@progress/kendo-vue-intl
Version:
31 lines (30 loc) • 1.36 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import { messages as e } from "./messages.mjs";
class i {
constructor(t) {
if (this.language = t, t === "" && process.env.NODE_ENV !== "production")
throw "Language should not be an empty string";
}
/**
* Provides a string based on a key for the current language.
* When no string for the current language is available under this key,
* the `defaultValue` is returned.
*
* @param key - The key which identifies the string for the current language.
* @param defaultValue - The default value which will be returned when no string
* for the current language is available under the key.
* @return - The string for the current language.
*/
toLanguageString(t, s) {
return this.language && e[this.language] && e[this.language].hasOwnProperty(t) ? e[this.language][t] : Object.keys(this)[0] && e[Object.values(this)[0]] && e[Object.values(this)[0]].hasOwnProperty(t) ? e[Object.values(this)[0]][t] : s;
}
}
export {
i as LocalizationService
};