掲示板

Localization of Portlet

thumbnail
11年前 に Narmada V によって更新されました。

Localization of Portlet

Junior Member 投稿: 37 参加年月日: 12/05/14 最新の投稿
hi
I am trying to localize my portlet. I have added the below changes.

1. view.jsp:

<%@ page import="java.util.ResourceBundle" %>
<%@ page import="java.util.Locale" %>

<%
Locale locale = (Locale)request.getSession().getAttribute("org.apache.struts.action.LOCALE");
String language = locale.getLanguage();
String country = locale.getCountry();
ResourceBundle res = ResourceBundle.getBundle("content/Language_zh_TW", new Locale(language, country));
%>

<input type="button" value="<%= res.getString("hello-world") %>" />

2. created Language_sh_TW.properties and Language_sh_CN.properties files and added the below content.

javax.portlet.title=May15 Portlet
javax.portlet.short-title=May15portlet
javax.portlet.keywords=May15,portlet
hello-world=Hello World

3. I have modified the portlet.xml file as below.
<supported-locale>es</supported-locale>
<supported-locale>zh_CN</supported-locale>
<supported-locale>zh_TW</supported-locale>
<resource-bundle>content.Language_zh_TW</resource-bundle>

Note: Language.properties and Language_sh_TW.properties and Language_sh_CN.properties fiels are under the folder root/WEB-INF/src/content.

Even by making all these changes, i am unable to localize my portlet.

Could anyone please let me know anythng must be done??
thumbnail
11年前 に Olaf Kock によって更新されました。

RE: Localization of Portlet

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
thumbnail
11年前 に Hitoshi Ozawa によって更新されました。

RE: Localization of Portlet

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
Be sure to include <%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>.

Information on liferay:ui tags
http://www.liferay.com/community/wiki/-/wiki/Main/Liferay+UI+Taglib
thumbnail
11年前 に Narmada V によって更新されました。

RE: Localization of Portlet

Junior Member 投稿: 37 参加年月日: 12/05/14 最新の投稿
This gives localization for the predefined keys. This is not working for the non-key words.

If I need to write my own message in the portlet, how can it be localized.
thumbnail
11年前 に Hitoshi Ozawa によって更新されました。

RE: Localization of Portlet

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
This is not working for the non-key words.

What do you mean by "non-key words". You're suppose to create a key with a matching word/sentence in the language properties.
You're suppose to create your own language properties files for your own portlet. This seems to be what you were doing from your first post.
thumbnail
11年前 に Narmada V によって更新されました。

RE: Localization of Portlet

Junior Member 投稿: 37 参加年月日: 12/05/14 最新の投稿
i am creating a custom portlet and trying to add some data to it. I want that data to be localized.

The code in jsp page is :
<liferay-ui:message key="yes" />
<liferay-ui:message key="hello-world" />

please find the screenshots attached.

as "yes" is predefined key word, i am getting it the language which i select. But "hello-world" is not the predefined key word. As mentioned, i have added it the Language_xx.properties file.

If i want to localize this hello-world, wat can be done.

添付ファイル:

thumbnail
11年前 に srikanth a によって更新されました。

RE: Localization of Portlet

Regular Member 投稿: 144 参加年月日: 11/02/21 最新の投稿
Hi Narmada,
One straight question to you.

1) Did you create the Language.properties for every supported language in your application.
2) If so did you put the key in all the files with respective translation.

if you have done this then you must get the value. Try to crosscheck it.


regards
Sri
thumbnail
11年前 に Narmada V によって更新されました。

RE: Localization of Portlet

Junior Member 投稿: 37 参加年月日: 12/05/14 最新の投稿
yes i have created language.properties file respect to all the supported languages.

Do u mean to say, I need to write the translation code in the every file for each language??

If yes, suppose if i am getting dynamic data from different website to the portlet. I am not sure of the data i am getting from it. If i wish to Localize such kind of custom portlet what should be done??

Isn't there any tool or any other way provided by Liferay to change the language with out defining the translation code in Language.properties for such requirements?
thumbnail
11年前 に Olaf Kock によって更新されました。

RE: Localization of Portlet

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
Do you reference your localization within portlet.xml?

<resource-bundle>content/Language</resource-bundle>


(Note: Portlets don't take the .properties ending while hooks do, there it's within the <language-properties> element)
thumbnail
11年前 に Hitoshi Ozawa によって更新されました。

RE: Localization of Portlet

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
Do u mean to say, I need to write the translation code in the every file for each language??


No. :-)

Isn't there any tool or any other way provided by Liferay to change the language with out defining the translation code in Language.properties for such requirements?


There actually isn't any requirement to use one specific way. It's possible to use other internationalization technique if you don't want to use liferay's.
thumbnail
11年前 に Vishal Panchal によって更新されました。

RE: Localization of Portlet

Expert 投稿: 289 参加年月日: 12/05/20 最新の投稿
Hi Narmada V,
to get your own message localized you should specify it in Language.properties file(s) and access using
<liferay-ui:message key="hello-world"/>

or
As you are asking about "non-key words" than
I think you r asking the localized value of the string which is not defined in Language.properties file(s).
e.g. you want to make the studentName as localized which is directly comes from database and you cant define it in Language.properties.
If I am right than you may do one thing is as following:-
(1) In service.xml you may define desired field with localized="true"
e.g.<column name="studentName" type="String" localized="true" />
(2) you can access it as locale specific in your page like
<%= HtmlUtil.escape(modelObj.getStudentName(locale)) %>


Thanks& Regards,
Vishal R. Panchal