Apologies for the duplicate post. Seems like something in the original is breaking the page, so I'll try this again:
We've got dictionary values set up like:
String EN FR
TEST-001 This is a Test1 FR:This is a Test1
TEST-002 This is a Test2 FR:This is a Test2
TEST-003 This is a Test3 FR:This is a Test3
I've looked through the Internationalizing UI Strings article (https://docs.adobe.com/docs/en/aem/6-2/develop/components/i18n/i18n-dev.html) but when I try to the following:
I only get returned the string I've passed in (i.e. "TEST-001").
Could someone help me understand how to retrieve the translated value back?
I'm not sure about the relationship between "String" and "EN" here, as the English string is typically the key. What do you get if you do:
Granite.I18n.get("This is a Test1");
The relationship between String and EN is based on the translator library found in /libs/cq/i18n/translator.html.
The String value is normally used as the lookup key in JSP or Sling and the EN is the actual translated value being returned if the locale is EN.
Regardless, if I pass the "This is a Test1" string into the Granite.I18n.get() function, with the locale set to FR, I still get back "This is a Test1"
Have you checked if your i18n works on JSP/Java? If it works there - I have no answer.
If not - make sure use set your dictionary correctly under /apps/your-app/i18n.
Also, your page should be under /content/your-app/...
Do you see any errors from your browser?
Can you check this url returns the expected information?
Consolidated i18n dictionaries are cached in the system. Therefore, addition of an entry may not reflect immediately. Does the dictionaries loaded at runtime have the keys TEST-001, TEST-002 and TEST-003 ?
Also, in case the keys are missing, one could update the cache by restarting the bundle - org.apache.sling.i18n.
The dictionaries do have the keys TEST-001, TEST-002, TEST-003 during runtime, as I can retrieve those values via JSP. I can even modify the values and see those changes come in via JSP after a page refresh