feedback5 W5S: i18n phase 2, match texts the server sends — a 机变 card's and an effect entry's name and description, the draft's name, a reward offer's label and the result title are shown from the localized data when the server's Chinese text is the data record's own (data.lookupRaw + ui/lang.js sentText; names through tName), a text the server reworded (a multi-round 悬赏) stays as sent; Chinese output unchanged by construction (in Chinese the localized record is the raw one); test/i18n-server.test.js covers it
This commit is contained in:
1 parent
7697b4ff40
commit
0025ceac16
7 files changed
+111
-15
No files matched your search
@@ -152,6 +152,20 @@ export function LangToggle({ class: cls }) {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* A game text the server sent in Chinese — a 机变 card's or an effect's description, a draft's name, a result title —
|
||||
* in the current language: the localized record's text when the sent text is that record's own Chinese text
|
||||
* (data.lookupRaw / getRaw), else the sent text as it is (a line the server reworded stays Chinese). In Chinese this is
|
||||
* always the sent text. Names have a shorter way: tName() (every record name of the data is in the overlay's names).
|
||||
* @param {unknown} sent the server's text
|
||||
* @param {unknown} raw the record's Chinese text
|
||||
* @param {unknown} local the record's text in the current language
|
||||
*/
|
||||
export function sentText(sent, raw, local) {
|
||||
if (typeof sent !== 'string' || !sent) return sent;
|
||||
return typeof raw === 'string' && raw === sent && typeof local === 'string' && local ? local : sent;
|
||||
}
|
||||
|
||||
/**
|
||||
* The text of an m.ticker frame in the current language. A config.broadcasts line (`id` + `args`, server ≥ 0.2.0) is
|
||||
* rebuilt from the localized broadcast template — `{0}` is the player's name (never translated), other args are
|
||||
|
||||
Reference in new issue
Block a user