-
Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathtransloco-root.module.ts
56 lines (53 loc) · 1.66 KB
/
transloco-root.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { HttpClient } from '@angular/common/http';
import { Injectable, NgModule } from '@angular/core';
import {
Translation,
TRANSLOCO_CONFIG,
TRANSLOCO_LOADER,
translocoConfig,
TranslocoLoader,
TranslocoModule,
} from '@ngneat/transloco';
import { environment } from '../environments/environment';
@Injectable({ providedIn: 'root' })
export class TranslocoHttpLoader implements TranslocoLoader {
constructor(private readonly http: HttpClient) {}
getTranslation(lang: string) {
return this.http.get<Translation>(`assets/i18n/${lang}.json`);
}
}
@NgModule({
exports: [TranslocoModule],
providers: [
{
provide: TRANSLOCO_CONFIG,
useValue: translocoConfig({
availableLangs: [
{ id: 'en', label: 'English' },
{ id: 'de', label: 'Deutsch' },
{ id: 'ru', label: 'Русский' },
{ id: 'fr', label: 'Français' },
{ id: 'zh-CN', label: '中文(中国)' },
{ id: 'ja', label: '日本語' },
{ id: 'nl', label: 'Nederlands' },
{ id: 'no', label: 'Norsk' },
{ id: 'es', label: 'Español' },
{ id: 'ko', label: '한국어' },
{ id: 'tr', label: 'Türkçe' },
{ id: 'cs', label: 'Čeština' },
{ id: 'pl', label: 'Polski' },
{ id: 'overwrite', label: 'Custom' },
],
defaultLang: 'en',
fallbackLang: 'en',
missingHandler: {
useFallbackTranslation: true,
},
reRenderOnLangChange: true,
prodMode: environment.production,
}),
},
{ provide: TRANSLOCO_LOADER, useClass: TranslocoHttpLoader },
],
})
export class TranslocoRootModule {}