mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-21 12:34:29 +00:00
31 lines
506 B
TypeScript
31 lines
506 B
TypeScript
import Cookies from "js-cookie";
|
|
|
|
const SUPPORTED_LOCALES = [
|
|
"en",
|
|
"pl",
|
|
"ru",
|
|
"fr",
|
|
"de",
|
|
"tr",
|
|
"zh-Hant",
|
|
"zh-Hans",
|
|
"fa",
|
|
"ko",
|
|
] as const;
|
|
|
|
type Locale = (typeof SUPPORTED_LOCALES)[number];
|
|
|
|
export default function useLocale() {
|
|
const currentLocale = (Cookies.get("DOKPLOY_LOCALE") ?? "en") as Locale;
|
|
|
|
const setLocale = (locale: Locale) => {
|
|
Cookies.set("DOKPLOY_LOCALE", locale, { expires: 365 });
|
|
window.location.reload();
|
|
};
|
|
|
|
return {
|
|
locale: currentLocale,
|
|
setLocale,
|
|
};
|
|
}
|