PHP Class Polyglot\Services\Lang

Inheritance: extends Illuminate\Translation\Translator
Show file Open project: anahkiasen/polyglot

Protected Properties

Property Type Description
$app Illuminate\Container\Container The IoC Container
$domain string The translation domain
$encoding string The localization encoding

Public Methods

Method Description
__construct ( Illuminate\Container\Container $app ) Build the language class
active ( string $locale ) : boolean Whether a given language is the current one
defaultLocale ( ) : string Get the default locale
fallbackLocale ( ) : string Get the fallback locale
get ( string $key, array $replace = [], string $locale = null ) : string Get the translation for the given key, or fallback to fallback locale
getAvailable ( ) : array Get all available languages
getDomain ( ) : string Get the translation domain
getEncoding ( boolean $slug = false ) : string Get the encoding
getInternalLocale ( ) : string Get the internal locale
getLocaleFolder ( string $locale ) : string Get the folder where a locale's translations reside
getShortInternalLocale ( ) : string Get the short version of the internal locale
getTranslationsFolder ( string $subfolder = null ) : string Get the folder where the translations reside
sanitize ( string $locale = null ) : string Sanitize a locale
setInternalLocale ( string | boolean $locale = false ) : string Sets the locale according to the current language
setLocale ( string $locale ) : string Change the current language
shortToLongLocale ( string $locale ) : string Translate a short locale to long (en => en_US)
valid ( string $locale ) : boolean Check whether a language is valid or not

Method Details

__construct() public method

Build the language class
public __construct ( Illuminate\Container\Container $app )
$app Illuminate\Container\Container

active() public method

Whether a given language is the current one
public active ( string $locale ) : boolean
$locale string The language to check
return boolean

defaultLocale() public method

Get the default locale
public defaultLocale ( ) : string
return string

fallbackLocale() public method

Get the fallback locale
public fallbackLocale ( ) : string
return string

get() public method

Get the translation for the given key, or fallback to fallback locale
public get ( string $key, array $replace = [], string $locale = null ) : string
$key string
$replace array
$locale string
return string

getAvailable() public method

Get all available languages
public getAvailable ( ) : array
return array An array of languages

getDomain() public method

Get the translation domain
public getDomain ( ) : string
return string

getEncoding() public method

Get the encoding
public getEncoding ( boolean $slug = false ) : string
$slug boolean
return string

getInternalLocale() public method

Get the internal locale
public getInternalLocale ( ) : string
return string

getLocaleFolder() public method

Get the folder where a locale's translations reside
public getLocaleFolder ( string $locale ) : string
$locale string
return string

getShortInternalLocale() public method

Get the short version of the internal locale
public getShortInternalLocale ( ) : string
return string

getTranslationsFolder() public method

Get the folder where the translations reside
public getTranslationsFolder ( string $subfolder = null ) : string
$subfolder string
return string

sanitize() public method

Sanitize a locale
public sanitize ( string $locale = null ) : string
$locale string
return string

setInternalLocale() public method

Sets the locale according to the current language
public setInternalLocale ( string | boolean $locale = false ) : string
$locale string | boolean A language string to use
return string

setLocale() public method

Change the current language
public setLocale ( string $locale ) : string
$locale string The language to change to
return string

shortToLongLocale() public method

Translate a short locale to long (en => en_US)
public shortToLongLocale ( string $locale ) : string
$locale string
return string

valid() public method

Check whether a language is valid or not
public valid ( string $locale ) : boolean
$locale string The language
return boolean

Property Details

$app protected property

The IoC Container
protected Container,Illuminate\Container $app
return Illuminate\Container\Container

$domain protected property

The translation domain
protected string $domain
return string

$encoding protected property

The localization encoding
protected string $encoding
return string