Skip to content

Adding New Text and Updating the Translations

zstadler edited this page Dec 16, 2018 · 16 revisions

Adding new text to the site

In order to enable translation of the site to different languages, text that appears on the screen should never be hard coded.

The following steps are required for every new text:

  1. Add a new variable to the ResourcesService class in IsraelHiking.Web\sources\application\services\resources.service.ts. Try adding it to the closest related group.
    For example:

    public about: string;
  2. Add an assignment of text to the new variable in the setLanguage method in ResourcesService. Use gettextCatalog with a representative English text to get the language-dependent value for this variable.
    For example:

    this.about = this.gettextCatalog.getString("About");
  3. Use this variable rather than the text itself in the code.
    For example, using angular in an HTML file:

    {{resources.about}}

    or in TypeScript:

    toastService.error(this.resources.about);

Translate in Zanata

Important Note: Make sure you have a secrets.json file that contains the following fields (See the readme on how to find/open the file):

{
        ...
	"zanataUserName": "your-zanata-user-name",
	"zanataApiKey": "api-key-from-zanata"
}
  1. Open command prompt and change to the IsraelHiking.Web folder.

  2. Run npm install

  3. Run npm run 1-upload. After extracting the translations and uploading an updated pot file to the IsraelHiking Zanata project.

  4. Your browser will show two new tabs containing the untranslated words in Hebrew and English.

  5. Translate the remaining phrases in both languages and save each one with Ctrl-Enter.

  6. You may also improve the existing translations by clearing the "Incomplete" checkbox. Specific phrases can be found using the search box.

  7. When translation is complete type npm run 2-download - this will download the needed files and convert them to JSON.

  8. Commit the translation files to Github (IsraelHiking.pot, he.json, and en-US.json in teh IsraelHiking.Web\sources\translations folder).

Manually uploading a pot file to Zanata

This is mainly for documentation or in case the upload of the pot file fails for some reason. It shouldn't be done when everything is working as expected.

  1. Go to the project Setting page on Zanata, login if needed, open the "Documents" list,

  2. Add the updated IsraelHiking.Web\translations\IsraelHiking.pot file,

    and upload it.

  3. The new texts can now be translated using Zanata UI. You may want to select the Incomplete checkbox to view just that texts that were not translated yet.

  4. Follow the instructions above to complete the translation and updates.