UNPKG

lc-i18n

Version:

Lockcommerce Translation Service

68 lines 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetLocale = exports.GetLocaleId = exports.GetI18n = exports.SetLocale = exports.T = exports.SetDefaultLocaleConfiguration = void 0; // @ts-ignore var I18n = require("i18n-js"); /** * * Fall Back on Missing Translation () * @param key * @returns Translation with custom format */ I18n.missingTranslation = function (key) { return key; }; /** * * Translate Static Keys () .. check locales folder in the root * @param key * @returns Translation */ exports.SetDefaultLocaleConfiguration = function (tConfiguration) { I18n.defaultLocale = tConfiguration.DefaultLocale; I18n.locale = tConfiguration.Locale; if (typeof tConfiguration.MissingTranslation === 'string') { I18n.missingTranslation = function (key) { return tConfiguration.MissingTranslation + key; }; } }; /** * * Translate Static Keys () .. check locales folder in the root * @param key * @returns Translation */ exports.T = function (key) { return I18n.t(key); }; exports.SetLocale = function (lang) { if (lang === void 0) { lang = 'en'; } I18n.defaultLocale = lang; I18n.locale = lang; }; /** * * Get Current Instant () * * @returns i18n */ exports.GetI18n = function () { return I18n; }; /** * * Not used For now * * @returns locale */ exports.GetLocaleId = function () { if (I18n.locale == 'en') return '1'; return '2'; }; /** * * Get Current Local () * * @returns locale */ exports.GetLocale = function () { return I18n.locale; }; exports.default = I18n; //# sourceMappingURL=index.js.map