Skip to content

TUD translations

Alfonce Nzioka edited this page Apr 13, 2021 · 23 revisions

This page describes two approaches to updating the Time Use Diary tool to support a new language. Both approaches involve editing a JSON file and replacing English text with the correct translations.

Approach 1: Editing an existing JSON file

In this approach, the user is provided with a link to the file that needs editing.

  1. Open the provided url in a browser
  2. On the top toolbar, click on the Edit icon to edit file. edit
  3. Go through the file line by line, replacing the text on the right of double colons with the appropriate translation.
  4. Once you have finished editing, scroll to the bottom of the page to the "Commit changes" section.
  5. In the text box, type a short description of what you have done. For example: Added Spanish translations
  6. Select create new branch and enter the name of the branch. For example: task-add-spanish-translations
  7. Click on the Propose changes button. This will redirect to a page where you can open a pull request.
  8. Click on the Create pull request button.

At this point the changes are ready for review by the team.

Approach 2: Creating a JSON file from scratch.

In this approach, the user will create a new folder and add a translation.json file to the folder. The name of the folder is unique to each language and corresponds to the ISO Language Code. For example, Swedish translations will be put in a folder named sv.

  1. Visit http://www.lingoes.net/en/translator/langcode.htm and look up the code of the language you want to translate.

  2. On Github, navigate to https://github.com/openlattice/chronicle-web/tree/develop/src/core/i18n

  3. On the toolbar, click on Add file button and select Create new file from the drop down list. Add file

  4. In the top input text box, enter the name of the folder followed immediately by a / (There should be no space before the /). This should create a new folder and reveal an empty text box to the right.

  5. Type translation.json in the text box and press Enter.

  6. Copy English translations to the new page.

    1. Open https://github.com/openlattice/chronicle-web/blob/develop/src/core/i18n/en/translation.json in a new tab
    2. On the toolbar click on the Raw button.
    3. Select all the text in the opened page. Right click and select copy. For Mac users, this can be achieved by pressing command + A followed by command + C on the keyboard. Windows users can press Ctrl + A followed by Ctrl + C
  7. Paste the copied text to the new page edit window.

  8. Follow steps 3 - 8 in Approach 1 above to provide the correct translations and create a pull request.

Editing translation.json file

Please note the following:

  • Most of the entries in the translation.json file have a key:value format. When editing, you should only provide translation for the value text. For example:

Here you would only need to translate the lines: "Thank you for taking the time..." and "To get started, ..."

  • If the value is a list, ensure the order of the translated list exactly matches the original. For example: In the translated version, the first item will correspond to "Monday" and the last item will correspond to "Sunday".

  • Some of the text that needs to be translated contains {{ }}. You shouldn't modify any text between these double brackets. This text will eventually be replaced with actual values when a participant fills out the survey. For example: In this case, {{time}} will be replaced with the end time of the previously selected activity and should appear in your translated version.

  • In the event of a nested object, only translate the values that are on the right of the : For example: Here you would only need to translate "Attending school/childcare", "Napping/sleeping" etc