1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 'use strict';
- /**
- * Collection of locale-specific utility functions on client-side When
- * constructor is called, locale (and BiDi config) is retrieved from <html> 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 <html> 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
|