Expand my Community achievements bar.

SOLVED

Translation from adobe library

Avatar

Level 4

I need to get the translation for the key words mentioned below .i need a way to get the adobe internal library. Please let me know how to do it. I am using <fmt:message key="${keyword}" /> . 

 
I  could use 
 
/apps/project/i18n/en_US
/apps/project/i18n/nl_NL
 
but i am looking  from existing adobe library so that i need not do anything here.As  it is a generic locale list.


de_DE
es_ES
fr_FR
ja_JP
ru_RU
pt_PT
zh_CN
nl_NL
ko_KR
en

de
es
fr
ja
ru
pt
zh
nl
 
 
 
For the above keywords it must pick up based on locale so if  I am on english based page url locale
http://localhost:4503/content/corporate/cworld/en_US/generic.html
 
 
then  the translated content for "en" must be displayed "English"
 
 
If i am in  nl based page url
 
http://localhost:4503/content/corporate/cworld/nl_NL/generic.html
 
then  the translated content for "en" must be displayed "engels"
 
Thanks,
1 Accepted Solution

Avatar

Correct answer by
Level 10

Values stored in i18n can easily be accessed via java code. You need to get the locale object

<%@page session="false"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <%@page import="java.util.Locale,java.util.ResourceBundle,com.day.cq.i18n.I18n"%> <%@include file="/libs/foundation/global.jsp"%> <cq:setContentBundle/> <% final Locale pageLocale = currentPage.getLanguage(false); final ResourceBundle resourceBundle = slingRequest.getResourceBundle(pageLocale); I18n i18n = new I18n(resourceBundle); %> <%= i18n.get("cartItem") %>

Here are some helpful reference links as well:-

http://blogs.adobe.com/dekesmith/2012/10/21/internationalization-within-sling-and-cq/

http://hootcook.blogspot.in/2013/02/cq5-internationalization.html

http://www.albinsblog.com/2014/12/implementing-internationalization-with.html#.Vf2L6X0po3Y

View solution in original post

5 Replies

Avatar

Level 10

Hi,

Also please take care of path where you should have language node, it should be

/content/project/langauge-node/wesbite-pages.

Your path doesn't follow this. Here is the Documentation for the same : http://docs.adobe.com/docs/en/cq/5-6-1/administering/multi_site_manager.html#Managing%20Different%20...

Avatar

Level 4

But How to  use it .For example The  list above i have mentioned does not chage when i use  say <fmt:message key="es_ES" /> to  Spanish

Any inputs here  how could i use  it

Avatar

Correct answer by
Level 10

Values stored in i18n can easily be accessed via java code. You need to get the locale object

<%@page session="false"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <%@page import="java.util.Locale,java.util.ResourceBundle,com.day.cq.i18n.I18n"%> <%@include file="/libs/foundation/global.jsp"%> <cq:setContentBundle/> <% final Locale pageLocale = currentPage.getLanguage(false); final ResourceBundle resourceBundle = slingRequest.getResourceBundle(pageLocale); I18n i18n = new I18n(resourceBundle); %> <%= i18n.get("cartItem") %>

Here are some helpful reference links as well:-

http://blogs.adobe.com/dekesmith/2012/10/21/internationalization-within-sling-and-cq/

http://hootcook.blogspot.in/2013/02/cq5-internationalization.html

http://www.albinsblog.com/2014/12/implementing-internationalization-with.html#.Vf2L6X0po3Y

Avatar

Level 10

<fmt:message> is not there with sling. as @edubey mentioned use i18n.get()

However, make sure you have all the dictionary built for the words you need.

Refer these which might help

1. https://docs.adobe.com/docs/en/aem/6-0/develop/components/i18n/i18n-dev.html

2, https://docs.adobe.com/docs/en/aem/6-0/develop/components/i18n.html

3. https://docs.adobe.com/docs/en/aem/6-0/develop/components/i18n/translator.html