20260721223033

This commit is contained in:
oneao committed 2026-07-21 22:30:33 +08:00
1 parent bab8e2972f
commit e9f099f044
26 files changed
+1687 -349

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
export const I18N_LOCALES = [
{ value: "zh-CN", label: "简体中文", shortLabel: "简体" },
{ value: "en-US", label: "English", shortLabel: "English" },
{ value: "zh-TW", label: "繁體中文", shortLabel: "繁體" },
];
export const I18N_LOCALE_CODES = I18N_LOCALES.map((item) => item.value);
export function getI18nNamespace(key) {
return String(key || "").split(".", 1)[0] || "common";
}
export function isValidI18nKey(key) {
return /^[A-Za-z][A-Za-z0-9_.:-]{1,149}$/.test(String(key || ""));
}
export function groupI18nRows(rows) {
const groups = {};
rows.forEach((item) => {
const key = item.b_key;
groups[key] ||= { key, values: {}, records: {} };
groups[key].values[item.b_locale] = item.b_value;
groups[key].records[item.b_locale] = item;
});
return groups;
}