Prefer locale without script or variant

Assignee

Reporter

Sprint

Description

JVM keeps adding more and more builtin locales in every version. Our code that identifies locales in simple "en.US" fashion is not enough anymore.

 

Simply listing available locales via our methods provides more locales than we're ready for.

public static void main(String[] args) {         List<java.util.Locale> availableLocales = org.jetel.util.MiscUtils.getAvailableLocales();         for (java.util.Locale locale : availableLocales) {             String localeId = org.jetel.util.MiscUtils.localeToString(locale);             if (localeId.equals("fr.FR") || localeId.equals("en.US")) {                 System.out.println(locale.getDisplayName());             }         }     }

 

Running above code on JDK 11:

English (United States, Computer) English (United States) French (France)

Running above code on JDK 17:

English (United States, Computer) English (Latin, United States) English (United States) French (Latin, France) French (France)

So when clover/wrangler user picks "en.US" locale then one of the 3 different english locales will be used. It's not clear which one, it may even be random.

The Latin part is "script" of the locale, the Computer part is "variant" of the locale. These additional locales are being added in newer JDK versions.

 

I think we should update our code to always pick and provide the simplest locale available.

  • When "en.US" is used in metadata, locale "English (United States)" without any script or variant should be used if it's available.

  • Wrangler users should only be provided with simplest possible locale without any script or variant.

Steps to reproduce

None

Attachments

1
  • 18 Aug 2023, 09:59 AM

relates to

Activity

Show:

Pavel Salamon August 18, 2023 at 9:59 AM
Edited

Fixed:

  • If multiple locales are available for language/country, the simplest locale is preferred - the locale without script or variant fields.

In wrangler this fixes the labels of locales - the english locale no longer has "Computer" suffix, the french locale will not have "Latin" prefix.

Pavel Salamon August 18, 2023 at 9:19 AM

Preferring the locale without script means that from these 3 locales on java 17:

sr_RS               Serbian (Serbia) sr_RS_#Cyrl         Serbian (Cyrillic, Serbia) sr_RS_#Latn         Serbian (Latin, Serbia)

we'll use the sr_RS locale. Before these changes one of the 3 would be used "randomly".

Fixed

Details

Priority

Fix versions

QA Testing

UNDECIDED
Created July 28, 2023 at 10:51 AM
Updated October 3, 2023 at 8:44 AM
Resolved August 18, 2023 at 3:34 PM