// Type definitions for the Anu-Localization-package // Written by: // Simon Owerien (simon128.github@outlook.com) declare namespace AnuLocalization { /** * This class provides information to configure the localization service. */ export class LocalizationConfiguration { /** * The fallback language to use if the priorized languages are not supported. */ public FallbackLanguage: string; /** * The string which identifies the key which should be translated. The key has to be inside of the first group. */ public RegexString: string; /** * The languages the web application supports. */ public LocalizationLanguages: LocalizationLanguage[]; /** * Loads the LocalizationConfiguration of an configuration-file. * @param path The path to the localization-file. */ public static LoadLocalizationConfiguration(path: string): LocalizationConfiguration; } /** * This error happens if the translation failed. */ export class LocalizationError extends Error { /** * Creates an instance of the error. * @param message The message of the error. */ constructor(message: string); } /** * This class provides information for the localization service * to translate supported languages. */ export class LocalizationLanguage { /** * The key of the language. */ public Key: string; /** * The path to the file you can find the translations in. */ public FilePath: string; /** * The key in the http-header which identifies this language. */ public HttpLanguageKey: string; /** * The priority of the language. */ public Priority: number; /** * Finds a language in an array of languages by the http key. * @param languages The languages where the sought language should be in. * @param httpLanguageKey The key of the language which is searched. */ public static FindByHttpKey(languages: LocalizationLanguage[], httpLanguageKey: string): LocalizationLanguage; } /** * An class which provides information to translate into different languages. */ export class LocalizationObject { /** * The key. */ public Key: string; /** * The translations. */ public Translations: TranslationObject[]; /** * Loads the LocalizationObjects of an localization-file. * @param path The path to the localization-file. */ public static LoadLocalizationObjects(path: string): LocalizationObject[]; } /** * A service which provides localization for the web application. */ export class LocalizationService { private _configuration: LocalizationConfiguration; /** * Creates an instance of the service. * @param configuration The configuration of the localization. */ public constructor(configuration: LocalizationConfiguration); /** * Translates the complete string. * @param stringForTranslation The string which should be translated. * @param languages The languages for which the translation should be found. * @param localizationObjects The objects that should contain the translations. */ public TranslateWholeString(stringForTranslation: string, languages: LocalizationLanguage[], localizationObjects: LocalizationObject[]) : string; /** * Translates a key. * @param key The key which should be translated. * @param languages The languages for which the translation should be found. * @param localizationObjects The objects that should contain the translation. */ public Translate(key: string, languages: LocalizationLanguage[], localizationObjects: LocalizationObject[]): string; } /** * An class which provides information about the relationship between * a language key and its translation of a key. */ export class TranslationObject { /** * The language key. */ public LanguageKey: string; /** * The translation */ public Translation: string; } } declare module "anu-localization" { export = AnuLocalization; }