UNPKG

@iobroker/adapter-react

Version:

React classes to develop admin interfaces for ioBroker with react.

82 lines (81 loc) 2.88 kB
export default I18n; /*** * Copyright 2018-2022 bluefox <dogafox@gmail.com> * * MIT License * ***/ /** * Translation string management. */ declare class I18n { /** * List of all languages with their translations. * @type {{ [lang in ioBroker.Languages]?: Record<string, string>; }} */ static translations: { fr?: Record<string, string>; pt?: Record<string, string>; pl?: Record<string, string>; en?: Record<string, string>; de?: Record<string, string>; ru?: Record<string, string>; nl?: Record<string, string>; it?: Record<string, string>; es?: Record<string, string>; "zh-cn"?: Record<string, string>; }; /** * The currently displayed language. * @type {ioBroker.Languages} */ static lang: ioBroker.Languages; static _disableWarning: boolean; /** * Set the language to display. * @param {ioBroker.Languages} lang */ 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 {object} words additional words for specific language * @param {ioBroker.Languages} lang */ static extendTranslations(words: object, lang: ioBroker.Languages): void; /** * Sets all translations (in all languages). * @param {{ [lang in ioBroker.Languages]?: Record<string, string>; }} translations */ static setTranslations(translations: { fr?: Record<string, string>; pt?: Record<string, string>; pl?: Record<string, string>; en?: Record<string, string>; de?: Record<string, string>; ru?: Record<string, string>; nl?: Record<string, string>; it?: Record<string, string>; es?: Record<string, string>; "zh-cn"?: Record<string, string>; }): void; /** * Get the currently chosen language. * @returns {ioBroker.Languages} The current language. */ static getLanguage(): ioBroker.Languages; /** * Translate the given string to the selected language. * @param {string} word The (key) word to look up the string. * @param {string[]} args Optional arguments which will replace the first (second, third, ...) occurrences of %s */ static t(word: string, ...args: string[]): string; /** * Disable warning about non-translated words * Required during development * @param {boolean} disable Do the warning should be disabled */ static disableWarning(disable: boolean): void; }