turbogui-angular
Version:
A library that tries to help with the most common user interface elements on several frameworks and platforms
49 lines • 2.82 kB
TypeScript
import { TranslationManager } from '../managers/TranslationManager';
import * as i0 from "@angular/core";
/**
* Fully featured translation service to be used with any application that requires text internationalization.
* It is defined as an abstract service class so it must be extended in our application. This way we can
* write custom methods to extend the functionality of this class if needed.
*
* @see TranslationBaseManager for more information about the methods and properties available.
*/
export declare abstract class LocalesBaseService extends TranslationManager {
/**
* Key used to store the user preferred locales in local storage
*/
private readonly _storageKey;
/**
* Try to detect the list of locales (sorted by preference) that are defined by the user
* at the browser setup and are also available for translation at this class.
*
* First we will check if there is a stored local storage value that was defined on a previous session.
* If found, all the locales stored there that are also available on this class will be returned.
*
* If no locales could be found from previous sessions, the method will check the browser default language and the
* browser languages list. All matching languages that are also listed on availableLocales will be returned, sorted
* by the browser preference.
*
* Finally, if nothing is found, the first locale from the class availableLocales will be returned.
*
* @returns A list of locales that can be used as a translation priority list
*/
getAvailableLocalesFromBrowser(): string[];
/**
* Initializes the translation system by loading and parsing bundle files from the specified translations path.
* After the promise finishes, the class will contain all the translation data and will be ready to translate any
* provided key.
*
* @param locales An array of locale codes (['en_US', 'es_ES', 'fr_FR', ...]) to load from the url response.
* The order of this array is not important for translation priority.
*
* @param url - Url where the translations are found. The response must be a Json with the expected structure:
* { library_name: { bundle_name: { locale_code: { key1: "translation1", key2: "translation2" } } } ... }
*
* @return A promise that will resolve if the translations get correctly loaded, or reject with an error if load fails
*/
loadLocalesFromUrl(locales: string[], url: string): Promise<void>;
setTranslationPriority(localesOrLanguages: string[]): string[];
static ɵfac: i0.ɵɵFactoryDeclaration<LocalesBaseService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<LocalesBaseService>;
}
//# sourceMappingURL=locales-base.service.d.ts.map