Server.Coldfusion.SupportedLocales includes unsupported locales

Description

<cfscript> n = 1.23456; </cfscript> <cfloop LIST = "#Server.Coldfusion.SupportedLocales#" index = "locale" delimiters = ","> <cfset oldlocale = setLocale(locale)> <cfoutput>#locale# #decimalformat(n)#<br></cfoutput> </cfloop>

Lucee 5.2.5 crashes with unsupported Locale [sr_BA_#Latn] on line 8
Lucee 4.5 crashes with unsupported Locale [ja_JP_JP_#u_ca_japanese] on line 8
acf supports all advertised locales

https://trycf.com/gist/2150f3bfcb9b705b03a850b59dfa1c43/acf2016?theme=monokai

Environment

None

Activity

Zac Spitzer 
9 December 2022 at 08:50

round tripping lsParseDateTime( lsDateTimeFormat(testDate)); only works with a few locales

https://trycf.com/gist/1756dba868cb089cf8f614d3399dc331/lucee5?theme=monokai

Andreas R 
16 September 2020 at 10:20
(edited)

I came accross this issue during experimentations and would like to complement some additional informations.

  • The locales sr_BA_#Latn, sr_ME_#Latn, sr_RS_#Latn, ja_JP_JP_#u-ca-japanese, th_TH_TH_#u-nu-thai are Java Locales IDs. The locales given by server.Coldfusion.SupportedLocales are all English Locales DisplayNames from the underlying Java, with the exception of these 5 mentioned above (which are Locale IDs. Why? Maybe the corresponding displaynames had “,” and this would break the list server.Coldfusion.SupportedLocales?

  • Because Lucee’s cfml setLocales() can have the Java DisplayName OR Java LocaleID passed as an argument, you can set them with it’s corresponding English DisplayNames as workaround/alternative.

    sr_BA_#Latn: setLocales("Serbian (Latin,Bosnia and Herzegovina)") sr_ME_#Latn: setLocales("Serbian (Latin,Montenegro)") sr_RS_#Latn: setLocales("Serbian (Latin,Serbia)") ja_JP_JP_#u-ca-japanese: setLocales("Japanese (Japan,JP)") th_TH_TH_#u-nu-thai: setLocales("Thai (Thailand,TH)")

That means that the issue could possibly be resolved by populating server.Coldfusion.SupportedLocales with all English DisplayNames of the Java Locales. For better illustration/proof run simple test template below testSetLocales.cfm. It outputs data with setting server.Coldfusion.SupportedLocales and java.util.Locales.getAvailableLocales() with DisplayName as proof.

If it comes to compability with ACF: ACF accepts ALL Locale IDs of Java.util.Locale.getAvailableLocales() and only a small set of DisplayNames. Lucee accepts all from both with exception of the 5 issued above. Thus it would be even better for compability reasons to make these work and then populate server.Coldfusion.SupportedLocaleswith Locale IDs and DisplayNames alltogether in Lucee.



for demonstration testSetLocales.cfm

<cfoutput> <cfscript> JavaLocale = CreateObject( "java", "java.util.Locale" ); tmp=JavaLocale.setDefault("en"); availableJavaLocalesArray=JavaLocale.getAvailableLocales(); loop list="Server.Coldfusion.SupportedLocales.listToArray(),availableJavaLocalesArray" item="localeArray" { ``` <table border="1" style="white-space: nowrap;margin-top:50px"> <tr> <th colspan="5" style="background-color: yellow;">Locale with '#localeArray#'</th> </tr> <tr> <th>Number</th><th>Locale</th><th>DisplayName()</th><th>Currency</th><th>Date/Time:</th> </tr> ``` counter=1; loop array="#evaluate(localeArray)#" index="index"{ ``` <tr> <td>#counter#.</td> <td>#index#</td> <td> <cfif localeArray is "availableJavaLocalesArray"> #index.getDisplayName()# </cfif> <cftry> <cfif localeArray is "availableJavaLocalesArray"> <cfset setlocale(index.getDisplayName())> <cfelse> <cfset setlocale(index)> </cfif> <td>#lscurrencyformat(1000.95)#</td> <td>#lsDateFormat(now())# #lsTimeFormat(now())#</td> <cfcatch type="any"> <td colspan="2" style="background-color: red;color: ##fff">NOT SUPPORTED: #cfcatch.Message#</td> </cfcatch> </cftry> </tr> ``` counter++; } ``` </table> ``` } // Proof that display names work on Lucee hardcoded unspportedLocalesAsDisplayNames=[ "Serbian (Latin,Bosnia and Herzegovina)", "Serbian (Latin,Montenegro)", "Serbian (Latin,Serbia)", "Japanese (Japan,JP)", "Thai (Thailand,TH)" ]; loop array="#unspportedLocalesAsDisplayNames#" index="index"{ setlocale(index); writeOutput("Locale set with setlocale(""#index#""): Currency: #lscurrencyformat(1000.95)#<br>"); } </cfscript> </cfoutput>

Pothys - MitrahSoft 
20 November 2017 at 14:51

I've added test case for this ticket, Lucee doesn't supports for following locales from #Server.Coldfusion.SupportedLocales#.

sr_BA_#Latn sr_ME_#Latn sr_RS_#Latn ja_JP_JP_#u-ca-japanese th_TH_TH_#u-nu-thai

In below three locales were working fine while removed '#'

sr_BA_Latn sr_ME_Latn sr_RS_Latn

Pull Request: https://github.com/lucee/Lucee/pull/341

Michael Offner 
18 November 2017 at 01:26

can you please make a testcase for this?

Pothys - MitrahSoft 
9 October 2017 at 14:19

I've analyzed this ticket & confirmed the issue happened on latest version of lucee. We can able to setLocale from the server.coldfusion.SupportedLocales.

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 6 October 2017 at 10:33
Updated 9 December 2022 at 08:50