This documentation is for WSO2 API Manager 2.1.0 View documentation for the latest release.
Page Comparison - Adding Internationalization and Localization (v.7 vs v.8) - API Manager 2.1.0 - WSO2 Documentation

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: https://wso2.org/jira/browse/DOCUMENTATION-6630

...

  1. Follow the instructions in your Web browser's user guide and set the browser's language to a preferred one. For example, in Google Chrome, you set the language using the Settings -> Show advanced settings -> Languages menu.
  2. Set the browser's encoding type to UTF-8.

    Introduction to resource files

  3. Go to  <APIM_HOME>/repository/deployment/server/jaggeryapps/publisher directory where <APIM_HOME> is the API Manager distribution's home.
  4. There are two types of resource files used to define localization strings in the API Manager.
    • The resource file used to store the strings defined in .jag files according to browser locale (For example, locale_en.json) is located in .../publisher/site/conf/locales/jaggery folder.
    • The resource file i18nResources.json, which is used to store strings defined in client-side javascript files such as pop-up messages when a UI event is triggered, is located in .../publisher/site/conf/locales/js folder.

    For example,

    To implement localization support for jaggery, we use its in-built script module 'i18n'. For more information, refer to http://jaggeryjs.org/documentation.jag?api=i18n.

    Localizing strings in Jaggery files

  5. To localize the API publisher to Spanish, first localize the strings defined in jaggery files. Create a new file by the name locale_{lolcaleCode}.json inside ...publisher/site/conf/locales/jaggery folder. For example, if the language set in the browser is Spanish, the locale code is es and the file name should be locale_es.json.
  6. Add the key-value pairs to locale_es.json file. For an example on adding key value pairs, refer to locale_en.json file in ...publisher/site/conf/locales/jaggery folder. It is the default resource file for jaggery.

    Note

    According to the language set in your browser the file name which includes the locale code is different. As described in step 5, you need to create a new file if there is no file existing for the language that you select. The file Name should The file Name should be  locale_{lolcaleCode}.json json where the localeCode refers to the sub tag of the subtag of the particular language. Please refer the the IANA Language Subtag Registry page for a list of subtagsof sub tags.

    By maching with the By matching the accept Language header, the particuar file the particular file will be selected from the resource file directory of each web application for the localization by the server. If there is no locale file found with the matching sub tag, locale_default.json file will be served for the localization.


    In addition, a section of a sample locale_es.json file is shown below for your reference.

    Localizing strings in client-side Javascript files

  7. To localize the javascript UI messages, navigate to publisher/site/conf/locales/js folder and update i18nResources.json file with relevant values for the key strings.
  8. Once done, open the API Publisher web application in your browser (https: //<YourHostName>:9443/publisher).
  9. Note that the UI is now changed to Spanish.