LBA/catalog-service/src/app/i18next/i18next.module.ts

27 lines
841 B
TypeScript

import { Module } from '@nestjs/common';
import * as i18next from 'i18next';
import Backend from 'i18next-fs-backend';
import { join } from 'path';
@Module({
providers: [
{
provide: 'I18NEXT',
useFactory: async () => {
await i18next.use(Backend).init({
lng: 'en', // زبان پیش‌فرض
fallbackLng: 'en', // زبان جایگزین
backend: {
loadPath: join(__dirname, './locales/{{lng}}/{{ns}}.json'), // مسیر فایل‌های ترجمه
},
ns: ['language', 'validation','translation'], // فضاهای نام
defaultNS: 'translation', // فضای نام پیش‌فرض
debug: true, // برای دیباگ
});
return i18next;
},
},
],
exports: ['I18NEXT'],
})
export class I18nextModule {}