-
Notifications
You must be signed in to change notification settings - Fork 33
Adding New Text and Updating the Translations
Harel M edited this page Apr 4, 2024
·
16 revisions
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:
-
Add a new variable to the
ResourcesService
class inIsraelHiking.Web\sources\application\services\resources.service.ts
. Try adding it to the closest related group.
For example:public about: string;
-
Add an assignment of text to the new variable in the
setLanguage
method inResourcesService
. UsegettextCatalog
with a representative English text to get the language-dependent value for this variable.
For example:this.about = this.gettextCatalog.getString("About");
-
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);
- Open command prompt and change to the
IsraelHiking.Web
folder. - Run
npm install
- Run
npm run extract
to extract the required translations to en-US.json file - You can manually edit the other language files by adding the newly created key and the relevant translation and commit everything to github.
- Pushing the changes to github without locally translating will allow to edit the translation in the Crowdin editor.
- Once the translation is complete Crowdin will open a PR with the required changed straight to the repo.