Code coverage report for app/assets/localizationHelper.js

Statements: 100% (7 / 7)      Branches: 100% (4 / 4)      Functions: 100% (2 / 2)      Lines: 100% (7 / 7)      Ignored: none     

All files » app/assets/ » localizationHelper.js
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              1                                           1                   1 38 38         1 1  
/*global require, define */
/*jslint nomen: true, debug: true, bitwise: true, todo: true */
 
/**
 * @module localizationHelper
 */
 
define([
    "handlebars",
    "framework",
    "l10n",
    "text!localization/localization.json"
],
    /**
     * @description Handlebars localization helper
     * @name module:localizationHelper
     * @requires handlebars {Function} Handlebars
     * @requires framework {Function} jQuery or Zepro
     * @requires l10n {Function} Localization lib
     * @requires text!localization/localization {JSON} Localization JSON file
     * @example <div>{{l10n myVar}}</div>
     *
     * @function
     * @returns {function} localizationFn
     */
        function (Handlebars, $, l10n, dictionary) {
        "use strict";
 
        // TODO Lang sets should be separated
        String.toLocaleString($.parseJSON(dictionary));
        /**
         * @name module:localizationHelper#localizationFn
         * @description Provides localization for HBS templates
         * @memberof module:localizationHelper
         * @param str {String} string to be localized
         * @param [options] {Object} HBS context
         * @function
         * @inner
         */
        var localizationFn = function (str, options) {
            str = (str+"").toLocaleString();
            return options && options.fn ?
                    options.fn(str) :
                    str;
        };
 
        Handlebars.registerHelper('l10n', localizationFn);
        return localizationFn;
    });