localize-router-http-loader

Http loader for LocalizeRouterParser

Showing:

Popularity

Downloads/wk

463

GitHub Stars

11

Maintenance

Last Commit

4yrs ago

Contributors

2

Package

Dependencies

0

Size (min+gzip)

0.5KB

License

MIT

Type Definitions

Built-In

Tree-Shakeable

Yes?

Categories

Readme

localize-router-http-loader

Build Status npm version

A loader for localize-router that loads config using Http

This package is built for angular version >=4.3. If you are still using old Angular please use localize-router-http-loader version <1.0.0

Installation

npm install --save localize-router-http-loader

Usage

In order to load localize-router config via http, you must initialize LocalizeRouterModule with LocalizeRouterHttpLoader:

// Required for AoT
export function HttpLoaderFactory(translate: TranslateService, location: Location, settings: LocalizeRouterSettings, http: HttpClient) {
  return new LocalizeRouterHttpLoader(translate, location, settings, http);
}

LocalizeRouterModule.forRoot(routes, {
    parser: {
        provide: LocalizeParser,
        useFactory: HttpLoaderFactory,
        deps: [TranslateService, Location, LocalizeRouterSettings, HttpClient]
    }
})

Parameters

LocalizeRouterHttpLoader has one optional parameter path which points to json config file. Default value is assets/locales.json.

export function HttpLoaderFactory(translate: TranslateService, location: Location, settings: LocalizeRouterSettings, http: HttpClient) {
  return new LocalizeRouterHttpLoader(translate, location, settings, http, 'my/custom/url/to/file.json');
}

Config file

JSON config file has following structure:

{
    "locales": ["en", "de", ...],
    "prefix": "MY_PREFIX"
}
interface ILocalizeRouterParserConfig {
    locales: Array<string>;
    prefix?: string;
}

Prefix field is not mandatory and default value is empty string.

License

Licensed under MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100