'use strict'; /** * Collection of locale-specific utility functions on client-side When * constructor is called, locale (and BiDi config) is retrieved from and * set as members of this module. */ define([], function () { var _singletonInstance = null; var _LocaleUtil = null; _LocaleUtil = function LocaleUtil() { // Singleton if (_LocaleUtil.prototype._singletonInstance) { return _LocaleUtil.prototype._singletonInstance; } this.locale = this.getLocale(); this.isRTL = this.isLocaleRTL(this.locale); _LocaleUtil.prototype._singletonInstance = this; }; /** * Returns the user locale set to lang attribute from server-side. * This locale is matched from the supported locales and user's locale * preference * @return {string} Language code (e.g. en_CA) */ _LocaleUtil.prototype.getLocale = function () { if (!this.locale) { this.locale = document.documentElement.getAttribute('lang'); } return this.locale; }; /** * Checks if the locale passed in as the argument is a RTL (Right-to-Left) * language * @param {string} sLocale - Language code * @return {boolean} True, if the locale is RTL */ _LocaleUtil.prototype.isLocaleRTL = function (sLocale) { if (!this.isRTL) { var aRtlLocales = ['ar', 'he']; this.isRTL = aRtlLocales.indexOf(sLocale) >= 0; } return this.isRTL; }; var _static = { getInstance: function getInstance() { if (!_singletonInstance) { _singletonInstance = new _LocaleUtil(); } return _singletonInstance; } }; return _static.getInstance(); }); //# sourceMappingURL=LocaleUtil.js.map