Multi Language
Multi Language Settings
i18n Language translation settings
How to add new language?
Let's add German language in the existing language.
-
Create a new file
src/assets/i18n/de.json
-
update the below code in the
src/assets/i18n.js
file
{ text: 'Deutsche', flag: 'assets/images/flags/germany.svg', lang: 'de' },
The translationGr JSON file,
{ "Mega Menu": "Mega-Menu", }
-
Now add the new option of German language in the
topbar language dropdown menu
src/app/layouts/topbar/topbar.component.ts
-
install
ngx-translate
andngx-cookie-service
packages -
ngx-translate
import in app.module.ts fileimport { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; export function createTranslateLoader(http: HttpClient): any { return new TranslateHttpLoader(http, 'assets/i18n/', '.json'); } @NgModule({ imports: [ TranslateModule.forRoot({ defaultLanguage: 'en', loader: { provide: TranslateLoader, useFactory: (createTranslateLoader), deps: [HttpClient] } }), ] });