import * as interfaces from '../interfaces/index.js'; 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; } };