PHP Class Pop\I18n\I18n

Author: Nick Sagona, III ([email protected])
Afficher le fichier Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Свойство Type Description
$content array Language content
$language string Default system language
$locale string Default system locale

Méthodes publiques

Méthode Description
__ ( 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.

Méthodes protégées

Méthode Description
loadCurrentLanguage ( ) : void Get language content from the XML file.
translate ( string $str, string | array $params = null ) : mixed Translate and return the string.

Method Details

__() public méthode

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

__construct() public méthode

Instantiate the I18n object.
public __construct ( string $lang = null ) : I18n
$lang string
Résultat I18n

_e() public méthode

Echo the translated string.
public _e ( string $str, string | array $params = null ) : void
$str string
$params string | array
Résultat void

createXmlFile() public static méthode

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
Résultat void

createXmlFromText() public static méthode

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
Résultat void

factory() public static méthode

Static method to load the I18n object.
public static factory ( string $lang = null ) : I18n
$lang string
Résultat I18n

getLanguage() public méthode

Get current language setting.
public getLanguage ( ) : string
Résultat string

getLanguages() public static méthode

Get languages from the XML files.
public static getLanguages ( string $dir = null ) : array
$dir string
Résultat array

getLocale() public méthode

Get current locale setting.
public getLocale ( ) : string
Résultat string

loadCurrentLanguage() protected méthode

Get language content from the XML file.
protected loadCurrentLanguage ( ) : void
Résultat void

loadFile() public méthode

Load language content from an XML file.
public loadFile ( string $langFile ) : void
$langFile string
Résultat void

translate() protected méthode

Translate and return the string.
protected translate ( string $str, string | array $params = null ) : mixed
$str string
$params string | array
Résultat mixed

Property Details

$content protected_oe property

Language content
protected array $content
Résultat array

$language protected_oe property

Default system language
protected string $language
Résultat string

$locale protected_oe property

Default system locale
protected string $locale
Résultat string