@phensley/cldr-core
Version:
Core library for @phensley/cldr
63 lines • 2.3 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var StringBundle = /** @class */ (function () {
function StringBundle(_id, tag, strings, exceptions, index) {
this._id = _id;
this.tag = tag;
this.strings = strings;
this.exceptions = exceptions;
this.index = index;
// Empty string will select the preferred calendar for the region.
this._calendarSystem = '';
this._numberSystem = 'default';
var language = tag.language();
this._languageRegion = language + "-" + tag.region();
this._languageScript = language + "-" + tag.script();
// When bundle is constructed, see if there are unicode extensions for
// number and calendar systems.
for (var _i = 0, _a = tag.extensionSubtags('u'); _i < _a.length; _i++) {
var subtag = _a[_i];
if (subtag.startsWith('nu-')) {
this._numberSystem = subtag.substring(3);
}
else if (subtag.startsWith('ca-')) {
this._calendarSystem = subtag.substring(3);
}
}
}
StringBundle.prototype.id = function () {
return this._id;
};
StringBundle.prototype.language = function () {
return this.tag.language();
};
StringBundle.prototype.region = function () {
return this.tag.region();
};
StringBundle.prototype.languageScript = function () {
return this._languageScript;
};
StringBundle.prototype.languageRegion = function () {
return this._languageRegion;
};
StringBundle.prototype.calendarSystem = function () {
return this._calendarSystem;
};
StringBundle.prototype.numberSystem = function () {
return this._numberSystem;
};
StringBundle.prototype.get = function (offset) {
// If there is an exception index, attempt to resolve it.
if (this.index !== undefined) {
var i = this.index[offset];
if (i !== undefined) {
return this.exceptions[i] || '';
}
}
// Return the actual string.
return this.strings[offset] || '';
};
return StringBundle;
}());
exports.StringBundle = StringBundle;
//# sourceMappingURL=bundle.js.map