新增设备巡检模块核心功能,包括: - 巡检数据存储与调度系统 - 华为/H3C交换机及Linux服务器采集器 - 设备扩展配置与告警规则管理 - 主机详情页巡检配置入口 - 产品名称自定义设置功能 - 网络设备SSH exec通道兼容处理
31 lines
991 B
TypeScript
31 lines
991 B
TypeScript
export type LocaleOption = {
|
|
id: string;
|
|
label: string;
|
|
};
|
|
|
|
export const DEFAULT_UI_LOCALE = 'zh-CN';
|
|
|
|
// Add new languages by appending to this list and providing message dictionaries.
|
|
export const SUPPORTED_UI_LOCALES: LocaleOption[] = [
|
|
{ id: 'en', label: 'English' },
|
|
{ id: 'es', label: 'Español' },
|
|
{ id: 'ru', label: 'Русский' },
|
|
{ id: 'zh-CN', label: '简体中文' },
|
|
{ id: 'zh-TW', label: '繁體中文' },
|
|
];
|
|
|
|
const isSupportedLocale = (locale: string): boolean => {
|
|
return SUPPORTED_UI_LOCALES.some((l) => l.id === locale);
|
|
};
|
|
|
|
export const resolveSupportedLocale = (locale: string): string => {
|
|
if (isSupportedLocale(locale)) return locale;
|
|
const base = locale.split('-')[0] || locale;
|
|
const baseExact = SUPPORTED_UI_LOCALES.find((l) => l.id === base)?.id;
|
|
if (baseExact) return baseExact;
|
|
const basePrefix = SUPPORTED_UI_LOCALES.find((l) => l.id.startsWith(`${base}-`))?.id;
|
|
if (basePrefix) return basePrefix;
|
|
return DEFAULT_UI_LOCALE;
|
|
};
|
|
|