Translations

Overview

Trezor stores translated strings in .json files in core/translations directory - e.g. de.json.

When no foreign-language is present, the English version is used - en.json.

Translations files contain the translated strings and also all the special font characters as a link to .json files in fonts directory. Font files are not needed for english, which uses just default/built-in ASCII characters.

Generating blobs

To generate up-to-date blobs, use python core/translations/cli.py gen - they will appear in core/translations as translations-*.bin files. The files contain information about the specific hardware model, language and device version.

Uploading blobs

To upload blobs with foreign-language translations, use trezorctl set language <blob_location> command.

To switch the language back into english, use trezorctl set language -r.

Translations blob format

offsetlengthnamedescriptionhash
0x00006magicblob magic TRTR00
0x00062container_lentotal length (up to padding)
0x00082header_lenheader length
0x000A2header_magicheader magic TR
0x000C8language_tagBCP 47 language tag (e.g. cs-CZ, en-US, ...)header
0x00144version4 bytes of version (major, minor, patch, build)header
0x00182data_lenlength of the raw data, i.e. translations + fontsheader
0x001A32data_hashSHA-256 hash of the dataheader
0x003Aheader_len - 48ignoredreserved for forward compatibilityheader
?2proof_lenlength of merkle proof and signature in bytes
?1proof_countnumber of merkle proof items following
?proof_count * 20proofarray of SHA-256 hashes
?1sig_maskCoSi signature mask
?64siged25519 CoSi signature of merkle root
?2translations_lenlength of the translated stringsdata
?translations_lentranslationstranslated string datadata
?2fonts_lenlength of the font datadata
?fonts_lenfontsfont datadata
??padding0xff bytes padding to flash sector boundary

Translation data

Offsets refer to the strings field, up to the following offset. First offset is always 0, following offset must always be equal or greater (equal denotes empty string).

offsetlengthnamedescription
0x00002countnumber of offsets, excluding the sentinel
0x00022offset[0]offset of string id 0 in the strings field
...2...
?2offset[count - 1]offset of string id count - 1 in the strings field
?2offset[count]offset past the last element
?translations_len - 2 * (count + 2)stringsconcatenation of UTF-8 strings

Fonts

Ids must be in increasing order, offsets must be in non-decreasing order. First offset must be 0.

offsetlengthnamedescription
0x00002countnumber of items in the offset table, excluding the sentinel
0x00022id[0]numeric id of the first font
0x00042offset[0]offset of the first font in the fonts field
.........
??id[count - 1]numeric id of the last font
??offset[count - 1]offset of the last font in the fonts field
??sentinel_idsentinel 0xffff
??sentinel_offsetoffset past the end of last element
?fontsconcatenation of fonts, format defined in the next section
?0-3paddingpadding (any value) for alignment purposes

Font data

The format is exactly the same as the previous table, the only difference is the interpretation of the payload.

offsetlengthnamedescription
0x00002countnumber of items in the offset table, excluding the sentinel
0x00022id[0]id (Unicode code point) of the first glyph
0x00042offset[0]offset of the first glyph in the glyphs field
.........
??id[count - 1]id (Unicode code point) of the last glyph
??offset[count - 1]offset of the last glyph in the glyphs field
??sentinel_idsentinel 0xffff
??sentinel_offsetoffset past the end of last element
?glyphsconcatenation of glyph bitmaps
?0-3paddingpadding (any value) for alignment purposes