Changing the USER_LOCALE preference through the plugin


We have a plugin that creates two users (one English user and one French user) and then creates tickets through those users.

Upon creation, the English user is automatically set to the default Locale (that being English), but the French user needs to be set to the French language.

The issue is, how can I (through java programming) change their USER_LOCALE preference, if the user is created through the plugin, without a password.

The following doc shows the fields I want to change, but I am not sure what methods to use to do so:

Any help is appreciated!

Just from the Java API I think this could work (had no time to test it)

import com.atlassian.jira.user.preferences.ExtendedPreferences;
import com.atlassian.jira.user.preferences.PreferenceKeys;
import com.atlassian.jira.user.preferences.UserPreferencesManager;

        try {
          ExtendedPreferences prefs = userPreferencesManager.getExtendedPreferences(theApplicationUser);
          prefs.setString(PreferenceKeys.USER_LOCALE, "en_US");
        } catch (Exception e) {
          System.err.println("Something went wrong: " + e.getMessage());

At best buy a valid Jira license and download the Jira Source code and really search the codebase for USER_LOCALE, there you will surely find the snippet you need :slight_smile:

Thanks a lot @clouless, that worked wonderfully and was the solution I was looking for.

Cool :slight_smile: Just be careful that you set a locale in the right format, since otherwise when this user logs-in his profile pages will be damaged ^^ I had this issue once and it was due a wrongly set locale via REST API. There seems to be no validation on the format :slight_smile: