Development
Internationalization
Ensure that the Go compiler is installed and then install the necessary helper commands:
go install github.com/nicksnyder/go-i18n/v2/goi18n
go install gitlab.com/particiapp/particiapp-reference-frontend/cmd/extracti18n
Translating into a new language
First create an empty translation file for the language for which you want to provide translations. The filename must conform to the scheme translate.<language-code>.json
where language-code
is a valid BCP 47 language tag code. E.g. create translate.de-DE.json
for German (Germany) translations:
cd internal/resources/resources/lang
touch translate.de-DE.json
Next merge the translatable messages from the default language (en) into the new translation file, e.g.:
goi18n merge -format json active.en.json translate.de-DE.json
Now you can edit translate.<language-code>.json
and translate the messages into the desired language. See the go-i18n documentation for further information on the translation file format. When you are done rename the file from translate.<language-code>.json
to active.<language-code>.json
, e.g.:
mv translate.de.json active.de.json
Please submit your translation on GitLab as a merge request on the particiapp-reference-client project.
Updating translations
In case messages have been added or removed from the source file the default language translations will need to be updated using the following command:
cd internal/resources/resources/
extracti18n -outdir lang index.tmpl
If any messages were added to the source file you first need to add translations in the default language by editing lang/active.en.json
.
After any changes to the default language translations you need to merge the changes to the translation files of all other languages:
cd lang
goi18n merge -format json active.*.json
This will create a new file translate.<language-code>.json
for each existing file active.<language-code>.json
containing only messages which have been added or changed. In order to update the translations edit any of these new files and then merge back the changes using the following command:
goi18n merge -format json active.*.json translate.*.json