2024-12-01 22:04:28 +00:00
|
|
|
import * as interfaces from '../interfaces/index.js';
|
2024-11-30 19:54:15 +00:00
|
|
|
|
|
|
|
type TTranslationImplementation = {
|
|
|
|
[key in keyof interfaces.IDeDocumentTranslations]: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const EN_translations: TTranslationImplementation = {
|
|
|
|
invoice: 'Invoice',
|
|
|
|
quantity: 'Quantity',
|
|
|
|
};
|
|
|
|
|
|
|
|
export const DE_translations: TTranslationImplementation = {
|
|
|
|
invoice: 'Rechnung',
|
|
|
|
quantity: 'Anzahl',
|
|
|
|
};
|
|
|
|
|
|
|
|
export const languageCodeMap = {
|
|
|
|
'DE': DE_translations,
|
|
|
|
'EN': EN_translations,
|
|
|
|
};
|
|
|
|
|
|
|
|
export type TLanguageCode = keyof typeof languageCodeMap;
|
|
|
|
|
|
|
|
export const translate = (languageCode: TLanguageCode, key: string, defaultValue: string) => {
|
|
|
|
const translations = languageCodeMap[languageCode] || EN_translations;
|
|
|
|
if (translations && translations[key]) {
|
|
|
|
return translations[key];
|
|
|
|
} else {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
};
|