how could I do to get the jira language with scriptRunner

yundong.li February 16, 2022

I want to get the jira language used by the current user through the Behaviour's Initialiser of scriptRunner,
How can I achieve this, can someone help?

2 answers

2 accepted

2 votes
Answer accepted
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 16, 2022

Hi @yundong.li ,

here code to retrieve logged in language :

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.user.UserLocaleStore;

JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
UserLocaleStore localeStore = ComponentAccessor.getComponentOfType(UserLocaleStore.class);
ApplicationUser loggedUser = jiraAuthenticationContext.getLoggedInUser();
Locale locale = localeStore.getLocale(loggedUser);
String language = locale.getDisplayLanguage();

 

This should work.

Regards,

Fabio

yundong.li February 16, 2022

hi @Fabio Racobaldo _Herzum_ 

Thank you very much.

it works very good!

1 vote
Answer accepted
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 16, 2022

Suggest an answer

Log in or Sign up to answer