Commit Graph

186 Commits

Author SHA1 Message Date
Yuri D'Elia 0d7680dbf7
New PO-based language translation support (#3471)
* lang: Add a PO language extractor with FW metadata support

Implement a straight-to-po language extractor which supports our custom
language requirements:

- _i/_I/ISTR for text string definitions
- _T for catalog translations (with back-reference support)
- //// EOL comments with:
  - MSG_ catalog entry name identifiers
  - c=X r=Y annotations for screen dimensioning checks
- Crude support for commented lines

All source locations are correctly referenced in the PO, with the
metadata colleted in the comment for further processing.

Several checks are implemented already during extraction:

- Correct catalog name assignment (no duplicates)
- Metadata checks for each entry

Further checks will be implemented by directly checking the translated PO file.

Requires "polib" and "regex" python modules.

* lang: Adapt lang-check to work directly on PO/POT files

* lang: Allow lang-extract to generate stable (pre-sorted) output directly

* lang: Further extend lang-extract consistency/error checking

- Do not parse inside preprocessor conditionals
- Distinguish between references and definitions
- Warn about missing references and definitions

* lang: lang-extract: warn about incorrect PROGMEM assignments

Check that ISTR is used along with PROGMEM_I1 in an attempt to spot
useless translated catalogs.

* lang: lang-extract: Improved handling of same-line translations

Correctly reference metadata on same-line translations.

* lang: lang-extract: Handle _O as a cat-ref

https://github.com/prusa3d/Prusa-Firmware/pull/3434

* lang: lang-extract: Warn about unused catalog definitions

* lang: lang-extract: Allow propagating translation comments via //

The definition:

    code //// definition [// comment]

will check [definition] as before, but blindly accumulate // comment.
The comment is then re-appended back into the PO files for translators
with the form:

    definition
    comment
    comment...

* lang: Fix incorrect display definitions

* lang: lang-extract: Check source encoding/charmap

* lang: Translate the degree symbol

* lang: Unbreak/cleanup DEBUG_SEC_LANG

* lang: Improve meaning of comment

* lang: Split charset conversions into an aux lib for future use

* lang: Implement lang-map.py to extract the translation symbol map

- Extracts the translatable symbol map for further use
- Computes a stable "language signature" from the map itself
- Optionally patches the binary update the symbols

* lang: Check for translation recoding problems

* lang: Implement a transliteration map to post-process translations

TRANS_CHARS is now used to replace unavailable symbols to the source
encoding, only while producing the language catalog.

* lang: Handle/check character replacements in lang-check

Filter the translation through TRANS_CHARS, so that the preview and
length check are performed correctly for expanding replacements such as
'ß' to 'ss'.

* lang: Implement lang-build.py to generate the final language catalog

* Cleanup .gitignore

* lang: Drop txt language files

* lang: Remove outdated translation scripts and obsolete docs

* lang: Update build scripts for new infrastructure

* lang: [no] Integrate accents from po/new/no.po

We now support accents natively

* lang: Remove redundant directory po/new/

* lang: Fix encoding of LCD characters in PO files

* lang: [hr] Fix wrapping in MSG_CRASH_DET_ONLY_IN_NORMAL

* lang: Sort and reformat PO files for further massaging

* lang: Switch to developer (dot) comments for PO metadata

* lang: Allow the IGNORE annotation to skip extraction

* lang: Fix missing/broken language metadata in sources

* lang: Add update-pot.sh and regenerate po/Firmware.pot

* lang: Add update-po.sh and refresh all PO files

* lang: Add summary documentation about the new translation workflow

* Add more ignored files

* CI: Add new required dependencies to travis

* lang: lang-build: Improve warning message

"referenced" was really meaning that data is being duplicated.

* lang: Respect the language order as defined in config.sh

This correctly splits normal and community-made entries during language
selection.

* lang: More typos in the documentation

* lang: Check for the maximum size of each language

Each table needs to fit within LANG_SIZE_RESERVED

* lang: Properly align _SEC_LANG to page boundaries

... instead of relying on _SEC_LANG_TABLE to calculate the offset

* lang: Build support for dual-language hex files

Detect the printer type by checking the current variant type.

On printers with no xflash (MK2*), generate one hex file for each
additional language file by patching the built-in secondary language
table during the build process

* lang: Mention lang-patchsec.py

* lang: Use color() instead of tput for clarity

* lang: Allow disabling terminal colors with NO_COLOR/TERM=dumb

* lang: Consistent use of redirection in config.sh

* lang: Stricter variant-type check for xflash support

* lang: Output size stats when building double-language hex files

* lang: Respect NO_COLOR in lang-check.py

* lang: Check for repeated/incorrect annotations

Catch errors such as "c=1 c=2"

* lang: Correct MSG_SLIGHT_SKEW/MSG_SEVERE_SKEW annotations

* lang: [it] Improve MSG_*_SKEW translation

* lang: Use INTLHEX instead of OUTHEX_P/S for configuration

We already have OUTHEX which is the compiled firmware.

Use INTLHEX for the final internationalized firmware, which is less
confusing. Also, assume it being a prefix for all generated hex
files, which reduces the number of variables set.

* lang: Move lang_map to lib.io for further use

* lang: lang-check: Accept a firmware map file to suppress unused string warnings

* lang: Use the map file to reduce useless warnings during fw-build

* lang: lang-check: Also suppress unused empty annotations

* lang: Fix MSG_MOVE_CARRIAGE_TO_THE_TOP_Z annotation

Refresh pot file

* lang: lang-check: Do not warn about same-word translations by default

Do not warn when one-word translations such as "No" result in "No" also
in other languages, since this is common in latin languages.

Allow to re-enable the warning with --warn-same

* lang: lang-build: Handle same-source/translation efficiently

* lang: [it] Explicitly add On/Off/Reset/Wizard to suppress warnings

Instead of displaying a warning, supress the warning and explicitly
translate each entry using english (which is the common/acceptable
word in these cases).

* lang: [it] Suppress more warnings

* lang: lang-check: Add intermediate "suggest" warning category

Warnings in the "suggest" category as shown as [S] as based on pure
speculation from the checking tool, such as the translation being
significantly shorter than the original.

As a result, they can be suppressed with --no-suggest

* lang: Return translation status from lang-check

- 0 if the translation only contains suggestions
- 1 if the translation contains warnings or errors

Check for the exit status in fw-build.sh, but do nothing at the moment
except printing a non-fatal error.

* lang: Remove "trim_trailing_whitespace=false" for po files

PO files got cleaned up/rewritten. We can now ensure they stay
consistent.

* lang: [sv] Re-integrate changes from 70c73cb

* lang: [no] Reintegrate changes from @pkg2000
2022-06-16 15:03:30 +02:00
3d-gussner 85a5986e9e Update `////MSG...` for `lang-add.sh` 2022-03-16 09:01:14 +01:00
3d-gussner 626e5b43eb Fix part 2 of `\04Refresh` and `Sheet...` 2022-03-11 15:37:57 +01:00
3d-gussner 45cd904520 Remove duplicate `Extruder fan:`
Create MSG in messages to reuse it
Remove `Nozzle FAN`
Change Support -> Extruder info -> fan speeds
2022-03-07 11:47:53 +01:00
3d-gussner bcd2b6f8bf Remove `Choose filament` as it is a duplicate of `Select filament` 2022-03-07 11:47:53 +01:00
3d-gussner 879803daa9 Temp. cal. -> PINDA cal.
01234567890123456789
 Temp. cal.   [Off] old
 PINDA cal.   [Off] new

Temp. cal.  1/6     old
PINDA cal.    1/6   new

MSG_TEMP_CALIBRATION -> MSG_PINDA_CALIBRATION
MSG_TEMP_CALIBRATION_DONE -> MSG_PINDA_CALIBRATION_DONE

Updated text
- MSG_PINDA_CALIBRATION_DONE
- MSG_PINDA_CAL_FAILED

Update status line during PINDA cal.

Changed PINDA cal. from submenu to function
- Deleted `lcd_pinda_calibration_menu()`
- Deleted `#MSG_CALIBRATE_PINDA c=17`

Tried to update translations

Updated po files
2022-03-07 11:47:52 +01:00
3d-gussner 7939142922 Change `Choose extruder` to `Select extruder` for consistant wording 2022-03-07 11:47:52 +01:00
3d-gussner 81d8c72cc4 Remove duplicate `Extruder fan:`
Create MSG in messages to reuse it
Remove `Nozzle FAN`
Change Support -> Extruder info -> fan speeds
2022-03-07 11:47:52 +01:00
3d-gussner 4a73cad3fd Remove `Choose filament` as it is a duplicate of `Select filament` 2022-03-07 11:47:52 +01:00
3d-gussner 881db2e747 Change `MSG_YES` to max. 4 chars
Hungarian YES is 4 letters long
2022-02-08 08:50:24 +01:00
3d-gussner e7d7068840 Change `MSG_WIZARD_DONE` rows to 3 2022-02-08 08:46:07 +01:00
Alex Voinea 93b1a6b736 "Unload filament" c adjustment 2022-01-16 11:19:24 +01:00
Yuri D'Elia d04ea859fb Consolidate "Unknown X-Code" to save 16 bytes 2021-07-20 08:19:19 +02:00
3d-gussner a9ae8ea731 Remove `SpoolJoin` from translations 2021-04-29 08:15:24 +02:00
3d-gussner 488d9d4b38 Remove "Firmware" from translations
deleted another unused "Firmware" define in language.h
2021-04-28 18:02:36 +02:00
3d-gussner d251f3980a Remove FlashAir from translations 2021-04-28 17:57:39 +02:00
3d-gussner 08566d4121 Remove PINDA from translations 2021-04-28 17:33:52 +02:00
3d-gussner 7a54c3638c Remove web links and `Prusa i3 MKxy OK.` from translations
as these never have been translated or doesn't make sense
to translate web links
2021-04-27 20:36:22 +02:00
3d-gussner 686054b95e Changed `x of 4` and `y of 9` to `x/4` and `y/4`
Added `Iteration` translation
2021-04-27 20:22:28 +02:00
3d-gussner 738a24178a Update #MSG_FIND_BED_OFFSET_AND_SKEW_LINE1 c=20 r=3 2021-04-27 07:45:36 +02:00
3d-gussner b8ae08fd3d Update `x of 4` and `x of 9` messages so longer text can be used. 2021-04-27 07:18:52 +02:00
3d-gussner 466de83ae0 Remove white spaces in messags which saves ~62bytes 2021-04-26 07:22:22 +02:00
3d-gussner c2cde83d7e Fix MSG_SELFTEST_WIRINGERROR to c=18 2021-04-23 13:29:45 +02:00
3d-gussner 3f51627c02 Fix MSG_NO being too short, no need to be 2021-04-23 13:23:11 +02:00
3d-gussner 013708479f Fix MSG_UNLOAD_FILAMENT length as in MMU a number is added 2021-04-23 13:12:57 +02:00
3d-gussner 032e8a5957 @leptun strip 1st char hack for duplicate `Cancel` 2021-04-23 13:03:59 +02:00
3d-gussner 044c0a0a6a Update "\04Refresh" message as two "abcd" "efgh" in one line cause issues in lang-build scripts 2021-04-23 08:49:22 +02:00
3d-gussner 8e74cbce58 Remove r=1 and some minor fixes 2021-03-31 08:07:42 +02:00
3d-gussner 268d4020cf Define #MSG_FINDA c=5 and update #MSG_PINDA c=5 2021-03-31 07:32:43 +02:00
3d-gussner 1c09e8411d Define #MSG_PINDA c=6 and remove duplicate saved 8 bytes 2021-03-30 19:30:26 +02:00
3d-gussner 2abdfeb4c5 Update #MSG_YES c=3 2021-03-30 18:48:14 +02:00
3d-gussner 1e2dde9a52 Update #MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1 c=20 r=3 2021-03-30 18:02:27 +02:00
3d-gussner 62ecbb3ae3 Update #MSG_BABYSTEP_Z c=18 2021-03-30 17:57:50 +02:00
3d-gussner 50e69fcca8 Update #MSG_NO c=3 2021-03-30 17:53:58 +02:00
3d-gussner 75c0de741b Update #MSG_AUTO_DEPLETE c=13 2021-03-30 17:52:59 +02:00
3d-gussner ddf47a3cac Update #MSG_NA c=3, #MSG_OFF c=3, #MSG_ON c=3 2021-03-30 17:51:31 +02:00
3d-gussner d1813890a8 Update #MSG_STOPPED c=20 2021-03-30 17:49:02 +02:00
3d-gussner a9ed513979 Update #MSG_STOP_PRINT c=18 2021-03-30 17:48:06 +02:00
3d-gussner 46367c2a33 Update #MSG_STEALTH c=7, #MSG_SILENT c=7, #MSG_NORMAL c=7 2021-03-30 17:46:37 +02:00
3d-gussner 3d848328ed Update #MSG_AUTO_POWER c=10 2021-03-30 17:42:33 +02:00
3d-gussner 8771519880 Update #MSG_HIGH_POWER c=10 2021-03-30 17:41:51 +02:00
3d-gussner afabfa789d Update #MSG_MODE c=6 2021-03-30 17:41:09 +02:00
3d-gussner dc56b74263 Update #MSG_MODE c=9 2021-03-30 17:39:43 +02:00
3d-gussner 2a08a6e441 Update #MSG_SELFTEST_WIRINGERROR c=17 2021-03-30 17:37:50 +02:00
3d-gussner e6ea843e62 Update #MSG_SELFTEST_MOTOR c=18 2021-03-30 17:36:39 +02:00
3d-gussner 35b000faea Update MSG_RESUMING_PRINT c=20 2021-03-30 17:34:36 +02:00
3d-gussner 557486ee0b Update MSG_REFRESH c=18 2021-03-30 17:34:00 +02:00
3d-gussner 54f594238b Update #MSG_NOZZLE c=12 2021-03-30 17:33:15 +02:00
3d-gussner a878056be3 Update MSG_BACK c=18 2021-03-30 17:32:04 +02:00
3d-gussner 610ba9bc45 Update #MSG_CARD_MENU c=18 2021-03-30 17:31:18 +02:00