Localization trouble

Enonic version: 6.15.2

I have some questions related to localization and fallback, for version 6.15.2

I found that for a new Danish subsite, the site did not pick up the new properties file automatically. That was mystifying, but then I discovered that there were at last two variants to choose from for all languages. This makes sense for languages with two or more variants, like Norwegian, but seems unnecessary for Danish, which to my knowledge has only one. However, it did not work regardless.

The customer had used the setting ‘Dansk (Danmark) (da-DK)’ instead of ‘Dansk (da)’, so my phrases_da.properties was not picked up. Renaming the file to danish_da_dk.properties had no effect, I even tried with dk in uppercase (contrary to the documentation), but to no avail. Not until I changed the language to ‘Dansk (da)’ instead of ‘Dansk (Danmark) (da-DK)’ did the site pick up the language variables. But then it worked, reading from the file phrases_da.properties. The other file, phrases_da_dk.properties was never read.

I found this a bit strange, shouldn’t the site pick up my phrases_da_dk.properties file for the ‘Dansk (Danmark) (da-DK)’ setting? Or even fall back to the danish_da.properties file if the other one was not present? Did I miss a setting? It falls back to the phrases.properties files, if the language setting is not set to ‘Dansk (da)’ but to ‘Dansk (Danmark) (da-DK)’. It works now with the language set to Dansk (da), but I am wondering if this is due to a bug or something I missed.

It will pick up the file that is closest to the language set on the site. I.e if your site uses (da) it will look for a file called “phrases.da.properties” if not found it will go to “phrases.properties”. It will never try to expand to a more specific file.

However, if your site language is set to “da-DK”, it would have resolved the “phrases.da.properties” file.

I assume you mean phrases_da.properties, and not phrases.da.properties? Yes, this I know, and it does. However, the second part, is what I assumed, language set to da-DK: it does not resolve to either phrases_da.properties, or phrases_da_dk.properties, but directly to phrases.properties. So I am wondering if this is a bug, or if I missed something.

It will probably resolver to phrases_da-DK.properties

But that’s the thing. It does not.

Even when you choose da-DK as your language?
Will have to look i to it…

Exactly. That’s why I’m wondering :slight_smile: I may have done something wrong, but can’t quite figure out what, if so. I tried with various properties files present, with lowercase, uppercase, da_dk, and dk_da… but to no avail.

Just remembered. You did check the “site” langauge right, not a single item within the site?
The resolution is based on the site, not every single item within it. That would cause a messy experience when phrases would change for every page you look at…

Hi,

Are we talking here about:

  • The i18n library (i18n.localize)?
  • Or the translation of contenttype/site/… forms in Content Studio.

That can create confusion because they are resolved differently.

  • i18n: If you do not specify a locale, the language set on the site is used yes.
  • The second one is done based on the preferred languages (set in the browser of the current user).

If we are talking about i18n.localize, I did some test on Enonic XP 6.15.7:

  1. Site with language “da” and file “phrases_da.properties” -> Found
  2. Site with language “da-DK” and file “phrases_da.properties” -> Found
  3. Site with language “da-DK” and file “phrases_da_dk.properties” -> Not Found
  4. Site with language “da-DK” and file “phrases_da_DK.properties” -> Found

So you are right that the documentation is wrong to lower case dk. We will fix it.
But I do not reproduce your problem. A site with language “da-DK” will use the file “phrases_da.properties”.

We are talking about i18n.localize.

Interesting, here are my results:

Site with language “da” and file “phrases_da.properties” -> Found
Site with language “da-DK” and file “phrases_da.properties” -> Not Found
Site with language “da-DK” and file “phrases_da_dk.properties” -> Not Found
Site with language “da-DK” and file “phrases_da_DK.properties” -> Not Found

Bear in mind, the version is 6.15.2. I’ll test with 6.15.7 later, when we upgrade the site.

Not reproduced with 6.15.2.
What is the version of lib-i18n that the application is using?