@singleton-i18n/js-core-sdk-server
Version:
A JavaScript Singleton client library for internationalization and localization that leverage data from Singleton service. The library works both for the browser and as a Node.js module.
30 lines (29 loc) • 846 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Plural = void 0;
/*
* Copyright 2019-2024 VMware, Inc.
* SPDX-License-Identifier: EPL-2.0
*/
const plurals_func_1 = require("./plurals.func");
class Plural {
constructor() { }
resolveLocale(locale) {
let lang = locale;
do {
if (plurals_func_1.PLURALFUNCS[lang]) {
return lang;
}
else if (plurals_func_1.PLURALFUNCS[lang.toLocaleLowerCase()]) {
return lang.toLocaleLowerCase();
}
lang = locale.trim().replace(/-[a-zA-Z]+$/, '');
} while (lang);
return null;
}
getFunc(locale) {
this._locale = this.resolveLocale(locale);
return plurals_func_1.PLURALFUNCS[this._locale];
}
}
exports.Plural = Plural;