1angular.module('irk') 2.factory('i18n', function ($http, Session, $q) { 3 4 var i18nTool = {}; 5 i18nTool.cache = {}; 6 7 i18nTool.clearCache = function() { 8 i18nTool.cache = {}; 9 } 10 11 i18nTool.viewPolicyChecker = function (key) { 12 return $http 13 .get('REST/i18n/'+key, { 14 }) 15 .then(function (res) { 16 return res.data; 17 }); 18 }; 19 20 i18nTool.get = function (key) { 21 if(!(key in this.cache)) { 22 this.cache[key] = this.viewPolicyChecker(key); 23 } 24 result = this.cache[key]; 25 26 var deferred = $q.defer(); 27 deferred.resolve(result); 28 return deferred.promise; 29 }; 30 31 i18nTool.translateSelectOptions = function(selectOptions) { 32 selectOptions.forEach(function(value) { 33 if(value.localisable) { 34 i18nTool.get(value.label).then(function(translated) { 35 value.label = translated; 36 }); 37 } 38 }); 39 }; 40 41 Session.registerObserverCallback(function() { 42 i18nTool.clearCache(); 43 }); 44 45 return i18nTool; 46 });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.