掲示板

Portlet localization problem

9年前 に Gergo Feher によって更新されました。

Portlet localization problem

New Member 投稿: 22 参加年月日: 15/03/30 最新の投稿
Hello!

I try to localize my JSF based portlet, but i have some problems. I want to use a hungarian or a slovakien property file, named Language_hu.properties, and Language_sk.properties.The user could choose what language he/she want to use. I put those property files under src/main/resources folder, there is the Language_en_US.properties file also, but i don't want to use it.
In faces-config xml i added the following lines:
<locale-config>
<default-locale>hu</default-locale>
<supported-locale>sk</supported-locale>
</locale-config>
<resource-bundle>
<base-name>Language</base-name>
<var>label</var>
</resource-bundle>
<message-bundle>Language</message-bundle>
</application>

In portlet xml i added those lines:
<supported-locale>hu</supported-locale>
<supported-locale>sk</supported-locale>

In the liferay-hook.xml i changed the default configuration to this:
<hook>
<language-properties>Language_hu.properties</language-properties>
</hook>

Those changes didn't help, my portlet always takes the properties from the default english property file. If i delete it, i got missing resource exception.
My question is: what's the proper way to change the dafault and supported locale?

Thank you,
Gergo
thumbnail
9年前 に Andew Jardine によって更新されました。

RE: Portlet localization problem

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Hi Gergo,

I'm not sure if you want to localize just the portlet, or if you mean to localize the entire site (including the portlet). I'm not familair with JSF, but your configuration certainly looks correct. I know that it is possible to change the default language, as well as configure the supported languages in either the portal-ext.properties file or in the Control Panel.

If you want to set the default language for the site in the control panel, then go to --

Control Panel > Sites > [Your Site] > Configuration (section on left) > Site Settings and then choose "Display Settings" from the sub menu on the right. In there you can choose "Define a custom default language and additional available languages for this site." and then set the default language and supported languages. Once you have done that, it should pick up your file.

If you wish to do it via portal-ext.properties then it would be applicable server wide (all sites I believe) and the properties you would override are --


  #
    # Specify the available locales. Messages corresponding to a specific
    # language are specified in properties files with file names matching that
    # of content/Language_*.properties. These values can also be overridden in
    # properties files with file names matching that of
    # content/Language-ext_*.properties. Use a comma to separate
    # each entry.
    #
    # If there is more than one locale for the same language, the first one in
    # the list will be used when a translation is requested in another locale of
    # the same language but a translated value cannot be found. For example, if
    # there are two locales such us pt_BR and pt_PT (in this order), any key not
    # found in pt_PT will be looked for in pt_BR.
    #
    # Language codes follow the ISO 639-1 standard. Content for each locale must
    # be UTF-8 encoded.
    #
    # See the following links, which specify language and country codes:
    #     http://www.loc.gov/standards/iso639-2/php/code_list.php
    #     http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
    #
    locales=ar_SA,eu_ES,bg_BG,ca_AD,ca_ES,zh_CN,zh_TW,hr_HR,cs_CZ,da_DK,nl_NL,nl_BE,en_US,en_GB,en_AU,et_EE,fi_FI,fr_FR,fr_CA,gl_ES,de_DE,el_GR,iw_IL,hi_IN,hu_HU,in_ID,it_IT,ja_JP,ko_KR,lo_LA,lt_LT,nb_NO,fa_IR,pl_PL,pt_BR,pt_PT,ro_RO,ru_RU,sr_RS,sr_RS_latin,sl_SI,sk_SK,es_ES,sv_SE,tr_TR,uk_UA,vi_VN

    #
    # Specify the locales that are enabled by default.
    #
    locales.enabled=ca_ES,zh_CN,en_US,fi_FI,fr_FR,de_DE,iw_IL,hu_HU,ja_JP,pt_BR,es_ES

    #
    # This sets the default locale of the portal, overriding the properties
    # "user.language" and "user.country" specified in system.properties.
    #
    #company.default.locale=en_US
thumbnail
9年前 に Philip White によって更新されました。

RE: Portlet localization problem

Junior Member 投稿: 76 参加年月日: 15/03/11 最新の投稿
Hello Gergo!

For changing the locale, you may want to go here to learn more about internationalizing JSF portlets with Liferay.

Hope this helps!

Phil
8年前 に Gergo Feher によって更新されました。

RE: Portlet localization problem

New Member 投稿: 22 参加年月日: 15/03/30 最新の投稿
Hi!

Thanks for your help! I realized that i use the standard JSF machanism, that Philip linked. It works if i want to use only one property file for localization. But depends on the chosen locale i want it change dinamicallywhich property file i want to use. So e.g. if you use the default locale, the hungarian, i want to use the Language_hu.properties file. Another case i want to use the slovakien (Language_sk.properties) file.
So in my faces-config.xml i configured that:
<locale-config>
<default-locale>hu</default-locale>
<supported-locale>sk</supported-locale>
</locale-config>
<resource-bundle>
<base-name>Language</base-name>
<var>label</var>
</resource-bundle>
<message-bundle>Language</message-bundle>
</application>

But the problem is that, it can't find the resource. If i get another base-name it works well, e.g. <base-name>Language_hu</base-name>.
Can make it dinamically somehow?

Thanks,
Gergo
thumbnail
8年前 に Juan Gonzalez によって更新されました。

RE: Portlet localization problem (回答)

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Hi Gergo,

I can get it working without problems.

Did you set something like this in your portlet.xml?

<supported-locale>hu</supported-locale>
<supported-locale>sk</supported-locale>
<resource-bundle>Language</resource-bundle>
8年前 に Gergo Feher によって更新されました。

RE: Portlet localization problem

New Member 投稿: 22 参加年月日: 15/03/30 最新の投稿
Hi!

My problem was that i didn't set the resouce bundle in portlet.xml.

Thanks,
Gergo
thumbnail
8年前 に Juan Gonzalez によって更新されました。

RE: Portlet localization problem

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Hi Gergo,

glad you got it working now. Please mark the previous answer as the right one so other users can see it quickly for future reference.

Thanks for using Liferay Faces emoticon
8年前 に Gergo Feher によって更新されました。

RE: Portlet localization problem

New Member 投稿: 22 参加年月日: 15/03/30 最新の投稿
I marked, and also my previous posts!