PHP Класс Pop\I18n\I18n

Автор: Nick Sagona, III ([email protected])
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$content array Language content
$language string Default system language
$locale string Default system locale

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

Метод Описание
__ ( string $str, string | array $params = null ) Return the translated string
__construct ( string $lang = null ) : I18n Constructor
_e ( string $str, string | array $params = null ) : void Echo the translated string.
createXmlFile ( array $lang, array $locales, string $file ) : void Create an XML language file from an array of data.
createXmlFromText ( string $source, string $output, string $target = null ) : void Create an XML document fragment from a source file and an output file, each entry separated by a new line
factory ( string $lang = null ) : I18n Static method to load the I18n object.
getLanguage ( ) : string Get current language setting.
getLanguages ( string $dir = null ) : array Get languages from the XML files.
getLocale ( ) : string Get current locale setting.
loadFile ( string $langFile ) : void Load language content from an XML file.

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

Метод Описание
loadCurrentLanguage ( ) : void Get language content from the XML file.
translate ( string $str, string | array $params = null ) : mixed Translate and return the string.

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

__() публичный метод

Return the translated string
public __ ( string $str, string | array $params = null )
$str string
$params string | array

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

Instantiate the I18n object.
public __construct ( string $lang = null ) : I18n
$lang string
Результат I18n

_e() публичный метод

Echo the translated string.
public _e ( string $str, string | array $params = null ) : void
$str string
$params string | array
Результат void

createXmlFile() публичный статический метод

The format of the parameters should be as follows: $lang = array( 'src' => 'en', 'output' => 'de', 'name' => 'German', 'native' => 'Deutsch' ); $locales = array( array( 'region' => 'DE', 'name' => 'Germany', 'native' => 'Deutschland', 'text' => array( array( 'source' => 'This field is required.', 'output' => 'Dieses Feld ist erforderlich.' ), ... ) ), ... );
public static createXmlFile ( array $lang, array $locales, string $file ) : void
$lang array
$locales array
$file string
Результат void

createXmlFromText() публичный статический метод

Create an XML document fragment from a source file and an output file, each entry separated by a new line
public static createXmlFromText ( string $source, string $output, string $target = null ) : void
$source string
$output string
$target string
Результат void

factory() публичный статический метод

Static method to load the I18n object.
public static factory ( string $lang = null ) : I18n
$lang string
Результат I18n

getLanguage() публичный метод

Get current language setting.
public getLanguage ( ) : string
Результат string

getLanguages() публичный статический метод

Get languages from the XML files.
public static getLanguages ( string $dir = null ) : array
$dir string
Результат array

getLocale() публичный метод

Get current locale setting.
public getLocale ( ) : string
Результат string

loadCurrentLanguage() защищенный метод

Get language content from the XML file.
protected loadCurrentLanguage ( ) : void
Результат void

loadFile() публичный метод

Load language content from an XML file.
public loadFile ( string $langFile ) : void
$langFile string
Результат void

translate() защищенный метод

Translate and return the string.
protected translate ( string $str, string | array $params = null ) : mixed
$str string
$params string | array
Результат mixed

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

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

Language content
protected array $content
Результат array

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

Default system language
protected string $language
Результат string

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

Default system locale
protected string $locale
Результат string