From 5172d50e25a2b9ea5b991a9259b69f64a262b08f Mon Sep 17 00:00:00 2001 From: HThuren Date: Mon, 8 Jan 2024 02:04:35 +0100 Subject: [PATCH] Documentation of how to translate firmware --- docs/development/TranslationOSD.md | 58 ++++++++++++++++++++++++++++++ docs/development/development.md | 10 +++++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100755 docs/development/TranslationOSD.md diff --git a/docs/development/TranslationOSD.md b/docs/development/TranslationOSD.md new file mode 100755 index 0000000000..31a6723e4d --- /dev/null +++ b/docs/development/TranslationOSD.md @@ -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: + ARMED + *** ARMED *** + +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: RESCUE N/A + +If you also want support of HD video format, +add to en/bf_locale.xml: RESCUE NOT AVAILABLE + +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 diff --git a/docs/development/development.md b/docs/development/development.md index e3f8909c97..9a39b1d90d 100644 --- a/docs/development/development.md +++ b/docs/development/development.md @@ -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.