Translator
Extends
Implements
Uses
Properties
$locale string
The default locale being used by the translator.
$fallback string
The fallback locale used by the translator.
$loaded array
The array of loaded translation groups.
Methods
__construct ( Loader $loader , $locale ) : void
Create a new translator instance.
Parameters
- $loader Loader
- $locale string
hasForLocale ( $key , $locale ) : bool
Determine if a translation exists for a given locale.
Parameters
- $key string
- $locale string|null
has ( $key , $locale , $fallback ) : bool
Determine if a translation exists.
Parameters
- $key string
- $locale string|null
- $fallback bool
get ( $key , array $replace , $locale , $fallback ) : string|array
Get the translation for the given key.
Parameters
- $key string
- $replace array
- $locale string|null
- $fallback bool
choice ( $key , $number , array $replace , $locale ) : string
Get a translation according to an integer value.
Parameters
- $key string
- $number Countable |int|array
- $replace array
- $locale string|null
localeForChoice ( $locale ) : string
Get the proper locale for a choice operation.
Parameters
- $locale string|null
getLine ( $namespace , $group , $locale , $item , array $replace ) : string|array|null
Retrieve a language line out the loaded array.
Parameters
- $namespace string
- $group string
- $locale string
- $item string
- $replace array
makeReplacements ( $line , array $replace ) : string
Make the place-holder replacements on a line.
Parameters
- $line string
- $replace array
addLines ( array $lines , $locale , $namespace ) : void
Add translation lines to the given locale.
Parameters
- $lines array
- $locale string
- $namespace string
load ( $namespace , $group , $locale ) : void
Load the specified language group.
Parameters
- $namespace string
- $group string
- $locale string
isLoaded ( $namespace , $group , $locale ) : bool
Determine if the given group has been loaded.
Parameters
- $namespace string
- $group string
- $locale string
addNamespace ( $namespace , $hint ) : void
Add a new namespace to the loader.
Parameters
- $namespace string
- $hint string
addJsonPath ( $path ) : void
Add a new JSON path to the loader.
Parameters
- $path string
parseKey ( $key ) : array
Parse a key into namespace, group, and item.
Parameters
- $key string
localeArray ( $locale ) : array
Get the array of locales to be checked.
Parameters
- $locale string|null
setSelector ( MessageSelector $selector ) : void
Set the message selector instance.
Parameters
- $selector MessageSelector
locale ( ) : string
Get the default locale being used.
getLocale ( ) : string
Get the default locale being used.
setLocale ( $locale ) : void
Set the default locale.
Parameters
- $locale string
getFallback ( ) : string
Get the fallback locale being used.
setFallback ( $fallback ) : void
Set the fallback locale being used.
Parameters
- $fallback string
setLoaded ( array $loaded ) : void
Set the loaded translation groups.
Parameters
- $loaded array