Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-59390

JIRA's UK locale name "en_UK" is invalid and causes various localization failures

    XMLWordPrintable

Details

    Description

      The incorrect locale name "en_UK" in the default JIRA UK language pack causes JIRA to supply an invalid Locale object for itself and for dependent plugins, which results in a wide range of localization failures when users have that language profile selected.

      The correct locale string is "en_GB", as defined by Java itself. The language pack provided with JIRA should have its suffix changed to en_GB in order to work properly.

      Providing the wrong en_UK locale string causes the following problems:

      Issue #1: JIRA provides two "English - United Kingdom" options in language lists

      a- If your JVM is configured to start up with the English default locale as follows:

      -Duser.country=GB -Duser.language=en

      then administrators will see two English options when configuring the system default language under Cog->System->General Configuration->Edit Settings:

      1. English - United Kingdom [default]
      2. English - UK

      The first choice above will provide a legal Locale object for the UK (since it copies the system default locale). The second option results in an invalid Locale object being provided to the user. (If the JVM is not configured for the UK locale, only the invalid "English - UK" locale option will be presented and there will be no opportunity to receive a valid UK Locale object.)

      b- If the system administrator has "English - United Kingdom" selected as the system default language as above, then when users go to select a language in their language profile, they too will be able to select either "English - United Kingdom" or "English - UK" as their language. If the user selects "English - UK", the user will receive an invalid Locale.

      However, if the administrator selects any other default locale in the General Configuration page (such as "English - UK" or "English - US"), or if the JVM is not configured to have the UK as the default locale at all, then users will only see the one invalid UK locale ("English - UK") in the language list in their profiles, and they will not ever be able to select a correct UK locale either.

      Issue #2: the Locale object returned for the "English - UK" locale is invalid and some Locale methods throw exceptions

      If the user has selected the invalid "English - UK" locale, then the Locale object throws exceptions when trying to access some methods.

      For example, this call:

      Locale locale = ComponentAccessor.getJiraAuthenticationContext().getLocale();
      String country = locale.getISO3Country();
      

      throws a MissingResourceException when the user has the "English - UK" locale selected. The call works correctly (and returns the expected "GBR") when the "English - United Kingdom" locale is selected.

      Issue #3: an invalid currency symbol is provided for the "English - UK" locale

      If we ask Java to give us the currency symbol for the user's locale:

      DecimalFormat decimalFormat = (DecimalFormat)NumberFormat.getInstance(locale);
      String currencySymbols = decimalFormat.getDecimalFormatSymbols().getCurrencySymbol();
      

      then we get the correct "£" symbol if the user selected "English - United Kingdom", but a "¤" symbol if the user selects "English - UK".

      Issue #4: Calendar objects returned for the "English - UK" locale report wrong week numbers

      In the UK, a week is defined as starting on Monday. Additionally, the first week in a year is considered to be the first week which contains at least four days of the year. (Reference: Java Calendar class, and also the defaults in the CalendarData_en_GB class in the JRE). Therefore, in the UK, week #1 of January 2016 begins on Monday 2016-01-04. If the user selects the "English - United Kingdom" locale and requests a calendar object with Calendar.getInstance(locale), then this is what they get.

      If the user selects the English - UK locale, the locale tells us that the week begins on Sunday and that the first week must contain only one day of the new year. If the user has the invalid "English - UK" locale selected, Calendar objects tell us that week #1 of January 2016 begins on Sunday 2015-12-27, which is incorrect.

      Attachments

        1. admin-two-locales.png
          admin-two-locales.png
          189 kB
        2. user-two-locales.png
          user-two-locales.png
          162 kB

        Issue Links

          Activity

            People

              Unassigned Unassigned
              7c60ab039b09 Scott Dudley [Inactive]
              Votes:
              8 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated: