angular-l10n
Version:
Angular library to translate texts, dates and numbers
78 lines (77 loc) • 3.88 kB
TypeScript
import { L10nLocale, L10nDateTimeFormatOptions, L10nNumberFormatOptions } from '../models/types';
import { L10nConfig } from '../models/l10n-config';
import { L10nTranslationService } from './l10n-translation.service';
import * as i0 from "@angular/core";
export declare class L10nIntlService {
private config;
private locale;
private translation;
constructor(config: L10nConfig, locale: L10nLocale, translation: L10nTranslationService);
/**
* Formats a date.
* @param value A date, a number (milliseconds since UTC epoch) or an ISO 8601 string
* @param options A L10n or Intl DateTimeFormatOptions object
* @param language The current language
* @param timeZone The current time zone
*/
formatDate(value: any, options?: L10nDateTimeFormatOptions, language?: string, timeZone?: string | undefined): string;
/**
* Formats a number.
* @param value A number or a string
* @param options A L10n or Intl NumberFormatOptions object
* @param language The current language
* @param currency The current currency
* @param convert An optional function to convert the value, with value and locale in the signature.
* For example:
* ```
* const convert = (value: number, locale: L10nLocale) => { return ... };
* ```
* @param convertParams Optional parameters for the convert function
*/
formatNumber(value: any, options?: L10nNumberFormatOptions, language?: string, currency?: string | undefined, convert?: (value: number, locale: L10nLocale, params: any) => number, convertParams?: any): string;
/**
* Formats a relative time.
* @param value A negative (or positive) number
* @param unit An Intl RelativeTimeFormatUnit value
* @param options An Intl RelativeTimeFormatOptions object
* @param language The current language
*/
formatRelativeTime(value: any, unit: Intl.RelativeTimeFormatUnit, options?: Intl.RelativeTimeFormatOptions, language?: string): string;
/**
* Gets the plural by a number.
* The 'value' is passed as a parameter to the translation function.
* @param value The number to get the plural
* @param prefix Optional prefix for the key
* @param options An Intl PluralRulesOptions object
* @param language The current language
*/
plural(value: any, prefix?: string, options?: Intl.PluralRulesOptions, language?: string): string;
/**
* Returns translation of language, region, script or currency display names
* @param code ISO code of language, region, script or currency
* @param options An Intl DisplayNamesOptions object
* @param language The current language
*/
displayNames(code: string, options: Intl.DisplayNamesOptions, language?: string): string;
getCurrencySymbol(locale?: L10nLocale): string | undefined;
/**
* Compares two keys by the value of translation.
* @param key1 First key to compare
* @param key1 Second key to compare
* @param options An Intl CollatorOptions object
* @param language The current language
* @return A negative value if the value of translation of key1 comes before the value of translation of key2;
* a positive value if key1 comes after key2;
* 0 if they are considered equal or Intl.Collator is not supported
*/
compare(key1: string, key2: string, options?: Intl.CollatorOptions, language?: string): number;
/**
* Returns the representation of a list.
* @param list An array of keys
* @param options An Intl ListFormatOptions object
* @param language The current language
*/
list(list: string[], options?: Intl.ListFormatOptions, language?: string): string;
static ɵfac: i0.ɵɵFactoryDeclaration<L10nIntlService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<L10nIntlService>;
}