TranslationService
in package
Table of Contents
Properties
- $activeInstance : TranslationService|null
- $currencyFormatter : NumberFormatter|null
- $locale : string
- $providers : array<string|int, mixed>|null
- $translations : array<string|int, mixed>
Methods
- __construct() : mixed
- buildDomain() : void
- formatAssociatedLocales() : array<string|int, string>
- Format associated locales, "en_US" will return ["en_US"=>"en_US", "en"=>"en_US"]
- formatCurrency() : string
- formatNumber() : string
- getActive() : TranslationService
- getActiveLocale() : string
- getCurrencyFormatter() : NumberFormatter|null
- getDefaultLocale() : string
- getDomainTranslations() : array<string|int, mixed>
- getFormatter() : NumberFormatter
- getHttpLocale() : string
- getInstance() : TranslationService
- getLocale() : string
- getProviders() : array<string|int, AbstractTranslationProvider>
- getSupportedProviders() : array<string|int, AbstractTranslationProvider>
- getTranslation() : string|null
- guessAvailableDomains() : array<string|int, string>
- guessAvailableLocales() : array<string|int, string>
- info() : string
- initializeProviders() : void
- isDomainBuilt() : bool
- parseNumber() : float
- requireIntl() : void
- setActive() : void
- setup() : void
- supportsIntl() : bool
- translate() : string|null
- formatTranslations() : array<string|int, mixed>
Properties
$activeInstance
protected
static TranslationService|null
$activeInstance
= null
$currencyFormatter
protected
NumberFormatter|null
$currencyFormatter
= null
$locale
protected
string
$locale
$providers
protected
static array<string|int, mixed>|null
$providers
= null
$translations
protected
array<string|int, mixed>
$translations
= []
Methods
__construct()
public
__construct(string $locale) : mixed
Parameters
- $locale : string
buildDomain()
public
buildDomain(string $domain[, bool $force = false ]) : void
Parameters
- $domain : string
- $force : bool = false
formatAssociatedLocales()
Format associated locales, "en_US" will return ["en_US"=>"en_US", "en"=>"en_US"]
public
static formatAssociatedLocales(array<string|int, mixed> $locales) : array<string|int, string>
Parameters
- $locales : array<string|int, mixed>
Return values
array<string|int, string>formatCurrency()
public
formatCurrency(float $value, string $currency[, bool|int $decimals = true ]) : string
Parameters
- $value : float
- $currency : string
- $decimals : bool|int = true
Return values
stringformatNumber()
public
formatNumber(int|float $value[, int $decimals = 0 ]) : string
Parameters
- $value : int|float
- $decimals : int = 0
Return values
stringgetActive()
public
static getActive() : TranslationService
Return values
TranslationServicegetActiveLocale()
public
static getActiveLocale() : string
Return values
stringgetCurrencyFormatter()
public
getCurrencyFormatter() : NumberFormatter|null
Return values
NumberFormatter|nullgetDefaultLocale()
public
static getDefaultLocale() : string
Return values
stringgetDomainTranslations()
public
getDomainTranslations(string $domain) : array<string|int, mixed>
Parameters
- $domain : string
Return values
array<string|int, mixed>getFormatter()
public
getFormatter(int $style[, string|null $pattern = null ]) : NumberFormatter
Parameters
- $style : int
- $pattern : string|null = null
Tags
Return values
NumberFormattergetHttpLocale()
public
getHttpLocale() : string
Return values
string —Locale as per RFC 4646
getInstance()
public
static getInstance(string $locale) : TranslationService
Parameters
- $locale : string
Return values
TranslationServicegetLocale()
public
getLocale() : string
Return values
stringgetProviders()
public
static getProviders() : array<string|int, AbstractTranslationProvider>
Return values
array<string|int, AbstractTranslationProvider>getSupportedProviders()
public
static getSupportedProviders() : array<string|int, AbstractTranslationProvider>
Return values
array<string|int, AbstractTranslationProvider>getTranslation()
public
getTranslation(string $key, string $domain[, bool $resolveLinks = false ]) : string|null
Parameters
- $key : string
- $domain : string
- $resolveLinks : bool = false
Return values
string|nullguessAvailableDomains()
public
guessAvailableDomains() : array<string|int, string>
Return values
array<string|int, string>guessAvailableLocales()
public
static guessAvailableLocales() : array<string|int, string>
Return values
array<string|int, string>info()
public
info(string $key) : string
Parameters
- $key : string
Return values
stringinitializeProviders()
public
static initializeProviders() : void
isDomainBuilt()
public
isDomainBuilt(string $domain) : bool
Parameters
- $domain : string
Return values
boolparseNumber()
public
parseNumber(string $value) : float
Parameters
- $value : string
Return values
floatrequireIntl()
public
static requireIntl() : void
setActive()
public
setActive() : void
setup()
public
setup() : void
supportsIntl()
public
static supportsIntl() : bool
Return values
booltranslate()
public
translate(string $key[, string|array<string|int, mixed>|null $domain = 'global' ][, array<string|int, mixed> $parameters = [] ][, bool $nullable = false ]) : string|null
Parameters
- $key : string
- $domain : string|array<string|int, mixed>|null = 'global'
- $parameters : array<string|int, mixed> = []
- $nullable : bool = false
Return values
string|nullformatTranslations()
protected
formatTranslations(array<string|int, mixed> $translations[, string $path = '' ]) : array<string|int, mixed>
Parameters
- $translations : array<string|int, mixed>
- $path : string = ''