Skip to content
Custom loader that allows to have modular angular-translate localizations
JavaScript TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
src
tests
.editorconfig
.gitignore
.npmignore
.travis.yml
CONTRIBUTING.md
README.md
bower.json
gulpfile.js
index.d.ts
karma.conf.js
package.json
tsconfig.json
tslint.json
webpack.config.js

README.md

angular-translate Pluggable Loader

Build Status semantic-release npm version Bower version

This library has been designed for Angular 1.5

Pluggable Loader is a custom loader for angular-translate. It aims to facilitate the modularization of the applications s.t. each module can contribute their own translations and possibly be independent in the kind of angular-translate loader it uses.

Installation

Available as npm package

$ npm install angular-translate-loader-pluggable --save

or as Bower package

$ bower install angular-translate-loader-pluggable --save

Docs & Demo

Plunkr demo: http://plnkr.co/edit/Smc89rX5UoCXYu6Qp2F0?p=preview

Configure your app to use the pluggable loader:

angular.module('demoapp', [
    'pascalprecht.translate',
    'angular-translate-loader-pluggable'
  ])
  .config(function translationConfig($translateProvider, translatePluggableLoaderProvider) {
    $translateProvider.useLoader('translatePluggableLoader');
  })

Then, in your angular modules where you want to contribute new translations, use the translatePluggableLoaderProvider instead of the $translateProvider.

angular.module('staticTranslationsModule', ['angular-translate-loader-pluggable'])
  .config(function(translatePluggableLoaderProvider) {
    translatePluggableLoaderProvider
      .translations('de', {
        "anotherMessage": "Anderes Message!"
      })
      .translations('en', {
        "anotherMessage": "Some Message!"
      });
  });

You can also use other loaders, such as the partial loader:

angular
  .module('partialModule', ['angular-translate-loader-pluggable'])
  .config(function(translatePluggableLoaderProvider, $translatePartialLoaderProvider){
    // this module uses the $translatePartialLoader
    translatePluggableLoaderProvider.useLoader('$translatePartialLoader', {
      urlTemplate: '{part}-locale-{lang}.json'
    });

    $translatePartialLoaderProvider.addPart('anothermodule');
  });

Note that I'm not registering the $translatePartialLoader on the $translateProvider but instead on the translatePluggableLoderProvider so that it can handle it.


Your loader doesn't work? Let me know about it!

Contribute

Of course! If you have improvements, suggestions, let me know about them and either file some issues to discuss something or even better, submit a PR. Please check out our contribution guidelines!

You can’t perform that action at this time.