-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update locale files and translation docs (#4212)
- Loading branch information
Showing
3 changed files
with
1,134 additions
and
972 deletions.
There are no files selected for viewing
56 changes: 44 additions & 12 deletions
56
docs/getting-started/contributing/localization-and-translation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,59 @@ | ||
# Localization and Translation | ||
# Translate Hypha in to your own language | ||
|
||
Hypha offers translations into another language or translations into your organisation's vocabulary, or a combination of both. Hypha has functionalities for adopters to localize their own version with [Weblate](https://weblate.org/) or install another translation service if they prefer. Translations could also be implemented with a text editor. | ||
|
||
## Getting Started on Localization | ||
|
||
Translations of Hypha can be of two kinds. Translations in to another language or translations in to you organisations vocabulary, or a combination of both. | ||
There are two resons organisations make use of translations. They need Hypha in another language, like Spanish or Chinese. Another common need is to translate Hypha to suit a organisations vocabulary. A combination of both works as well of course. | ||
|
||
Our team is currently using [Weblate](https://weblate.org/) to manage translations of this project. Please visit Hypha's Weblate https://hosted.weblate.org/projects/hypha/ to start the translation process. You will need a Weblate account, and take it from there. [Weblate instructions and related documentation](https://docs.weblate.org/en/latest/user/basic.html) on translation is a great introductory resource. project on Weblate to contribute. If you are experiencing issues while you are working on translations, please open an issue on \[GitHub}. | ||
|
||
Adopters could also consider installing another translation service or apps for Linux/Windows/macOS po-files. In the **How to Edit the .po file in hypha/locale** we describe how translators can edit directly with a text editor. All translations will eventually be stored as django.po files. | ||
There is no requirement on using Weblate. An organisation can use any tool or service they see fit to translate the .po file. | ||
|
||
## Adding a language | ||
## Adding a language on Weblate | ||
|
||
If your language is not listed on packaging.python.org, click the button Start new translation at the bottom of the language list and add the language you want to translate. | ||
|
||
![400cf55f15e65d40324564503d44e959ed4d271a](https://user-images.githubusercontent.com/20019656/162624460-b3cec361-14b7-402a-b506-d688665c00f2.png) | ||
|
||
![0cb98ef6ae05630cb9db64ccc2cc35bc16f779f4](https://user-images.githubusercontent.com/20019656/162624457-bb52fb66-eda2-48fb-8aed-1ee9e88a7d8c.png) | ||
|
||
## How to Edit the .po file in hypha/locale | ||
## Find the translation files in Hypha | ||
|
||
This is the "template" that gets loaded in to translations services/apps. | ||
|
||
`hypha/locale/django.pot` | ||
|
||
This is the example English .po file. | ||
|
||
`hypha/locale/en/LC_MESSAGES/django.po` | ||
|
||
## Django commands | ||
|
||
To generate updated .po and .pot files for English (en) we use the following command: | ||
|
||
```bash | ||
m makemessages --locale en --ignore .venv --keep-pot | ||
``` | ||
|
||
This is done fairly regular to keep the translations up to date. | ||
|
||
You can use this command to generate a translation template for any language. Even if you are using weblate or another service to create the .po files this is a good way to start since you get the directory structure. | ||
|
||
```bash | ||
m makemessages --locale sv-SE --ignore .venv | ||
``` | ||
|
||
This will create `hypha/locale/sv_SE/LC_MESSAGES/django.po` | ||
|
||
It is the `django.po` file that contain all the translations. You can start to translate all the string in this file. | ||
|
||
If you already have a translated version, replace that files with the generated one. Make sure the name and path stay the same. | ||
|
||
It is then nessesery to complile the .po files in to binary .mo files. This command takes care of that. | ||
|
||
```bash | ||
m compilemessages --ignore .venv | ||
``` | ||
|
||
Hypha has translations to common strings propagated across other components within it by default. This lightens the burden of repetitive and multi version translation. The translation propagation can be disabled per Component configuration using Allow translation propagation in case the translations should diverge. | ||
If you update the .po files you will need to rerun the above command. | ||
|
||
Hypha's list of translatable strings is available here. | ||
Set `LANGUAGE_CODE = "sv-SE"` | ||
|
||
In cases where text strings are not yet translatable, a quick method to find out would be search in the .po file here. As an Adopter you could also edit “`hypha/locale/en`” and “`hypha/locale/[your_lang_code]`” any way you like. | ||
Restart your server to make it pick up the new translations files. |
Oops, something went wrong.