blob: 7722ad96b7bd2d37661942b0d7265d9edfe40a77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
//== Translate Substitute Module =============================================//
/**
* For those not using Angular-Translate (pascalprecht.translate), this will sub
* in for it so we don't have to include Angular-Translate if we don't want to.
*/
var translateSubMod = angular.module('translate.sub',[]);
/**
* $translate Service
* Sets up a $translateProvider service to use in your module's config
* function. $translate.Provider syntax is the same as Angular-Translate,
* use $translate.Provider.translations(lang,obj) to change the defaults
* for modal button, header and message text.
*/
translateSubMod.provider('$translate',[function(){
var _translations = []; // object of key/value translation pairs
var _current = 'en-US'; // default language
/**
* Translations
* Set the internal object of translation key/value pairs.
*/
this.translations = function(lang,obj){
if(angular.isDefined(lang) && angular.isDefined(obj)){
_translations[lang] = angular.copy(obj);
_current = lang;
}
}; // end translations
this.$get = [function(){
return {
/**
* Instant
* Retrieve the translation for the given key, if key not found
* return an empty string.
* Example: $translate.instant('DIALOGS_OK');
*/
instant : function(what){
if(angular.isDefined(what) && angular.isDefined(_translations[_current][what]))
return _translations[_current][what];
else
return '';
} // end instant
}; // end return
}]; // end $get
}]); // end $translate
/**
* Translate Filter
* For use in an Angular template.
* Example: {{"DIALOGS_CLOSE" | translate}}
*/
translateSubMod.filter('translate',['$translate',function($translate){
return function(what){
return $translate.instant(what);
};
}]); // end translate / translate.sub
|