Hi,
As per below link, I'm trying to access i18n string using javascript. I have included the clientlibs granite.util in my page.
https://docs.adobe.com/docs/en/aem/6-1/develop/components/i18n/i18n-dev.html
I have key/string as imported by {0} on {1}. I'm trying to access the i18n strings using below line of code
Granite.I18n.setLocale(
"de"
);
Granite.I18n.get(
"
imported by {0} on {1}"
, [userName, date],
"user name, date"
);
All I get was username and date substituted in the key as imported by Peter on 26th Aug. It doesn't give localized string. Whereas if I use below code
Granite.I18n.get(
"
Warning"
); It gives localized string "
Warnung:.
Kindly let me know if I miss something.
Thanks,
Ruben
Views
Replies
Total Likes
I assume you mean you are using JSP code right - not JavaScript. Can you post all of your code that you are using.
Views
Replies
Total Likes
No, I'm using Javascript not JSP. Please find the below sample code
Granite.I18n.setLocale("de");
var userName = "Peter";
var date = "26th Aug";
var text = Granite.I18n.get("imported by {0} on {1}", [userName, date], "user name, date");
console.log(text);
Views
Replies
Total Likes
Have you put the translation of your keywords in dictionary?
If yes, are you able to see the dictionary request in your browser? (Something like 'dict.en.json')
Views
Replies
Total Likes
Yes I have translation in the dictionary and I can see request in the browser 'dict.de.json'.
And response contains "imported by {0} on {1} ":" importiert von {0} am {1}"
But in javascript, it doesn't give translated value. Am I missing something. Above sample code is what I use
Views
Replies
Total Likes
You could use the CQ object like below:
CQ.I18n.getMessage('Key-name');
Views
Replies
Total Likes
Views
Likes
Replies