mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat(i18n): replace translation in Appearance
This commit is contained in:
@@ -63,7 +63,7 @@ export function AppearanceForm() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
form.reset({
|
form.reset({
|
||||||
theme: (theme ?? "system") as AppearanceFormValues["theme"],
|
theme: (theme ?? "system") as AppearanceFormValues["theme"],
|
||||||
language: locale ?? "en",
|
language: locale,
|
||||||
});
|
});
|
||||||
}, [form, theme, locale]);
|
}, [form, theme, locale]);
|
||||||
function onSubmit(data: AppearanceFormValues) {
|
function onSubmit(data: AppearanceFormValues) {
|
||||||
@@ -92,9 +92,9 @@ export function AppearanceForm() {
|
|||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
return (
|
return (
|
||||||
<FormItem className="space-y-1 ">
|
<FormItem className="space-y-1 ">
|
||||||
<FormLabel>Theme</FormLabel>
|
<FormLabel>{t("settings.appearance.theme")}</FormLabel>
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
Select a theme for your dashboard
|
{t("settings.appearance.themeDescription")}
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
@@ -112,7 +112,7 @@ export function AppearanceForm() {
|
|||||||
<img src="/images/theme-light.svg" alt="light" />
|
<img src="/images/theme-light.svg" alt="light" />
|
||||||
</div>
|
</div>
|
||||||
<span className="block w-full p-2 text-center font-normal">
|
<span className="block w-full p-2 text-center font-normal">
|
||||||
Light
|
{t("settings.appearance.themes.light")}
|
||||||
</span>
|
</span>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -125,7 +125,7 @@ export function AppearanceForm() {
|
|||||||
<img src="/images/theme-dark.svg" alt="dark" />
|
<img src="/images/theme-dark.svg" alt="dark" />
|
||||||
</div>
|
</div>
|
||||||
<span className="block w-full p-2 text-center font-normal">
|
<span className="block w-full p-2 text-center font-normal">
|
||||||
Dark
|
{t("settings.appearance.themes.dark")}
|
||||||
</span>
|
</span>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -141,7 +141,7 @@ export function AppearanceForm() {
|
|||||||
<img src="/images/theme-system.svg" alt="system" />
|
<img src="/images/theme-system.svg" alt="system" />
|
||||||
</div>
|
</div>
|
||||||
<span className="block w-full p-2 text-center font-normal">
|
<span className="block w-full p-2 text-center font-normal">
|
||||||
System
|
{t("settings.appearance.themes.system")}
|
||||||
</span>
|
</span>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -158,9 +158,9 @@ export function AppearanceForm() {
|
|||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
return (
|
return (
|
||||||
<FormItem className="space-y-1">
|
<FormItem className="space-y-1">
|
||||||
<FormLabel>Language</FormLabel>
|
<FormLabel>{t("settings.appearance.language")}</FormLabel>
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
Select a language for your dashboard
|
{t("settings.appearance.languageDescription")}
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
<Select
|
<Select
|
||||||
@@ -187,7 +187,7 @@ export function AppearanceForm() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button type="submit">Save</Button>
|
<Button type="submit">{t("settings.common.save")}</Button>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
@@ -96,9 +96,7 @@ export const ProfileForm = () => {
|
|||||||
<CardTitle className="text-xl">
|
<CardTitle className="text-xl">
|
||||||
{t("settings.profile.title")}
|
{t("settings.profile.title")}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
<CardDescription>
|
<CardDescription>{t("settings.profile.description")}</CardDescription>
|
||||||
Change the details of your profile here.
|
|
||||||
</CardDescription>
|
|
||||||
</div>
|
</div>
|
||||||
{!data?.is2FAEnabled ? <Enable2FA /> : <Disable2FA />}
|
{!data?.is2FAEnabled ? <Enable2FA /> : <Disable2FA />}
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
@@ -111,9 +109,12 @@ export const ProfileForm = () => {
|
|||||||
name="email"
|
name="email"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Email</FormLabel>
|
<FormLabel>{t("settings.profile.email")}</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input placeholder="Email" {...field} />
|
<Input
|
||||||
|
placeholder={t("settings.profile.email")}
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -124,11 +125,11 @@ export const ProfileForm = () => {
|
|||||||
name="password"
|
name="password"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Password</FormLabel>
|
<FormLabel>{t("settings.profile.password")}</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
type="password"
|
type="password"
|
||||||
placeholder="Password"
|
placeholder={t("settings.profile.password")}
|
||||||
{...field}
|
{...field}
|
||||||
value={field.value || ""}
|
value={field.value || ""}
|
||||||
/>
|
/>
|
||||||
@@ -143,7 +144,7 @@ export const ProfileForm = () => {
|
|||||||
name="image"
|
name="image"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Avatar</FormLabel>
|
<FormLabel>{t("settings.profile.avatar")}</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
onValueChange={(e) => {
|
onValueChange={(e) => {
|
||||||
@@ -181,7 +182,7 @@ export const ProfileForm = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button type="submit" isLoading={isLoading}>
|
<Button type="submit" isLoading={isLoading}>
|
||||||
Save
|
{t("settings.common.save")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,11 +1,27 @@
|
|||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
|
"common": {
|
||||||
|
"save": "Save"
|
||||||
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"title": "Account"
|
"title": "Account",
|
||||||
|
"description": "Change the details of your profile here.",
|
||||||
|
"email": "Email",
|
||||||
|
"password": "Password",
|
||||||
|
"avatar": "Avatar"
|
||||||
},
|
},
|
||||||
"appearance": {
|
"appearance": {
|
||||||
"title": "Appearance",
|
"title": "Appearance",
|
||||||
"description": "Customize the theme of your dashboard."
|
"description": "Customize the theme of your dashboard.",
|
||||||
|
"theme": "Theme",
|
||||||
|
"themeDescription": "Select a theme for your dashboard",
|
||||||
|
"themes": {
|
||||||
|
"light": "Light",
|
||||||
|
"dark": "Dark",
|
||||||
|
"system": "System"
|
||||||
|
},
|
||||||
|
"language": "Language",
|
||||||
|
"languageDescription": "Select a language for your dashboard"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,27 @@
|
|||||||
{
|
{
|
||||||
"settings": {
|
"settings": {
|
||||||
|
"common": {
|
||||||
|
"save": "保存"
|
||||||
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"title": "账户偏好"
|
"title": "账户偏好",
|
||||||
|
"description": "更改您的个人资料详情。",
|
||||||
|
"email": "电子邮件",
|
||||||
|
"password": "密码",
|
||||||
|
"avatar": "头像"
|
||||||
},
|
},
|
||||||
"appearance": {
|
"appearance": {
|
||||||
"title": "外观",
|
"title": "外观",
|
||||||
"description": "自定义仪表板主题。"
|
"description": "自定义仪表板主题。",
|
||||||
|
"theme": "主题",
|
||||||
|
"themeDescription": "选择仪表板主题",
|
||||||
|
"themes": {
|
||||||
|
"light": "亮",
|
||||||
|
"dark": "暗",
|
||||||
|
"system": "系统"
|
||||||
|
},
|
||||||
|
"language": "语言",
|
||||||
|
"languageDescription": "选择仪表板语言"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
|
|
||||||
const SUPPORTED_LOCALES = ["en", "zh-Hans"] as const;
|
const SUPPORTED_LOCALES = ["en", "zh-Hans"] as const;
|
||||||
|
|
||||||
type Locale = (typeof SUPPORTED_LOCALES)[number];
|
type Locale = (typeof SUPPORTED_LOCALES)[number];
|
||||||
type PossibleLocale = (typeof SUPPORTED_LOCALES)[number] | undefined | null;
|
|
||||||
|
|
||||||
export default function useLocale() {
|
export default function useLocale() {
|
||||||
const currentLocale = Cookies.get("DOKPLOY_LOCALE") as PossibleLocale;
|
const currentLocale = (Cookies.get("DOKPLOY_LOCALE") ?? "en") as Locale;
|
||||||
|
|
||||||
console.log(currentLocale);
|
|
||||||
|
|
||||||
const setLocale = (locale: Locale) => {
|
const setLocale = (locale: Locale) => {
|
||||||
Cookies.set("DOKPLOY_LOCALE", locale);
|
Cookies.set("DOKPLOY_LOCALE", locale);
|
||||||
|
|||||||
Reference in New Issue
Block a user