@eclipse-scout/core
Version:
Eclipse Scout runtime
87 lines • 3.97 kB
TypeScript
/// <reference types="jquery" />
import { Session, TextMap } from '../index';
export type TextMapType = Record<string, TextMap>;
export declare const texts: {
/**
* This default language is used whenever a new text is registered.
*/
defaultLanguage: string;
TEXT_KEY_REGEX: RegExp;
textsByLocale: TextMapType;
bootstrap(url: string | string[]): JQuery.Promise<any>;
/** @internal */
_setTextsByLocale(val: TextMapType): void;
/** @internal */
_handleBootstrapResponse(url: string, data: any): void;
init(model: Record<string, Record<string, string>>): void;
/**
* Links the texts of the given languageTag to make parent lookup possible (e.g. look first in de-CH, then in de, then in default).
*/
link(languageTag: string): void;
/**
* Creates an array containing all relevant tags.
* <p>
* Examples:<br>
* - 'de-CH' generates the array: ['de-CH', 'de', 'default']
* - 'de' generates the array: ['de', 'default']
* - 'default' generates the array: ['default']
*/
createOrderedLanguageTags(languageTag: string): string[];
/**
* Returns the (modifiable) TextMap for the given language tag.
* If no TextMap exists for the languageTag given, a new empty map is created.
* @returns the TextMap for the given languageTag. Never returns null or undefined.
*/
get(languageTag: string): TextMap;
/** @internal */
_get(languageTag: string): TextMap;
/**
* Registers the text map for the given locale.
* If there already is a text map registered for that locale, it will be replaced, meaning existing texts for that locale are deleted.
* @internal
*/
_put(languageTag: string, textMap: TextMap): void;
/**
* Extracts NLS texts from the DOM tree. Texts are expected in the following format:
*
* <scout-text data-key="..." data-value="..." />
*
* This method returns a map with all found texts. It must be called before scout.prepareDOM()
* is called, as that method removes all <scout-text> tags.
*/
readFromDOM(): Record<string, string>;
/**
* Converts a key to the form '${textKey:AKey}'.
* @param key to convert (e.g. 'AKey')
* @returns text containing the text key like '${textKey:AKey}'.
*/
buildKey(key: string): string;
/**
* @param value text which contains a text key like '${textKey:AKey}'.
* @returns the resolved key or the unchanged value if the text key could not be extracted.
*/
resolveKey(value: string): string;
/**
* @param value text which contains a text key like '${textKey:AKey}'.
* @param languageTag the languageTag to use for the text lookup with the resolved key.
* @returns the resolved text in the given language or the unchanged text if the text key could not be extracted.
*/
resolveText(value: string, languageTag: string): string;
/**
* Utility function to easily replace an object property which contains a text key like '${textKey:AKey}'.
*
* @param object object having a text property which contains a text-key
* @param [textProperty] name of the property where a text-key should be replaced by a text. By default, 'text' is used as property name.
* @param [session] can be undefined when given 'object' has a session property, otherwise mandatory
*/
resolveTextProperty(object: any, textProperty?: string, session?: Session): void;
/**
* Registers a texts map for a text key.
* The texts for the default language specified by {@link texts.defaultLanguage} are registered as default texts.
*
* @param key the text key under which the given textsArg map will be registered.
* @param textsArg an object with the languageTag as key and the translated text as value
*/
registerTexts(key: string, textsArg: Record<string, string>): void;
};
//# sourceMappingURL=texts.d.ts.map