oex2003/evolution-api
0
1import { ConfigService, Language } from '@config/env.config';2import fs from 'fs';3import i18next from 'i18next';4import path from 'path';5 6const languages = ['en', 'pt-BR', 'es'];7const translationsPath = path.join(__dirname, 'translations');8const configService: ConfigService = new ConfigService();9 10const resources: any = {};11 12languages.forEach((language) => {13 const languagePath = path.join(translationsPath, `${language}.json`);14 if (fs.existsSync(languagePath)) {15 resources[language] = {16 translation: require(languagePath),17 };18 }19});20 21i18next.init({22 resources,23 fallbackLng: 'en',24 lng: configService.get<Language>('LANGUAGE'),25 debug: false,26 27 interpolation: {28 escapeValue: false,29 },30});31export default i18next;32 