-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add New Language Support
Neutron supports multiple languages, allowing you to contribute translations in your preferred language. Follow these steps to add support for a new language:
Ensure you have the required package installed by running the following command:
pip install pybabel
- Navigate to the
app
folder of the Neutron project. - Locate the file named
messages.pot
, which contains the English text ready for translation.
- Make a copy of
messages.pot
and translate its contents into your target language. Save this file with an appropriate name, e.g.,messages_fr.po
for French translations.
Run the following commands from the terminal, replacing <your_translation_file>
and <your_language_iso_code>
accordingly:
cd app
pybabel init -i <your_translation_file> -d translations -l <your_language_iso_code>
For example:
pybabel init -i messages_fr.pot -d translations -l fr
Once you've initialized the translation, compile the translated messages into a format that Neutron can use:
pybabel compile -d translations
To incorporate a new language translation into Neutron, follow these steps to modify the source code:
-
Update
app/language.py
:Open the
language.py
file in your application's codebase. -
Modify the
LANGUAGES
Dictionary:Locate the
LANGUAGES
dictionary withinlanguage.py
and append the following entry:LANGUAGES = { 'en': 'English', 'vi': 'Vietnamese', '<your_language_iso_code>': '<your_language_name>' }
Replace
<your_language_iso_code>
with the ISO code (e.g., 'fr' for French) and<your_language_name>
with the corresponding language name (e.g., 'French').
If you make changes to your translations or if the English source messages are updated, use the following command to update your translations:
pybabel update -i <your_translation_file> -d translations
Ensure to replace <your_translation_file>
with the updated source file if it has changed.
To share your translation with the Neutron community, consider submitting your translated file to the project maintainers.