Categories

    How to translate chat plugin

    Chat plugin uses i18next and moments library for translation. There are 2 type of file used to translate in the plugin :

    1. Resources file  : This file will contain all the text available for translation . You can find the English-langue text is  in the file  public_html/app/Plugin/Chat/webroot/js/client/utils/locale/eng.js .

    2. Config file  : This file will contain the option for loading resources .

    Here is the step-by-step guide to translate  chat plugin . We assume that we want to translate community.moosocial.com  to Portuguese .

    1. Translating mooSocial to Portuguese .

    Check out https://moosocial.com/wiki/doku.php?id=how_to:translate_moosocial

    2. Getting ISO 639-2 Code

    Opening community.moosocial.com in Chrome  , switch to Portuguese  then run the code “window.mooConfig.language” in Console window to get “POR” code (  ISO 639-2 Code) . See image bellow

     

    3. Creating the POR resource file

    We  copy and rename the file public_html/app/Plugin/Chat/webroot/js/client/utils/locale/eng.js to public_html/app/Plugin/Chat/webroot/js/client/utils/locale/por.js  then you can start translating chat plugin . Translate a text is easy - just translate English to Portuguese . Example , we translate the key who_s_online by replacing  English text “Who's Online” to   “Quem está online”.

    4. Adding option for loading POR resource file in config file

    Opening the file  public_html/app/Plugin/Chat/webroot/js/client/utils/ChatMooI18n.js  then adding loaded options in the init function of i18next like bellow :

     

    5. Getting ISO 639-1 Code

    Opening community.moosocial.com in Chrome agian , switch to Portuguese  then run the code “window.mooConfig.language_2letter” in Console window to get “PT” code (  ISO 639-1 Code) . See image bellow

     

    6. Loading date PT resource file in config file

    Opening the file  public_html/app/Plugin/Chat/webroot/js/client/utils/ChatMooI18n.js  then uncomment the line 100 like bellow

     

    7. Creating the mooChat.js bundle file

    Connecting via SSH to community.moosocial.com , we go to the folder public_htm/app/Plugin/Chat/webroot/js/client  and run the command line “npm install” for installing module dependencies . After installing the dependencies , we run the next command line “npm run build”  for creating the bundle file in production mode then  we copy and replace the mooChat.js file in client folder to the file public_html/app/webroot/chat/js/client/mooChat.js .

    8. Refreshing(clear) the cache from our Chrome browser for community.moosocial.com and we get the translation .

     

    Noticed that we assume Portuguese example so the POR resource is not ready for  community.moosocial.com  . It means that you can not get the  Portuguese translation for chat plugin in step 8 .

     

    Thank you for using our chat plugin !

    Share
    0% users marked this FAQ as helpful. Is this FAQ helpful?

    Yes No

Comments (0)

No login