PHP Класс i18n, php-i18n

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$appliedLang
$cacheFilePath
$cachePath string Cache file path This is the path for all the cache files. Best is an empty directory with no other files in it.
$fallbackLang string Remember to create a language file for the fallback!!
$filePath string Language file path This is the path for the language files. You must use the '{LANGUAGE}' placeholder for the language or the script wont find any language files.
$forcedLang string Forced language If you want to force a specific language define it here.
$isInitialized
$langFilePath
$mergeFallback boolean Merge in fallback language Whether to merge current language's strings with the strings of the fallback language ($fallbackLang).
$prefix string The class name of the compiled class that contains the translated texts.
$sectionSeperator string For example, if you have a string 'greeting' in a section 'welcomepage' you will can access it via 'L::welcomepage_greeting'. If you changed it to 'ABC' you could access your string via 'L::welcomepageABCgreeting'
$userLangs array Normally, if you use the getUserLangs-method this array will be filled in like this: 1. Forced language 2. Language in $_GET['lang'] 3. Language in $_SESSION['lang'] 4. Fallback language

Открытые методы

Метод Описание
__construct ( $filePath = NULL, $cachePath = NULL, $fallbackLang = NULL, $prefix = NULL ) Constructor The constructor sets all important settings. All params are optional, you can set the options via extra functions too.
getAppliedLang ( )
getCachePath ( )
getFallbackLang ( )
getUserLangs ( ) : array getUserLangs() Returns the user languages Normally it returns an array like this: 1. Forced language 2. Language in $_GET['lang'] 3. Language in $_SESSION['lang'] 4. HTTP_ACCEPT_LANGUAGE 5. Fallback language Note: duplicate values are deleted.
init ( )
isInitialized ( )
setCachePath ( $cachePath )
setFallbackLang ( $fallbackLang )
setFilePath ( $filePath )
setForcedLang ( $forcedLang )
setMergeFallback ( $mergeFallback )
setPrefix ( $prefix )
setSectionSeperator ( $sectionSeperator )

Защищенные методы

Метод Описание
compile ( $config, $prefix = '' ) Recursively compile an associative array to PHP code.
fail_after_init ( )
getConfigFilename ( $langcode )
load ( $filename )

Приватные методы

Метод Описание
array_extend ( $a, $b ) Something of a sane version of PHP's array_merge

Описание методов

__construct() публичный Метод

Constructor The constructor sets all important settings. All params are optional, you can set the options via extra functions too.
public __construct ( $filePath = NULL, $cachePath = NULL, $fallbackLang = NULL, $prefix = NULL )

compile() защищенный Метод

Recursively compile an associative array to PHP code.
protected compile ( $config, $prefix = '' )

fail_after_init() защищенный Метод

protected fail_after_init ( )

getAppliedLang() публичный Метод

public getAppliedLang ( )

getCachePath() публичный Метод

public getCachePath ( )

getConfigFilename() защищенный Метод

protected getConfigFilename ( $langcode )

getFallbackLang() публичный Метод

public getFallbackLang ( )

getUserLangs() публичный Метод

getUserLangs() Returns the user languages Normally it returns an array like this: 1. Forced language 2. Language in $_GET['lang'] 3. Language in $_SESSION['lang'] 4. HTTP_ACCEPT_LANGUAGE 5. Fallback language Note: duplicate values are deleted.
public getUserLangs ( ) : array
Результат array with the user languages sorted by priority.

init() публичный Метод

public init ( )

isInitialized() публичный Метод

public isInitialized ( )

load() защищенный Метод

protected load ( $filename )

setCachePath() публичный Метод

public setCachePath ( $cachePath )

setFallbackLang() публичный Метод

public setFallbackLang ( $fallbackLang )

setFilePath() публичный Метод

public setFilePath ( $filePath )

setForcedLang() публичный Метод

public setForcedLang ( $forcedLang )

setMergeFallback() публичный Метод

public setMergeFallback ( $mergeFallback )

setPrefix() публичный Метод

public setPrefix ( $prefix )

setSectionSeperator() публичный Метод

public setSectionSeperator ( $sectionSeperator )

Описание свойств

$appliedLang защищенное свойство

protected $appliedLang

$cacheFilePath защищенное свойство

protected $cacheFilePath

$cachePath защищенное свойство

Cache file path This is the path for all the cache files. Best is an empty directory with no other files in it.
protected string $cachePath
Результат string

$fallbackLang защищенное свойство

Remember to create a language file for the fallback!!
protected string $fallbackLang
Результат string

$filePath защищенное свойство

Language file path This is the path for the language files. You must use the '{LANGUAGE}' placeholder for the language or the script wont find any language files.
protected string $filePath
Результат string

$forcedLang защищенное свойство

Forced language If you want to force a specific language define it here.
protected string $forcedLang
Результат string

$isInitialized защищенное свойство

protected $isInitialized

$langFilePath защищенное свойство

protected $langFilePath

$mergeFallback защищенное свойство

Merge in fallback language Whether to merge current language's strings with the strings of the fallback language ($fallbackLang).
protected bool $mergeFallback
Результат boolean

$prefix защищенное свойство

The class name of the compiled class that contains the translated texts.
protected string $prefix
Результат string

$sectionSeperator защищенное свойство

For example, if you have a string 'greeting' in a section 'welcomepage' you will can access it via 'L::welcomepage_greeting'. If you changed it to 'ABC' you could access your string via 'L::welcomepageABCgreeting'
protected string $sectionSeperator
Результат string

$userLangs защищенное свойство

Normally, if you use the getUserLangs-method this array will be filled in like this: 1. Forced language 2. Language in $_GET['lang'] 3. Language in $_SESSION['lang'] 4. Fallback language
protected array $userLangs
Результат array