Translations cleaning / workflows (#10125)

This commit is contained in:
Félix Malfait
2025-02-11 15:26:21 +01:00
committed by GitHub
parent 6da9976193
commit cc68deaab1
63 changed files with 376 additions and 164 deletions

View File

@ -16,7 +16,7 @@ import { detectTimeZone } from '@/localization/utils/detectTimeZone';
import { getDateFormatFromWorkspaceDateFormat } from '@/localization/utils/getDateFormatFromWorkspaceDateFormat';
import { getTimeFormatFromWorkspaceTimeFormat } from '@/localization/utils/getTimeFormatFromWorkspaceTimeFormat';
import { ColorScheme } from '@/workspace-member/types/WorkspaceMember';
import { APP_LOCALES, isDefined } from 'twenty-shared';
import { APP_LOCALES, isDefined, SOURCE_LOCALE } from 'twenty-shared';
import { WorkspaceMember } from '~/generated-metadata/graphql';
import { useGetCurrentUserQuery } from '~/generated/graphql';
import { dynamicActivate } from '~/utils/i18n/dynamicActivate';
@ -70,7 +70,8 @@ export const UserProviderEffect = () => {
return {
...workspaceMember,
colorScheme: (workspaceMember.colorScheme as ColorScheme) ?? 'Light',
locale: (workspaceMember.locale as keyof typeof APP_LOCALES) ?? 'en',
locale:
(workspaceMember.locale as keyof typeof APP_LOCALES) ?? SOURCE_LOCALE,
};
};
@ -94,7 +95,7 @@ export const UserProviderEffect = () => {
});
dynamicActivate(
(workspaceMember.locale as keyof typeof APP_LOCALES) ?? 'en',
(workspaceMember.locale as keyof typeof APP_LOCALES) ?? SOURCE_LOCALE,
);
}

View File

@ -65,33 +65,85 @@ export const LocalePicker = () => {
label: string;
value: (typeof APP_LOCALES)[keyof typeof APP_LOCALES];
}> = [
{
label: t`Afrikaans`,
value: APP_LOCALES['af-ZA'],
},
{
label: t`Arabic`,
value: APP_LOCALES['ar-SA'],
},
{
label: t`Catalan`,
value: APP_LOCALES['ca-ES'],
},
{
label: t`Chinese — Simplified`,
value: APP_LOCALES['zh-CN'],
},
{
label: t`Chinese — Traditional`,
value: APP_LOCALES['zh-TW'],
},
{
label: t`Czech`,
value: APP_LOCALES['cs-CZ'],
},
{
label: t`Danish`,
value: APP_LOCALES['da-DK'],
},
{
label: t`Dutch`,
value: APP_LOCALES['nl-NL'],
},
{
label: t`English`,
value: APP_LOCALES.en,
},
{
label: t`Finnish`,
value: APP_LOCALES['fi-FI'],
},
{
label: t`French`,
value: APP_LOCALES['fr-FR'],
},
{
label: t`Spanish`,
value: APP_LOCALES['es-ES'],
},
{
label: t`German`,
value: APP_LOCALES['de-DE'],
},
{
label: t`Greek`,
value: APP_LOCALES['el-GR'],
},
{
label: t`Hebrew`,
value: APP_LOCALES['he-IL'],
},
{
label: t`Hungarian`,
value: APP_LOCALES['hu-HU'],
},
{
label: t`Italian`,
value: APP_LOCALES['it-IT'],
},
{
label: t`Japanese`,
value: APP_LOCALES['ja-JP'],
},
{
label: t`Korean`,
value: APP_LOCALES['ko-KR'],
},
{
label: t`Japanese`,
value: APP_LOCALES['ja-JP'],
label: t`Norwegian`,
value: APP_LOCALES['no-NO'],
},
{
label: t`Polish`,
value: APP_LOCALES['pl-PL'],
},
{
label: t`Portuguese — Portugal`,
@ -102,12 +154,36 @@ export const LocalePicker = () => {
value: APP_LOCALES['pt-BR'],
},
{
label: t`Chinese — Simplified`,
value: APP_LOCALES['zh-CN'],
label: t`Romanian`,
value: APP_LOCALES['ro-RO'],
},
{
label: t`Chinese — Traditional`,
value: APP_LOCALES['zh-TW'],
label: t`Russian`,
value: APP_LOCALES['ru-RU'],
},
{
label: t`Serbian (Cyrillic)`,
value: APP_LOCALES['sr-Cyrl'],
},
{
label: t`Spanish`,
value: APP_LOCALES['es-ES'],
},
{
label: t`Swedish`,
value: APP_LOCALES['sv-SE'],
},
{
label: t`Turkish`,
value: APP_LOCALES['tr-TR'],
},
{
label: t`Ukrainian`,
value: APP_LOCALES['uk-UA'],
},
{
label: t`Vietnamese`,
value: APP_LOCALES['vi-VN'],
},
];
if (isDebugMode) {

View File

@ -1,12 +1,13 @@
import { i18n } from '@lingui/core';
import { I18nProvider } from '@lingui/react';
import { Decorator } from '@storybook/react';
import { SOURCE_LOCALE } from 'twenty-shared';
import { messages as enMessages } from '../../locales/generated/en';
i18n.load({
en: enMessages,
[SOURCE_LOCALE]: enMessages,
});
i18n.activate('en');
i18n.activate(SOURCE_LOCALE);
export const I18nFrontDecorator: Decorator = (Story) => {
return (

View File

@ -27,6 +27,7 @@ import { PrefetchDataProvider } from '@/prefetch/components/PrefetchDataProvider
import { WorkspaceProviderEffect } from '@/workspace/components/WorkspaceProviderEffect';
import { i18n } from '@lingui/core';
import { I18nProvider } from '@lingui/react';
import { SOURCE_LOCALE } from 'twenty-shared';
import { IconsProvider } from 'twenty-ui';
import { dynamicActivate } from '~/utils/i18n/dynamicActivate';
import { FullHeightStorybookLayout } from '../FullHeightStorybookLayout';
@ -67,7 +68,7 @@ const ApolloStorybookDevLogEffect = () => {
return <></>;
};
await dynamicActivate('en');
await dynamicActivate(SOURCE_LOCALE);
const Providers = () => {
return (

View File

@ -1,11 +1,11 @@
import { i18n } from '@lingui/core';
import { APP_LOCALES } from 'twenty-shared';
import { APP_LOCALES, SOURCE_LOCALE } from 'twenty-shared';
export const dynamicActivate = async (locale: keyof typeof APP_LOCALES) => {
if (!Object.values(APP_LOCALES).includes(locale)) {
// eslint-disable-next-line no-console
console.warn(`Invalid locale "${locale}", defaulting to "en"`);
locale = 'en';
locale = SOURCE_LOCALE;
}
const { messages } = await import(`../../locales/generated/${locale}.ts`);
i18n.load(locale, messages);

View File

@ -1,5 +1,10 @@
import { fromNavigator, fromStorage, fromUrl } from '@lingui/detect-locale';
import { APP_LOCALES, isDefined, isValidLocale } from 'twenty-shared';
import {
APP_LOCALES,
isDefined,
isValidLocale,
SOURCE_LOCALE,
} from 'twenty-shared';
import { dynamicActivate } from '~/utils/i18n/dynamicActivate';
export const initialI18nActivate = () => {
@ -22,7 +27,7 @@ export const initialI18nActivate = () => {
} else if (isDefined(navigatorLocale) && isValidLocale(navigatorLocale)) {
// TODO: remove when we're ready to launch
// locale = navigatorLocale;
locale = 'en';
locale = SOURCE_LOCALE;
}
dynamicActivate(locale);