1 //== Translate Substitute Module =============================================//
4 * For those not using Angular-Translate (pascalprecht.translate), this will sub
5 * in for it so we don't have to include Angular-Translate if we don't want to.
8 var translateSubMod = angular.module('translate.sub',[]);
12 * Sets up a $translateProvider service to use in your module's config
13 * function. $translate.Provider syntax is the same as Angular-Translate,
14 * use $translate.Provider.translations(lang,obj) to change the defaults
15 * for modal button, header and message text.
17 translateSubMod.provider('$translate',[function(){
18 var _translations = []; // object of key/value translation pairs
19 var _current = 'en-US'; // default language
23 * Set the internal object of translation key/value pairs.
25 this.translations = function(lang,obj){
26 if(angular.isDefined(lang) && angular.isDefined(obj)){
27 _translations[lang] = angular.copy(obj);
30 }; // end translations
32 this.$get = [function(){
36 * Retrieve the translation for the given key, if key not found
37 * return an empty string.
38 * Example: $translate.instant('DIALOGS_OK');
40 instant : function(what){
41 if(angular.isDefined(what) && angular.isDefined(_translations[_current][what]))
42 return _translations[_current][what];
49 }]); // end $translate
53 * For use in an Angular template.
54 * Example: {{"DIALOGS_CLOSE" | translate}}
56 translateSubMod.filter('translate',['$translate',function($translate){
57 return function(what){
58 return $translate.instant(what);
60 }]); // end translate / translate.sub