JSCS Cleanup - use function syntax for i18n
Changed the declaration of i18n factory to fix the angular/ng_di violation Change-Id: I39efe672df8ebb8ea943b47d9f15fed8d9d08b7b Partially-Implements: blueprint jscs-cleanup
This commit is contained in:
parent
fa012c21ba
commit
b0183de57b
@ -16,27 +16,31 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('horizon.framework.util.i18n', [])
|
angular
|
||||||
|
.module('horizon.framework.util.i18n', [])
|
||||||
|
.factory('horizon.framework.util.i18n.gettext', getText);
|
||||||
|
|
||||||
|
getText.$inject = ['$window'];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @name horizon.framework.util.i18n.gettext
|
* @name horizon.framework.util.i18n.gettext
|
||||||
* @description
|
* @description
|
||||||
* Provides a wrapper for translation, using the global 'gettext'
|
* Provides a wrapper for translation, using the global 'gettext'
|
||||||
* function if it is present. Provides a method that
|
* function if it is present. Provides a method that
|
||||||
* simply returns the input if the expected global 'gettext' is
|
* simply returns the input if the expected global 'gettext' is
|
||||||
* not provided.
|
* not provided.
|
||||||
*
|
*
|
||||||
* Ideally once gettext is no longer needed on a global scope,
|
* Ideally once gettext is no longer needed on a global scope,
|
||||||
* the global ref can be deleted here. For now that is not possible.
|
* the global ref can be deleted here. For now that is not possible.
|
||||||
* Also, if future alternate means were provided, we could put that
|
* Also, if future alternate means were provided, we could put that
|
||||||
* logic here.
|
* logic here.
|
||||||
*
|
*
|
||||||
* This could also be done in the context of the filter, but
|
* This could also be done in the context of the filter, but
|
||||||
* the approach taken here was to separate business logic
|
* the approach taken here was to separate business logic
|
||||||
* (translation) from filters, which are arguably more
|
* (translation) from filters, which are arguably more
|
||||||
* presentation-oriented.
|
* presentation-oriented.
|
||||||
*/
|
*/
|
||||||
.factory('horizon.framework.util.i18n.gettext', ['$window', function ($window) {
|
function getText($window) {
|
||||||
// If no global function, revert to just returning given text.
|
// If no global function, revert to just returning given text.
|
||||||
var gettextFunc = $window.gettext || function (x) { return x; };
|
var gettextFunc = $window.gettext || function (x) { return x; };
|
||||||
|
|
||||||
@ -45,5 +49,5 @@
|
|||||||
return function () {
|
return function () {
|
||||||
return gettextFunc.apply(this, arguments);
|
return gettextFunc.apply(this, arguments);
|
||||||
};
|
};
|
||||||
}]);
|
}
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user