Reputation: 1304
Following is my requirement:
I need to change language dynamically. So I have one button which will have toggle values. So when value is "English" it will show content in english and when value is something else say "Hindi" then it will show content in Hindi.
Is there any way to achieve this functionality dynamically?
Any help would be appreciated.
Thank you.
Upvotes: 0
Views: 2774
Reputation: 83
You can change with inbuilt language portlet. For Hindi language you can set below locales properties in portal-ext.properties. You add remove required supported locale.The Hindi locale beta version available after 6 liferay version.
locales.enabled=hi_IN,ar_SA,ca_AD,ca_ES,zh_CN,zh_TW,cs_CZ,nl_NL,en_US,fi_FI,fr_FR,de_DE,el_GR,hu_HU,it_IT,ja_JP,ko_KR,nb_NO,fa_IR,pl_PL,pt_BR,pt_PT,ru_RU,es_ES,sv_SE,tr_TR,vi_VN
To add it in the your custom theme use below code.
$velocityPortletPreferences.setValue("portletSetupShowBorders", "false") $velocityPortletPreferences.setValue("languageIds", "pt_BR,en_US,hi_IN") $velocityPortletPreferences.setValue("displayStyle", "1") $theme.runtime("82", "", $velocityPortletPreferences.toString()) $velocityPortletPreferences.reset()Upvotes: 4
Reputation: 253
you can switch using liferay urls.
if the language is english you can use localhost:8080/en/...
if the language is other you can use localhost:8080//...
Upvotes: 0