-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation of how to translate firmware
- Loading branch information
Showing
2 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -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 |
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