此提交完成了全项目的国际化适配: 1. 新增多语言翻译文件与基础配置 2. 替换所有硬编码文本为i18n调用 3. 优化语言切换与文档语言同步逻辑 4. 重构部分业务逻辑以支持动态翻译 5. 移除过时代码与硬编码配置
45 lines
971 B
TypeScript
45 lines
971 B
TypeScript
/** 玩法展示名(与种子 play_types 对齐;无映射时回退 play_code) */
|
||
const LABELS: Record<string, string> = {
|
||
big: "Big",
|
||
small: "Small",
|
||
pos_4a: "4A",
|
||
pos_4b: "4B",
|
||
pos_4c: "4C",
|
||
pos_4d: "4D",
|
||
pos_4e: "4E",
|
||
pos_3a: "3A",
|
||
pos_3b: "3B",
|
||
pos_3c: "3C",
|
||
pos_3abc: "3ABC",
|
||
pos_2a: "2A",
|
||
pos_2b: "2B",
|
||
pos_2c: "2C",
|
||
pos_2abc: "2ABC",
|
||
straight: "Straight",
|
||
box: "Box",
|
||
ibox: "iBox",
|
||
mbox: "mBox",
|
||
roll: "Roll",
|
||
half_box: "Half Box",
|
||
head: "Head",
|
||
tail: "Tail",
|
||
odd: "Odd",
|
||
even: "Even",
|
||
digit_big: "Big Digit",
|
||
digit_small: "Small Digit",
|
||
};
|
||
|
||
export function playLabelZh(playCode: string): string {
|
||
return LABELS[playCode] ?? playCode;
|
||
}
|
||
|
||
export function playLabel(
|
||
playCode: string,
|
||
t?: (key: string, options?: { defaultValue?: string }) => string,
|
||
): string {
|
||
if (!t) {
|
||
return playLabelZh(playCode);
|
||
}
|
||
return t(`playLabels.${playCode}`, { defaultValue: LABELS[playCode] ?? playCode });
|
||
}
|