@iobroker/adapter-react-v5
Version:
React components to develop ioBroker interfaces with react.
85 lines (84 loc) • 2.9 kB
TypeScript
/**
* Copyright 2018-2024 Denis Haev (bluefox) <dogafox@gmail.com>
*
* MIT License
*
*/
declare global {
interface Window {
sysLang: ioBroker.Languages;
i18nShow: (filter: string | RegExp) => void;
i18nDisableWarning: (disable: boolean) => void;
}
}
type I18nWordDictionary = Record<ioBroker.Languages, string>;
type I18nWordsDictionary = Record<string, I18nWordDictionary>;
type I18nOneLanguageDictionary = Record<string, string>;
type I18nDictionary = {
[lang in ioBroker.Languages]?: I18nOneLanguageDictionary;
};
type I18nWordsWithPrefix = I18nDictionary & {
prefix?: string;
};
/**
* Translation string management.
*/
export declare class I18n {
/** List of all languages with their translations. */
static translations: I18nDictionary;
/** List of unknown translations during development. */
static unknownTranslations: string[];
/** The currently displayed language. */
static lang: ioBroker.Languages;
static _disableWarning: boolean;
/**
* Set the language to display
*
* @param lang The default language for translations.
*/
static setLanguage(lang: ioBroker.Languages): void;
/**
* Add translations
* User can provide two types of structures:
* - {"word1": "translated word1", "word2": "translated word2"}, but in this case the lang must be provided
* - {"word1": {"en": "translated en word1", "de": "translated de word1"}, "word2": {"en": "translated en word2", "de": "translated de word2"}}, but no lang must be provided
*
* @param words additional words for specific language
* @param lang language for the words
*/
static extendTranslations(words: I18nWordsWithPrefix | I18nOneLanguageDictionary | I18nWordsDictionary, lang?: ioBroker.Languages): void;
/**
* Sets all translations (in all languages).
*
* @param translations The translations to add.
*/
static setTranslations(translations: I18nDictionary): void;
/**
* Get the currently chosen language.
*
* @returns The current language.
*/
static getLanguage(): ioBroker.Languages;
/**
* Translate the given string to the selected language
*
* @param word The (key) word to look up the string.
* @param args Optional arguments which will replace the first (second, third, ...) occurrences of %s
*/
static t(word: string, ...args: any[]): string;
/**
* Show non-translated words
* Required during development
*
* @param filter The filter to apply to the list of non-translated words.
*/
static i18nShow(filter?: string | RegExp): void;
/**
* Disable warning about non-translated words
* Required during development
*
* @param disable Whether to disable the warning
*/
static disableWarning(disable: boolean): void;
}
export {};