mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(i18n): add language select into appearance tab
This commit is contained in:
21
apps/dokploy/utils/hooks/use-locale.ts
Normal file
21
apps/dokploy/utils/hooks/use-locale.ts
Normal 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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user