@progress/kendo-react-intl
Version:
React Internationalization package provides services for parsing and formatting of dates and numbers. KendoReact Internationalization package
36 lines (35 loc) • 1.41 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 a } from "./messages.mjs";
class s {
/**
* Creates a new LocalizationService instance.
*
* @param language The language code for localization.
*/
constructor(t) {
if (this.language = t, t === "" && process.env.NODE_ENV !== "production")
throw "Language should not be an empty string";
}
/* eslint-disable max-len */
/**
* 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.
*/
// tslint:enable:max-line-length
toLanguageString(t, e) {
return this.language && a[this.language] && a[this.language].hasOwnProperty(t) ? a[this.language][t] : e;
}
}
export {
s as LocalizationService
};