Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Localization

String literals in Wisk are localized and translated to French and Spanish.

Translations are stored in Firestore in the localization collection.

img_31.png

These keys are used from Web, iOS and API code to offer messages in the venue’s language.

Usage

How to use it from Web code

On web the translations live in the state. Before the translations arrive from Firestore collection they are taken from src\modules\translations.js file. To use translations just get them from the store like this mapState(['translations'), then in a template just use the desired key, for example ``. The keys in the translations object are loosely namespaced, meaning that the key name has a logic, like follows. The name after teh prefix should point to the entity/component in the project where is being used, or if it is a generic text, the name contains the word Generic. The prefix, most of them start with txt which means it is a simple string and some of them start with tpl which means it is a template. To use template translations we must call the method translations.translate, pass the key as first parameter and a map object as the second parameter, like this: ${this.translations.translate ('tplSubrecipeRecipePDFFor', { '{a}': this.subrecipe.title })}.pdf, where the string '{a}' will be replaced with the string passed as the value. Template keys must be of specal format which has no danger of benig replaced by the translation engine. There are also group translations which are used in automatically mapping the translated text to a value in an enumeration, like a status.

In order to update the translations on web there is a process in place, needed in order to transform the keys used by the web project to match the structure expected by the localizations service. To see the console it is best if used in local mode running of the web project. The process is as follows:

  1. In file src\modules\translations.js add/remove/update the new key and text by following existing style
  2. In wisk-localization git repository, pull latest changes, open the file src\main\resources\wisk\wisk-EN.json in a text editor, select all and copy it to clipboard. Don’t close it yet.
  3. Go to /translations URL in the project and in the big textarea paste the text from the clipboard
  4. Push the button to process the translations. If the console is open, a message will be visible, saying the new text was coppied to clipboard
  5. In the file src\main\resources\wisk\wisk-EN.json still open and with everything selected, paste from clipboard the updated text, then save and close the file.
  6. Push latest translations to git.

How to use it from iOS code

LocalizationService.localizedString(for: "ios.swipe.add_new")

How to use it from API code

LocalizationService.localizedString(language: language, term: "api.cannotChangePasswordForUser")

How to add a new translation

Translations are kept in wisk-localization project, inside the file called wisk-EN.json.

To add a new translation, you need to add a new key with the english text.

"api.venueIsNotPartOfGroup": "This venue is not part of a group",

You can also pass parameters to the localization key.

"api.venueIsNotALinkedVenue": "Selected venue {1} is not a linked venue",

This wisk-localization project has only a master branch, and the keys will be published to the firestore collection in all three environments on every push.

img_32.png

Translating to other languages

Files from French and Spanish are also kept in the same project, but we don’t have to touch them directly.

For translation, we use a solution called POEditor (credentials can be found in Notion)

The actual translation needs to be triggered manually, using the following instructions: https://www.loom.com/share/1927e51c3c42434c9808cd4b4c9caa29