mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-27 05:07:50 +02:00
🌐 Streamline supported languages (#1728)
This commit is contained in:
parent
c5724f0118
commit
061989d241
4 changed files with 27 additions and 64 deletions
|
@ -21,21 +21,17 @@ import { usePreferences } from "@/contexts/preferences";
|
||||||
import { useTranslation } from "@/i18n/client";
|
import { useTranslation } from "@/i18n/client";
|
||||||
import { getBrowserTimeZone, normalizeTimeZone } from "@/utils/date-time-utils";
|
import { getBrowserTimeZone, normalizeTimeZone } from "@/utils/date-time-utils";
|
||||||
|
|
||||||
|
import type { SupportedLocale } from "@rallly/languages";
|
||||||
import { useRequiredContext } from "../components/use-required-context";
|
import { useRequiredContext } from "../components/use-required-context";
|
||||||
|
|
||||||
const dayjsLocales: Record<
|
const dayjsLocales: Record<
|
||||||
string,
|
SupportedLocale,
|
||||||
{
|
{
|
||||||
weekStart: number;
|
weekStart: number;
|
||||||
timeFormat: TimeFormat;
|
timeFormat: TimeFormat;
|
||||||
import: () => Promise<ILocale>;
|
import: () => Promise<ILocale>;
|
||||||
}
|
}
|
||||||
> = {
|
> = {
|
||||||
eu: {
|
|
||||||
weekStart: 1,
|
|
||||||
timeFormat: "hours24",
|
|
||||||
import: () => import("dayjs/locale/eu"),
|
|
||||||
},
|
|
||||||
en: {
|
en: {
|
||||||
weekStart: 1,
|
weekStart: 1,
|
||||||
timeFormat: "hours12",
|
timeFormat: "hours12",
|
||||||
|
@ -51,11 +47,6 @@ const dayjsLocales: Record<
|
||||||
timeFormat: "hours24",
|
timeFormat: "hours24",
|
||||||
import: () => import("dayjs/locale/es"),
|
import: () => import("dayjs/locale/es"),
|
||||||
},
|
},
|
||||||
ca: {
|
|
||||||
weekStart: 1,
|
|
||||||
timeFormat: "hours24",
|
|
||||||
import: () => import("dayjs/locale/ca"),
|
|
||||||
},
|
|
||||||
da: {
|
da: {
|
||||||
weekStart: 1,
|
weekStart: 1,
|
||||||
timeFormat: "hours24",
|
timeFormat: "hours24",
|
||||||
|
@ -76,11 +67,6 @@ const dayjsLocales: Record<
|
||||||
timeFormat: "hours24",
|
timeFormat: "hours24",
|
||||||
import: () => import("dayjs/locale/fr"),
|
import: () => import("dayjs/locale/fr"),
|
||||||
},
|
},
|
||||||
hr: {
|
|
||||||
weekStart: 1,
|
|
||||||
timeFormat: "hours24",
|
|
||||||
import: () => import("dayjs/locale/hr"),
|
|
||||||
},
|
|
||||||
it: {
|
it: {
|
||||||
weekStart: 1,
|
weekStart: 1,
|
||||||
timeFormat: "hours24",
|
timeFormat: "hours24",
|
||||||
|
@ -91,11 +77,6 @@ const dayjsLocales: Record<
|
||||||
timeFormat: "hours24",
|
timeFormat: "hours24",
|
||||||
import: () => import("dayjs/locale/sv"),
|
import: () => import("dayjs/locale/sv"),
|
||||||
},
|
},
|
||||||
sk: {
|
|
||||||
weekStart: 1,
|
|
||||||
timeFormat: "hours24",
|
|
||||||
import: () => import("dayjs/locale/sk"),
|
|
||||||
},
|
|
||||||
cs: {
|
cs: {
|
||||||
weekStart: 1,
|
weekStart: 1,
|
||||||
timeFormat: "hours24",
|
timeFormat: "hours24",
|
||||||
|
@ -141,21 +122,6 @@ const dayjsLocales: Record<
|
||||||
timeFormat: "hours24",
|
timeFormat: "hours24",
|
||||||
import: () => import("dayjs/locale/zh"),
|
import: () => import("dayjs/locale/zh"),
|
||||||
},
|
},
|
||||||
"zh-Hant": {
|
|
||||||
weekStart: 0,
|
|
||||||
timeFormat: "hours24",
|
|
||||||
import: () => import("dayjs/locale/zh-tw"),
|
|
||||||
},
|
|
||||||
vi: {
|
|
||||||
weekStart: 1,
|
|
||||||
timeFormat: "hours24",
|
|
||||||
import: () => import("dayjs/locale/vi"),
|
|
||||||
},
|
|
||||||
tr: {
|
|
||||||
weekStart: 1,
|
|
||||||
timeFormat: "hours24",
|
|
||||||
import: () => import("dayjs/locale/tr"),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dayjs.extend(localizedFormat);
|
dayjs.extend(localizedFormat);
|
||||||
|
@ -195,7 +161,7 @@ export const useDayjs = () => {
|
||||||
export const DayjsProvider: React.FunctionComponent<{
|
export const DayjsProvider: React.FunctionComponent<{
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
config?: {
|
config?: {
|
||||||
locale?: string;
|
locale?: SupportedLocale;
|
||||||
timeZone?: string;
|
timeZone?: string;
|
||||||
localeOverrides?: {
|
localeOverrides?: {
|
||||||
weekStart?: number;
|
weekStart?: number;
|
||||||
|
@ -281,7 +247,7 @@ export const ConnectedDayjsProvider = ({
|
||||||
return (
|
return (
|
||||||
<DayjsProvider
|
<DayjsProvider
|
||||||
config={{
|
config={{
|
||||||
locale: i18n.language,
|
locale: i18n.language as SupportedLocale,
|
||||||
timeZone: preferences.timeZone ?? undefined,
|
timeZone: preferences.timeZone ?? undefined,
|
||||||
localeOverrides: {
|
localeOverrides: {
|
||||||
weekStart: preferences.weekStart ?? undefined,
|
weekStart: preferences.weekStart ?? undefined,
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import languages from "./languages.json";
|
import { languages } from "./languages";
|
||||||
|
|
||||||
|
export type SupportedLocale = keyof typeof languages;
|
||||||
|
|
||||||
export const supportedLngs = Object.keys(languages);
|
export const supportedLngs = Object.keys(languages);
|
||||||
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
{
|
|
||||||
"eu": "Basque",
|
|
||||||
"ca": "Català",
|
|
||||||
"cs": "Česky",
|
|
||||||
"da": "Dansk",
|
|
||||||
"de": "Deutsch",
|
|
||||||
"en": "English",
|
|
||||||
"en-GB": "English (UK)",
|
|
||||||
"es": "Español",
|
|
||||||
"fr": "Français",
|
|
||||||
"hr": "Hrvatski",
|
|
||||||
"it": "Italiano",
|
|
||||||
"hu": "Magyar",
|
|
||||||
"nl": "Nederlands",
|
|
||||||
"no": "Norsk",
|
|
||||||
"pl": "Polski",
|
|
||||||
"pt-BR": "Português - Brasil",
|
|
||||||
"ru": "Русский",
|
|
||||||
"sk": "Slovenčina",
|
|
||||||
"fi": "Suomi",
|
|
||||||
"sv": "Svenska",
|
|
||||||
"tr": "Türkçe",
|
|
||||||
"zh": "简体中文",
|
|
||||||
"zh-Hant": "繁體中文"
|
|
||||||
}
|
|
20
packages/languages/src/languages.ts
Normal file
20
packages/languages/src/languages.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
export const languages = {
|
||||||
|
cs: "Česky",
|
||||||
|
da: "Dansk",
|
||||||
|
de: "Deutsch",
|
||||||
|
en: "English",
|
||||||
|
"en-GB": "English (UK)",
|
||||||
|
es: "Español",
|
||||||
|
fr: "Français",
|
||||||
|
it: "Italiano",
|
||||||
|
hu: "Magyar",
|
||||||
|
nl: "Nederlands",
|
||||||
|
no: "Norsk",
|
||||||
|
pl: "Polski",
|
||||||
|
pt: "Português",
|
||||||
|
"pt-BR": "Português - Brasil",
|
||||||
|
ru: "Русский",
|
||||||
|
fi: "Suomi",
|
||||||
|
sv: "Svenska",
|
||||||
|
zh: "简体中文",
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue