mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-18 10:40:50 +08:00
fix: address language review feedback
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import type { Language } from '@/types';
|
||||
import { STORAGE_KEY_LANGUAGE } from '@/utils/constants';
|
||||
import { STORAGE_KEY_LANGUAGE, SUPPORTED_LANGUAGES } from '@/utils/constants';
|
||||
|
||||
const parseStoredLanguage = (value: string): Language | null => {
|
||||
try {
|
||||
const parsed = JSON.parse(value);
|
||||
const candidate = parsed?.state?.language ?? parsed?.language ?? parsed;
|
||||
if (candidate === 'zh-CN' || candidate === 'en' || candidate === 'ru') {
|
||||
return candidate;
|
||||
if (SUPPORTED_LANGUAGES.includes(candidate as Language)) {
|
||||
return candidate as Language;
|
||||
}
|
||||
} catch {
|
||||
if (value === 'zh-CN' || value === 'en' || value === 'ru') {
|
||||
return value;
|
||||
if (SUPPORTED_LANGUAGES.includes(value as Language)) {
|
||||
return value as Language;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user