feat(i18n): add language select into appearance tab

This commit is contained in:
JiPai
2024-11-08 02:16:15 +08:00
parent 0ca8ee17be
commit 7f0a92f224
11 changed files with 124 additions and 24 deletions

View File

@@ -0,0 +1,21 @@
import Cookies from "js-cookie";
const SUPPORTED_LOCALES = ["en", "zh-Hans"] as const;
type Locale = (typeof SUPPORTED_LOCALES)[number];
type PossibleLocale = (typeof SUPPORTED_LOCALES)[number] | undefined | null;
export default function useLocale() {
const currentLocale = Cookies.get("DOKPLOY_LOCALE") as PossibleLocale;
console.log(currentLocale);
const setLocale = (locale: Locale) => {
Cookies.set("DOKPLOY_LOCALE", locale);
window.location.reload();
};
return {
locale: currentLocale,
setLocale,
};
}