Skip to content

A loader for `ngx-translate` internationalization library that loads locally stored translations for NativeScript Angular.

Notifications You must be signed in to change notification settings

danvick/ngx-translate-nativescript-loader

Repository files navigation

Description

A loader for ngx-translate that loads localally stored translations for NativeScript.

Version Size Downloads

Installation:

npm i @ngx-translate/core --save
npm i @danvick/ngx-translate-nativescript-loader --save

Usage:

import { NgModule } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { NativeScriptLoader } from '@danvick/ngx-translate-nativescript-loader';

export function createTranslateLoader() {
    return new NativeScriptLoader("./assets/i18n/", ".json");
}

@NgModule({
	imports: [
		NativeScriptModule,
		TranslateModule.forRoot({
			loader: {
				provide: TranslateLoader,
				useFactory: createTranslateLoader
			}
		})
	],
	bootstrap: [AppComponent]
})
export class AppModule { }

The assumed default location for your translation is ./assets/i18n/ and default assumed format extesion is .json. So you could ignore the arguments all together and have your createTranslateLoader() function as:

export function createTranslateLoader() {
    return new NativeScriptLoader();
}

About

A loader for `ngx-translate` internationalization library that loads locally stored translations for NativeScript Angular.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •