v0.5.0. Users can change the interface language instantly with a single click from their settings page.
Configuration
Available languages are configured incustom/conf/app.ini under the [i18n] section. All supported languages are enabled by default:
Contributing translations
Translations live in theconf/locale directory of the repository, one locale_<lang>.ini file per language. To add a missing translation or correct a wrong one, edit the file of your language and send a pull request on GitHub.
1
Find the key
Add
?i18n_debug=1 to the address of any page, e.g., https://gogs.example.com/explore/repos?i18n_debug=1, to show the key name of every string in front of it, such as 「home.my_repos」My repositories. It stays on while you navigate, until you reload the page without it. Messages the server sends already translated, such as form errors and activity feed headlines, do not show their key; search conf/locale/locale_en-US.ini for their English text instead.Then search for the key in your language’s file. Keys with a dot are under a section, e.g., home.my_repos is my_repos below the [home] header.2
Edit the message
Change the text after the
= sign. Keep every placeholder in curly braces, such as {name} or {count}, and every HTML tag of the English message. You may move them to fit the word order of your language.3
Send a pull request
Open a pull request with your changes. The tests check that every placeholder of the English message is kept.
When translating, focus on conveying the meaning rather than producing a literal word-for-word translation. It is more important that the translation reads naturally in your language than that it matches the exact words of the English version.
Every language file has the same keys as
locale_en-US.ini. Changes that add or change English messages translate them into every language in the same pull request.Testing translations locally
If you want to test your translation without making changes to your Git history, place your locale file into:Custom locale files
If you are not satisfied with the official translation for your language, you can override individual fields by creating a custom locale file:custom/conf/locale/locale_en-US.ini and add only the keys you want to change. Restart Gogs to apply the changes.
Custom locale files only need to contain the keys you want to override, not the entire locale file. Unspecified keys will fall back to the official translation.