m-e-conroy/angular-dialog-service — pull request #17 by oliversalzburg (2014-02-28 12:21:30+00:00)
Title: Added i18n support

This adds a new provider on the `dialogs` module. This provider contains the collection of all strings used by default in the dialogs.

The `$dialogs` service now exposes a new function `translate`. By calling this function, the user can provide alternative translations to be used.

We integrate dialogs with this translation feature (using [i18n-node-angular](https://github.com/oliversalzburg/i18n-node-angular)) into our application as follows:

var myModule = angular.module( "myModule", [
"dialogs", "i18n"
] )
.config( [
"$routeProvider", "$locationProvider", "$compileProvider",
function( $routeProvider, $locationProvider, $compileProvider ) {
// stuff
}
] )
.run( [
"i18n", "$dialogs",
function( i18n, $dialogs ) {
i18n.ensureLocaleIsLoaded().then( function() {
// Retrieve original strings
var defaultStrings = $dialogs.translate();
var translated = {};
for( var translateable in defaultStrings ) {
translated[ translateable ] = i18n.__( defaultStrings[ translateable ] );
}
var result = $dialogs.translate( translated );
} );
}
] );