UNPKG

angular-l10n

Version:

An Angular library to translate messages, dates and numbers

129 lines 4.38 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ var DefaultLocale = /** @class */ (function () { function DefaultLocale() { } Object.defineProperty(DefaultLocale.prototype, "value", { get: /** * @return {?} */ function () { return this.formattedValue; }, set: /** * @param {?} defaultLocale * @return {?} */ function (defaultLocale) { this.formattedValue = defaultLocale; this.parseValue(); }, enumerable: true, configurable: true }); /** * @param {?} languageCode * @param {?=} countryCode * @param {?=} scriptCode * @param {?=} numberingSystem * @param {?=} calendar * @return {?} */ DefaultLocale.prototype.build = /** * @param {?} languageCode * @param {?=} countryCode * @param {?=} scriptCode * @param {?=} numberingSystem * @param {?=} calendar * @return {?} */ function (languageCode, countryCode, scriptCode, numberingSystem, calendar) { this.languageCode = languageCode; this.scriptCode = scriptCode; this.countryCode = countryCode; this.numberingSystem = numberingSystem; this.calendar = calendar; /** @type {?} */ var value = languageCode; value += !!scriptCode ? "-" + scriptCode : ""; value += !!countryCode ? "-" + countryCode : ""; // Adds the 'u' (Unicode) extension. value += (!!numberingSystem || !!calendar) ? "-u" : ""; value += !!numberingSystem ? "-nu-" + numberingSystem : ""; value += !!calendar ? "-ca-" + calendar : ""; this.formattedValue = value; }; /** * @return {?} */ DefaultLocale.prototype.parseValue = /** * @return {?} */ function () { if (!!this.value) { /** @type {?} */ var value = this.value; // Looks for the 'u' (Unicode) extension. /** @type {?} */ var index = value.search("-u"); if (index != -1) { /** @type {?} */ var extensions = value.substring(index + 1).split("-"); switch (extensions.length) { case 3: if (extensions[1] == "nu") { this.numberingSystem = extensions[2]; this.calendar = undefined; } else if (extensions[1] == "ca") { this.numberingSystem = undefined; this.calendar = extensions[2]; } break; default: this.numberingSystem = extensions[2]; this.calendar = extensions[4]; } // Extracts the codes. value = value.substring(0, index); } /** @type {?} */ var codes = value.split("-"); switch (codes.length) { case 1: this.languageCode = codes[0]; this.scriptCode = undefined; this.countryCode = undefined; break; case 2: this.languageCode = codes[0]; this.scriptCode = undefined; this.countryCode = codes[1]; break; default: this.languageCode = codes[0]; this.scriptCode = codes[1]; this.countryCode = codes[2]; } } }; return DefaultLocale; }()); export { DefaultLocale }; if (false) { /** @type {?} */ DefaultLocale.prototype.languageCode; /** @type {?} */ DefaultLocale.prototype.scriptCode; /** @type {?} */ DefaultLocale.prototype.countryCode; /** @type {?} */ DefaultLocale.prototype.numberingSystem; /** @type {?} */ DefaultLocale.prototype.calendar; /** @type {?} */ DefaultLocale.prototype.formattedValue; } //# sourceMappingURL=default-locale.js.map