Liferay I18N support for Swahili Language
Liferay portal provides multilingual support of 34 languages for OOBT portlets. Below are the listed locale(languages) liferay provides supports for OOBT portlets,
|
But consider you encounter a situation where you have to add a new language support to Liferay that is not one of the ones supported? Like Thai (thai) , Swahili (sw) etc.
In this blog we see How we can add support of new language to liferay portal.
Let consider Swahili (sw) language for to add support in Portal.
For that follow below mentioned steps.
A. Each language that Liferay supports, has its own servlet-mapping and url-pattern defined for the same in "web.xml"
(which is inside LIFERAY_HOME\tomcat-<version>\webapps\ROOT\WEB-INF),
so we will have to make this arrangement for "Swahili" language. This first step will activate "Swahili" language in Liferay.
B. In order to make "sw" language visible in control panel and in Language portlet, we need to define the new locale in "portal-ext.properties".
C. Finally you need a hook to add a new "language_<sw>.properties" file with all the keys and their respective translations you want for "Swahili" language.
A: Go to web.xml file,
check below mentioned file path and do the change accordingly.
(LIFERAY_HOME\tomcat-<version>\webapps\ROOT\WEB-INF).
Add below mentioned (code) configurations into it.
i) <!-- Newly added language Swahili --> (Find appropriate location into file)
<servlet-mapping>
<servlet-name>I18n Servlet</servlet-name>
<url-pattern>/sw/*</url-pattern>
</servlet-mapping>
|
ii) <!-- Newly added language Swahili (Security constraint) --> (Find appropriate location into file)
<url-pattern>/sw/c/portal/protected</url-pattern>
|
B: Add SW language option into Control panel.
In order to make "Swahili" language visible in control panel and Language portlet,
we need to define the new locale in "portal-ext.properties".
Open "portal-ext.properties" and add “sw” at below mentioned property at last
locales= .. , ... , .. , sw
Save the "portal-ext.properties" file.
- Add sw.png image into below mentioned path so we can see image as well in control panel.
"Liferay-Home\tomcat-<version>\webapps\ROOT\html\themes\classic\images\language".
- Restart your Server.
- Go to Control Panel -> Portal Settings -> Display Settings.
- Find for Swahili locale into available locales tab.
- Once you found it lets move to Current locale tab.
- Check into Language portlet.
- Add Language portlet on page and check it shows SW.png or not?
- If you see there is sw.png then you can consider configurations is correct.
C: Finally you will need a hook to push your own "language_sw.properties" file into Liferay.
- Create Language property hook with below mentioned name.
"sw-Language-hook".
- Once hook is created successfully the add below code into web.xml in Hook plugin.
<language-properties>
content/Language_sw.properties
</language-properties>
|
- Then create new property file with below mentioned name into content folder in hook plugin.
“Language_sw.properties”
- Add all the properties key’s from “Language.properties” into “Language_sw.properties” with appropriate values in Swahili language.
Like below mentioned,
javax.portlet.long-title.99=Vitambulisho
javax.portlet.long-title.147=Jamii
javax.portlet.long-title.154=Wiki
javax.portlet.long-title.161=Blogs
javax.portlet.long-title.162=Bodi ya Ujumbe
|
- After this we are ready to deploy "sw-Language-hook".
- Prepare war for "sw-Language-hook" plugin and deploy into server.
- Once deployed successfully then check Language portlet and select Swahili locale.
- Test it properly with different keys.
References:
|
https://web.liferay.com/web/salman.khan/blog/-/blogs/add-a-new-language-to-liferay-detailed-step-by-step-
|
Comments