From 2778e802b23c29b826998f6159782cc9700cd319 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Wed, 21 Aug 2019 01:58:59 +0200 Subject: [PATCH 1/2] Modified few things in the workflow and more --- lang/translations.md | 64 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/lang/translations.md b/lang/translations.md index c32b4d8fb..6c787787c 100644 --- a/lang/translations.md +++ b/lang/translations.md @@ -2,10 +2,43 @@ ## Workflow -- Build firmware using build.sh. That creates necessary files in the `lang` dir. -- add messages that are new: investigate not-tran.txt, copy selected strings into `lang_add.txt` and run lang-add.sh -- export PO files for translation: `lang-export.sh` -- when translators finish their work use `lang-import.sh` +- Build firmware + - using `build.sh` + - using `PF-build.sh` with a `break` before `# build languages` +- change to `lang` folder +- check if lang scripts being able to run with `config.sh` + - if you get `Arduino main folder: NG` message change in `config.sh` `export ARDUINO=C:/arduino-1.8.5` to `export ARDUINO=` + -example: `export ARDUINO=D:/Github/Prusa-Firmware/PF-build-env-1.0.6/windows-64` +- run `lang-build.sh en` to create english `lang_en.tmp`, `lang_en.dat` and `lang_en.bin` files +- change in `fw-build.sh` `IGNORE_MISSING_TEXT=1` to `IGNORE_MISSING_TEXT=0` so it stops with error and generates `not_used.txt` and `not_tran.txt` +- run modified `fw-build.sh` + - `not_tran.txt` should be reviewed and added as these are potential missing translations + - copy `not_tran.txt` as `lang_add.txt` + - check if there are things you don't want to translate or must be modifed + - als check that the strings do not start with `spaces` as the scripts doesn't handle these well at this moment. + - run `lang-add.sh lang_add.txt` to add the missing translations to `lang_en.txt` and `lang_en_??.txt` + - `not_used.txt` should only contain mesages that aren't used in this variant like MK2.5 vs MK3 +- run `fw-clean.sh` to cleanup firmware related files +- delete `not_used.txt` and `not_tran.txt` +- run `lang-clean.sh` to cleanup language related files +- run `lang-export.sh all` to create PO files for translation these are stored in `/lang/po` folder + - Send them to translators and reviewers or + - copy these to `/lang/po/new` and + - translate these with POEdit the newly added messages + - easiest way is to choose `Validate`in POEdit as it shows you `errors` and the `missing transalations` / most likely the newly added at the top. +- The new translated files are expected in `/lang/po/new` folder so store the received files these +- run `lang-import.sh ` for each newly translated language + - script improvement to import "all" and other things would be great. +- Double check if something is missing or faulty + - run `lang-build.sh` to to create `lang_en.tmp/.dat/.bin` and `lang_en_??.tmp/.dat/.bin` files + - run `fw-build.sh` and check if there are still some messages in `not_tran.txt` that need attention +- After approval + - run `fw-clean.sh` to cleanup firmware related files + - run `lang-clean.sh` to cleanup language related files + - change in `fw-build.sh` back to `IGNORE_MISSING_TEXT=1` + - remove `break` from `PF-build.sh` script if that has been modified + - build your firmware with `build.sh`, `PF-build.sh` or how you normally do it. + - Check/Test firmware on printer ## Code / usage There are 2 modes of operation. If `LANG_MODE==0`, only one language is being used (the default compilation approach from plain Arduino IDE). @@ -65,7 +98,8 @@ const char* lang_get_translation(const char* s){ A simple list of strings that are not translated yet. ### `not_used.txt` -A list os strings not currently used in the firmware. May be removed from `lang_en_*.txt` files by hand. +A list os strings not currently used in this variant of the firmware or are obsolete. +Example: There are MK2.5 specific messages that aren't used when you compile a MK3 variant and vice versa. So be carefull and double check the code if this message is obsolete or just not used due to the chosen variant. ## Scripts @@ -138,7 +172,25 @@ Removes all language output files from lang folder. That means deleting: Exports PO (gettext) for external translators. ### `lang-import.sh` -Import from PO +Import from PO. + +Arguments: +- `$1` : language code (`en`, `cz`, `de`, `es`, `fr`, `it`, `pl`) +- empty/no arguments quits the script + +Input files: `.po` files like `de.po`, `es.po`, etc. + +Input folder: ´/lang/po/new´ + +Output files: + +Output foler: ´/lang/po/new´ + +Needed improments to scrpit: + - add `all` argument + - update `replace in translations` to all known special characters the LCD display with Japanese ROM cannot display + - move `lang_en_.txt` to folder `/lang` + - cleanup `_filtered.po`, `_new.po` and `nonasci.txt` ### `progmem.sh` From 2d4535af1f78b57cce638dcad618de85048039b2 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Wed, 21 Aug 2019 08:39:48 +0200 Subject: [PATCH 2/2] Added "All" argument and it is default in nothing is chosen The script had to started for each language code translation. Adding the "All" argument and make it as default if nothing is chosen makes the workflow easier. --- lang/lang-import.sh | 62 +++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/lang/lang-import.sh b/lang/lang-import.sh index 6176e053f..b7d4b1572 100755 --- a/lang/lang-import.sh +++ b/lang/lang-import.sh @@ -4,7 +4,19 @@ # for importing translated xx.po LNG=$1 -if [ -z "$LNG" ]; then exit -1; fi +# if no arguments, 'all' is selected (all po and also pot will be generated) +if [ -z "$LNG" ]; then LNG=all; fi + +# if 'all' is selected, script will generate all po files and also pot file +if [ "$LNG" = "all" ]; then + ./lang-import.sh cz + ./lang-import.sh de + ./lang-import.sh es + ./lang-import.sh fr + ./lang-import.sh it + ./lang-import.sh pl + exit 0 +fi # language code (iso639-1) is equal to LNG LNGISO=$LNG @@ -28,43 +40,43 @@ sed -i 's/ \\n/ /g;s/\\n/ /g' $LNG'_filtered.po' #replace in czech translation if [ "$LNG" = "cz" ]; then - #replace 'ž' with 'z' + #replace 'ž' with 'z' sed -i 's/\xc5\xbe/z/g' $LNG'_filtered.po' - #replace 'ì' with 'e' + #replace 'ì' with 'e' sed -i 's/\xc4\x9b/e/g' $LNG'_filtered.po' - #replace 'í' with 'i' + #replace 'í' with 'i' sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po' - #replace 'ø' with 'r' + #replace 'ø' with 'r' sed -i 's/\xc5\x99/r/g' $LNG'_filtered.po' - #replace 'è' with 'c' + #replace 'è' with 'c' sed -i 's/\xc4\x8d/c/g' $LNG'_filtered.po' - #replace 'á' with 'a' + #replace 'á' with 'a' sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po' - #replace 'é' with 'e' + #replace 'é' with 'e' sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po' fi #replace in german translation if [ "$LNG" = "de" ]; then - #replace 'ä' with 'ae' + #replace 'ä' with 'ae' sed -i 's/\xc3\xa4/ae/g' $LNG'_filtered.po' - #replace 'ü' with 'ue' + #replace 'ü' with 'ue' sed -i 's/\xc3\xbc/ue/g' $LNG'_filtered.po' - #replace 'ö' with 'oe' + #replace 'ö' with 'oe' sed -i 's/\xc3\xb6/oe/g' $LNG'_filtered.po' fi #replace in spain translation if [ "$LNG" = "es" ]; then - #replace 'á' with 'a' + #replace 'á' with 'a' sed -i 's/\xc3\xa1/a/g' $LNG'_filtered.po' #replace '?' with '?' sed -i 's/\xc2\xbf/?/g' $LNG'_filtered.po' - #replace 'ó' with 'o' + #replace 'ó' with 'o' sed -i 's/\xc3\xb3/o/g' $LNG'_filtered.po' - #replace 'é' with 'e' + #replace 'é' with 'e' sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po' - #replace 'í' with 'i' + #replace 'í' with 'i' sed -i 's/\xc3\xad/i/g' $LNG'_filtered.po' #replace '!' with '!' sed -i 's/\xc2\xa1/!/g' $LNG'_filtered.po' @@ -74,29 +86,29 @@ fi #replace in french translation if [ "$LNG" = "fr" ]; then - #replace 'é' with 'e' + #replace 'é' with 'e' sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po' - #replace 'É' with 'E' + #replace 'É' with 'E' sed -i 's/\xc3\x89/E/g' $LNG'_filtered.po' - #replace 'é' with 'e' (left) + #replace 'é' with 'e' (left) sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po' - #replace 'á' with 'a' (left) + #replace 'á' with 'a' (left) sed -i 's/\xc3\xa0/a/g' $LNG'_filtered.po' fi #replace in italian translation if [ "$LNG" = "it" ]; then - #replace 'é' with 'e' (left) + #replace 'é' with 'e' (left) sed -i 's/\xc3\xa8/e/g' $LNG'_filtered.po' - #replace 'á' with 'a' (left) + #replace 'á' with 'a' (left) sed -i 's/\xc3\xa0/a/g' $LNG'_filtered.po' - #replace 'ó' with 'o' (left) + #replace 'ó' with 'o' (left) sed -i 's/\xc3\xb2/o/g' $LNG'_filtered.po' - #replace 'ú' with 'u' (left) + #replace 'ú' with 'u' (left) sed -i 's/\xc3\xb9/u/g' $LNG'_filtered.po' - #replace 'é' with 'e' + #replace 'é' with 'e' sed -i 's/\xc3\xa9/e/g' $LNG'_filtered.po' - #replace 'É' with 'E' (left) + #replace 'É' with 'E' (left) sed -i 's/\xc3\x88/E/g' $LNG'_filtered.po' fi