forked from baron/baron-sso
adminfront 상단 화면 i18n 정리
This commit is contained in:
32
adminfront/src/lib/locale.ts
Normal file
32
adminfront/src/lib/locale.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { DEFAULT_LOCALE, LOCALE_STORAGE_KEY, type Locale } from "../../../common/core/i18n";
|
||||
|
||||
function isLocale(value: string): value is Locale {
|
||||
return value === "ko" || value === "en";
|
||||
}
|
||||
|
||||
export function getAdminLocale(): Locale {
|
||||
if (typeof window === "undefined") {
|
||||
return DEFAULT_LOCALE;
|
||||
}
|
||||
|
||||
const stored = window.localStorage.getItem(LOCALE_STORAGE_KEY);
|
||||
if (stored && isLocale(stored)) {
|
||||
return stored;
|
||||
}
|
||||
|
||||
const pathLocale = window.location.pathname.split("/")[1];
|
||||
if (pathLocale && isLocale(pathLocale)) {
|
||||
return pathLocale;
|
||||
}
|
||||
|
||||
const browserLang = window.navigator.language.toLowerCase();
|
||||
if (browserLang.startsWith("ko")) {
|
||||
return "ko";
|
||||
}
|
||||
|
||||
return DEFAULT_LOCALE;
|
||||
}
|
||||
|
||||
export function getAdminDateLocale() {
|
||||
return getAdminLocale() === "ko" ? "ko-KR" : "en-US";
|
||||
}
|
||||
Reference in New Issue
Block a user