Expand description
Message language. Messages are written in English; a Japanese translation is shown when the language is Japanese.
- Language:
set_lang(the GUI setting), otherwiseLENSBENCH_LANG(ja・en), otherwise the OS language (Japanese if it starts withja, English otherwise). - Translation: a table (the computing crates’ one is
lang/ja.tsvof thelensbench-langcrate, which the entry points add withadd_tableat start-up; it is kept out of this crate so that adding a line does not rebuild every crate that depends on the core) holdsEnglish template<TAB>Japanese template. A{...}in the English template matches any text, and the same{...}in the Japanese template is replaced by that text (identical tokens such as{}are taken in order). Only the text slots{e}(a nested message),{why}・{hint}(an added note) and{what}(a label) are translated again; other slot values (names, numbers, file names) are kept as they are. Only{e}and{why}may hold": ". When several lines match, the one with the most literal text wins. A message that is not in the table is split at": "and each part is translated (the context added bycrate::Error::at); text with no match stays as is. - New messages: write them in English and add the Japanese line to
lensbench-lang/lang/ja.tsv. Crates outside this repository’s public part keep their own table and add it withadd_table.
Enums§
- Lang
- Message language
Functions§
- add_
table - Add a table of the same format as
lensbench-lang/lang/ja.tsv(the entry points add that table, and an exe that adds plugins adds the Japanese of their messages, at start-up; the text is read when it is first needed). Check it withcheck_tablein a test - check_
table - Check a table: each line has a tab, the same
{…}in English and Japanese, unnamed{}in the same order, no two slots side by side, and no English twice. The errors name the line - is_ja
- Whether messages are shown in Japanese
- lang
- The current message language
- set_
lang - Choose the message language (the GUI calls this when its language changes)
- tr
- The message in the current language (English as written, Japanese from the table)
- tr_doc
translate_docin the current language- tr_item
translate_itemin the current language- translate
- The Japanese of an English message (the whole message, otherwise each
": "-separated part, otherwise, when every sentence has a line, each sentence: a note of several sentences joined by". "becomes sentences joined by “。”) - translate_
doc - Japanese of a description of several lines (help, analysis settings): each line from its own table line
(a trailing
[unit]is kept as it is); lines with no line of their own stay English - translate_
item - The Japanese of a name from an
# itemssection of the table (a tolerance item such asL1 group decenter x); other text stays as it is - warning
- A warning line for the terminal: “warning: …” in English, “注意: …” (translated) in Japanese