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,


  1. Arabic (Saudi Arabia) - ar_SA
  2. Basque (Spain) - eu_ES
  3. Bulgarian (Bulgaria) - bg_BG
  4. Catalan (Andorra) - ca_AD
  5. Catalan (Spain) - ca_ES
  6. Chinese (China) - zh_CN
  7. Chinese (Taiwan) - zh_TW
  8. Czech (Czech Republic) - cs_CZ
  9. Dutch (Netherlands) - nl_NL
  10. English (United States) - en_US
  11. Estonian (Estonia) - et_EE
  12. Finnish (Finland) - fi_FI
  13. French (France) - fr_FR
  14. galician (Spain) gl_ES
  15. German (Germany) - de_DE
  16. Greek (Greece) - el_GR
  17. Hebrew (Israel) - iw_IL
  18. Hindi (India) - hi_IN
  19. Hungarian (Hungary)- hu_HU
  20. Italian (Italy) - it_IT
  21. Japanese (Japan)- ja_JP
  22. Korean (South Korea) - ko_KR
  23. Norwegian - nb_NO
  24. Farsi/Persian (Iran) - fa_IR
  25. Polish (Poland) - pl_PL
  26. Portuguese (Brazil) - pt_BR
  27. Portuguese (Portugal) - pt_PT
  28. Russian (Russia) - ru_RU
  29. Slovak (Slovakia) - sk_SK
  30. Spanish (Spain) - es_ES
  31. Swedish (Sweden) - sv_SE
  32. Turkish (Turkey) - tr_TR
  33. Ukrainian (Ukraine) - uk_UA
  34. Vietnamese (Vietnam) - vi_VN


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

Popular posts from this blog

Export & auto sync Liferay Calendar events with Outlook & Google Calendar

Configure SOLR with Liferay