Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation of how to translate OSD in firmware #326

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions docs/development/TranslationOSD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Translation OSD

This documentaion are intended for developers of Betaflight firmware, who want to translate the language in OSD view.

Current en (English) and da (Danish) are covered, but be welcome to do more

The developer can work as usual, do programming and keep it there.
Developer OR translator can at another time replace text to be translated with preprocessor defines.

Notice: commands i ex cli.c are not subject to translation.

# Setup

The setup make preprocessor to replace defines by the translated text.
The preprocessor defines are made first of all, in English xml file src/main/locales/en/bf_locale.xml by add needed defines.
Add the string to be translated, example below, in bf_locale.xml and in C source code.
Source files that contain strings wanted to be translated, need to #include "locales/localisation.h" in C source file.
Also update define TRANSLATED_SRC in mk/source.mk to control make. Currently osd.c, osd_elements.c, osd_warnings.c and cli.c has translation items (but don't translate commands in cli.c).

Other preprocessor files are located below src/main/locales/xx, where xx are 2 capital letter country code found in [http://www.lingoes.net/en/translator/langcode.htm].
Until we have crowdin support, the developer have to translate own language by translate in xx/bf_locale.xml
Make a copy of en/bf_locale.xml, save in xx/bf_locale.xml and translate.

If you don't translate, compile will still work, due to at setup with autogenerated untranslated.h, basically all english strings, where all missing defines are handled for every language.

### To compile the target xx
Default locale are 'en', use: "make xx".
To compile for other languages, ex Danish, use: "make xx LOCALE=da"

## Support for HD video format

If you want to extend text when use HD video format, make the same section in bf_locale.xml immediately after first declaration and postfix define with _HD, like ex:
<string name="STR_OSD_ARMED" maxLength="10" comment="translation of: ARMED">ARMED</string>
<string name="STR_OSD_ARMED_HD" maxLength="20" comment="HD translation of: *** ARMED ***">*** ARMED ***</string>

PS. en/bf_locale.xml need to have the _HD section, when Crowdin come into use.

### To compile the target xx with use of HD video format
Default locale are 'en', use: "make xx USE_HD_EXTENDED=yes".
To compile for other languages, ex Danish, use: "make xx LOCALE=da USE_HD_EXTENDED=yes"

# Example

To make translation of tfp_sprintf(warningText, "RESCUE N/A"), you rewrite to tfp_sprintf(warningText, STR_OSDW_RESCUE_NA),
add to en/bf_locale.xml: <string name="STR_OSDW_RESCUE_NA" maxLength="15" comment="translation of: RESCUE N/A">RESCUE N/A</string>

If you also want support of HD video format,
add to en/bf_locale.xml: <string name="STR_OSDW_RESCUE_NA_HD" maxLength="20" comment="HD translation of: RESCUE NOT AVAILABLE">RESCUE NOT AVAILABLE</string>

Important ! Check buffers can handle the translated string, set maxLength to maximum buffer size or preferable below, to reduce size of frirmware image.

The preprossor generate:
#define STR_OSDW_RESCUE_NA TR2("RESCUE N/A", "RESCUE NOT AVAILABLE")

If USE_HD_EXTENDED are not defined: "RESCUE N/A" are used, if USE_HD_EXTENDED are defined: "RESCUE NOT AVAILABLE" are used.

If a translator make a string over maxLength, the compliation will give this error and halt:
ERROR - define STR_OSDW_RESCUE_NA with maxLength of 15 exceed with text: RESCUE longandlong / 19
10 changes: 9 additions & 1 deletion docs/development/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,20 @@ GitHub actions are used to run automatic builds

## Translators

We want to make Betaflight accessible for pilots who are not fluent in English, and for this reason we are currently maintaining translations into 21 languages for Betaflight Configurator: Català, Dansk, Deutsch, Español, Euskera, Français, Galego, Hrvatski, Bahasa Indonesia, Italiano, 日本語, 한국어, Latviešu, Português, Português Brasileiro, polski, Русский язык, Svenska, 简体中文, 繁體中文.
### Betaflight Configurator
We want to make Betaflight accessible for pilots who are not fluent in English, and for this reason we are currently maintaining translations into 21 languages for Betaflight Configurator: Català, Dansk, Deutsch, Español, Euskera, Français, Galego, Hrvatski, Bahasa Indonesia, Italiano, 日本語, 한국어, Netherlands, Português, Português Brasileiro, Polski, Русский, Svenska, українська, 简体中文, 繁體中文.
We have got a team of volunteer translators who do this work, but additional translators are always welcome to share the workload, and we are keen to add additional languages. If you would like to help us with translations, you have got the following options:

- If you would like to help by suggesting some updates or improvements to translations in a language you are familiar with, head to [crowdin](https://crowdin.com/project/betaflight-configurator) and add your suggested translations there
- If you would like to start working on the translation for a new language, or take on responsibility for proof-reading the translation for a language you are very familiar with, please head over to the Betaflight [Discord server](https://discord.betaflight.com/invite), and join the translation channel in the [Development section](https://discord.com/channels/868013470023548938/1073533061330915328) - the people in there can help you to get a new language added, or set you up as a proof reader

### Betaflight firmware / OSD
We also have translation of OSD in Betaflight firmware, currently 1 languages: Dansk, but more to come.
This are current under develompent, checkout the section Translation OSD, how to do.
Intention are to have support with crowdin, ie. betaflight-firmware.

For developers checkout [Translation OSD] (??? howto make link reference)

## General Principles

1. Name everything well.
Expand Down
Loading