class Illuminate / Translation / Translator
You are viewing an older version of the documentation. For the latest, please visit master documentation.

Translator

Extends

Implements

Uses

Properties

protected

$loader Loader

The loader implementation.

Default: null
protected

$locale string

The default locale being used by the translator.

Default: null
protected

$fallback string

The fallback locale used by the translator.

Default: null
protected

$loaded array

The array of loaded translation groups.

Default: []
protected

$selector MessageSelector

The message selector.

Default: null

Methods

public

__construct ( Loader $loader , $locale ) : void

Create a new translator instance.

Parameters

public

hasForLocale ( $key , $locale ) : bool

Determine if a translation exists for a given locale.

Parameters

  • $key string
  • $locale string|null
public

has ( $key , $locale , $fallback ) : bool

Determine if a translation exists.

Parameters

  • $key string
  • $locale string|null
  • $fallback bool
public

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
public

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
protected

localeForChoice ( $locale ) : string

Get the proper locale for a choice operation.

Parameters

  • $locale string|null
protected

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
protected

makeReplacements ( $line , array $replace ) : string

Make the place-holder replacements on a line.

Parameters

  • $line string
  • $replace array
public

addLines ( array $lines , $locale , $namespace ) : void

Add translation lines to the given locale.

Parameters

  • $lines array
  • $locale string
  • $namespace string
public

load ( $namespace , $group , $locale ) : void

Load the specified language group.

Parameters

  • $namespace string
  • $group string
  • $locale string
protected

isLoaded ( $namespace , $group , $locale ) : bool

Determine if the given group has been loaded.

Parameters

  • $namespace string
  • $group string
  • $locale string
public

addNamespace ( $namespace , $hint ) : void

Add a new namespace to the loader.

Parameters

  • $namespace string
  • $hint string
public

addJsonPath ( $path ) : void

Add a new JSON path to the loader.

Parameters

  • $path string
public

parseKey ( $key ) : array

Parse a key into namespace, group, and item.

Parameters

  • $key string
protected

localeArray ( $locale ) : array

Get the array of locales to be checked.

Parameters

  • $locale string|null
public

getSelector ( ) : MessageSelector

Get the message selector instance.

public

setSelector ( MessageSelector $selector ) : void

Set the message selector instance.

Parameters

public

getLoader ( ) : Loader

Get the language line loader implementation.

public

locale ( ) : string

Get the default locale being used.

public

getLocale ( ) : string

Get the default locale being used.

public

setLocale ( $locale ) : void

Set the default locale.

Parameters

  • $locale string
public

getFallback ( ) : string

Get the fallback locale being used.

public

setFallback ( $fallback ) : void

Set the fallback locale being used.

Parameters

  • $fallback string
public

setLoaded ( array $loaded ) : void

Set the loaded translation groups.

Parameters

  • $loaded array