Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
190km committed Dec 26, 2024
1 parent c3476a1 commit 46348f4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ import { useTheme } from "next-themes";
import { useEffect } from "react";
import { toast } from "sonner";


const languageCodes = Object.values(Languages).map(lang => lang.code) as string[];
const appearanceFormSchema = z.object({
theme: z.enum(["light", "dark", "system"], {
required_error: "Please select a theme.",
}),

language: z.enum(Object.values(Languages).map(lang => lang.code), {
language: z.enum(languageCodes, {
required_error: "Please select a language.",
}),
})
});

type AppearanceFormValues = z.infer<typeof appearanceFormSchema>;
Expand Down
40 changes: 21 additions & 19 deletions apps/dokploy/lib/languages.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
export const Languages = {
english: { code: "en", name: "English" },
polish: { code: "pl", name: "Polski" },
russian: { code: "ru", name: "Русский" },
french: { code: "fr", name: "Français" },
german: { code: "de", name: "Deutsch" },
chineseTraditional: { code: "zh-Hant", name: "繁體中文" },
chineseSimplified: { code: "zh-Hans", name: "简体中文" },
turkish: { code: "tr", name: "Türkçe" },
kazakh: { code: "kz", name: "Қазақ" },
persian: { code: "fa", name: "فارسی" },
korean: { code: "ko", name: "한국어" },
portuguese: { code: "pt-br", name: "Português" },
italian: { code: "it", name: "Italiano" },
japanese: { code: "ja", name: "日本語" },
spanish: { code: "es", name: "Español" },
};

export type Language = keyof typeof Languages;
export const Languages = {
english: { code: "en", name: "English" },
polish: { code: "pl", name: "Polski" },
russian: { code: "ru", name: "Русский" },
french: { code: "fr", name: "Français" },
german: { code: "de", name: "Deutsch" },
chineseTraditional: { code: "zh-Hant", name: "繁體中文" },
chineseSimplified: { code: "zh-Hans", name: "简体中文" },
turkish: { code: "tr", name: "Türkçe" },
kazakh: { code: "kz", name: "Қазақ" },
persian: { code: "fa", name: "فارسی" },
korean: { code: "ko", name: "한국어" },
portuguese: { code: "pt-br", name: "Português" },
italian: { code: "it", name: "Italiano" },
japanese: { code: "ja", name: "日本語" },
spanish: { code: "es", name: "Español" },
};

export type Language = keyof typeof Languages;
export type LanguageCode = (typeof Languages)[keyof typeof Languages]["code"];

2 changes: 1 addition & 1 deletion apps/dokploy/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default api.withTRPC(
appWithTranslation(MyApp, {
i18n: {
defaultLocale: "en",
locales: Object.values(Languages),
locales: Object.values(Languages).map(language => language.code),
localeDetection: false,
},
fallbackLng: "en",
Expand Down
7 changes: 4 additions & 3 deletions apps/dokploy/utils/hooks/use-locale.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { Languages } from "@/lib/languages";
import { LanguageCode } from "@/lib/languages";
import Cookies from "js-cookie";

export default function useLocale() {
const currentLocale = (Cookies.get("DOKPLOY_LOCALE") ?? "en") as Languages;

const currentLocale = (Cookies.get("DOKPLOY_LOCALE") ?? "en") as LanguageCode;

const setLocale = (locale: Languages) => {
const setLocale = (locale: LanguageCode) => {
Cookies.set("DOKPLOY_LOCALE", locale, { expires: 365 });
window.location.reload();
};
Expand Down
2 changes: 1 addition & 1 deletion apps/dokploy/utils/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const serverSideTranslations = (
keySeparator: false,
i18n: {
defaultLocale: "en",
locales: Object.values(Languages),
locales: Object.values(Languages).map(language => language.code),
localeDetection: false,
},
});

0 comments on commit 46348f4

Please sign in to comment.