Skip to content

Commit

Permalink
fix: test fuer translate gefixed
Browse files Browse the repository at this point in the history
  • Loading branch information
deleonio committed Feb 27, 2024
1 parent 73204d4 commit 1974c7a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/components/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Generic } from 'adopted-style-sheets';
import { i18n } from './core/i18n';
import locale_de from './locales/de';
import locale_en from './locales/en';
import { processEnv } from '@public-ui/schema';

type ResourcePrefix = 'Kol';
type ComponentKeys = keyof typeof locale_de;
Expand All @@ -19,11 +20,15 @@ type Options = {
placeholders?: { [K: string]: string };
};

export const translate = (key: `${Lowercase<ResourcePrefix>}-${Lowercase<ComponentKeys>}`, options?: Options) => {
export let translate = (key: `${Lowercase<ResourcePrefix>}-${Lowercase<ComponentKeys>}`, options?: Options) => {
let text = i18n.translate(key, options);
if (text === key) {
i18n.addTranslations(translations);
text = i18n.translate(key, options);
}
return text;
};

if (processEnv === 'test') {
translate = (key): string => key;
}

0 comments on commit 1974c7a

Please sign in to comment.