From b0183de57bac437d6b92c32fc9dae106e3dbc430 Mon Sep 17 00:00:00 2001 From: Rajat Vig Date: Wed, 15 Jul 2015 09:06:21 -0700 Subject: [PATCH] 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 --- horizon/static/framework/util/i18n/i18n.js | 44 ++++++++++++---------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/horizon/static/framework/util/i18n/i18n.js b/horizon/static/framework/util/i18n/i18n.js index fdf59eede4..00acbfc564 100644 --- a/horizon/static/framework/util/i18n/i18n.js +++ b/horizon/static/framework/util/i18n/i18n.js @@ -16,27 +16,31 @@ (function () { '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 - * @description - * Provides a wrapper for translation, using the global 'gettext' - * function if it is present. Provides a method that - * simply returns the input if the expected global 'gettext' is - * not provided. - * - * Ideally once gettext is no longer needed on a global scope, - * the global ref can be deleted here. For now that is not possible. - * Also, if future alternate means were provided, we could put that - * logic here. - * - * This could also be done in the context of the filter, but - * the approach taken here was to separate business logic - * (translation) from filters, which are arguably more - * presentation-oriented. - */ - .factory('horizon.framework.util.i18n.gettext', ['$window', function ($window) { + * @name horizon.framework.util.i18n.gettext + * @description + * Provides a wrapper for translation, using the global 'gettext' + * function if it is present. Provides a method that + * simply returns the input if the expected global 'gettext' is + * not provided. + * + * Ideally once gettext is no longer needed on a global scope, + * the global ref can be deleted here. For now that is not possible. + * Also, if future alternate means were provided, we could put that + * logic here. + * + * This could also be done in the context of the filter, but + * the approach taken here was to separate business logic + * (translation) from filters, which are arguably more + * presentation-oriented. + */ + function getText($window) { // If no global function, revert to just returning given text. var gettextFunc = $window.gettext || function (x) { return x; }; @@ -45,5 +49,5 @@ return function () { return gettextFunc.apply(this, arguments); }; - }]); + } })();