GRIS_I18N
in package
Class for translations
With this class strings can be translated to different languages and returns the right gender version if available.
Parts of this code are taken from the i18n class of TheBugGenie by Daniel Andre Eikeland zegenie@zegeniestudios.net
PHP version 7
Copyright (c) 2012, Holger Heuser, GESIS Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8 50667 Cologne, Germany
Tags
Table of Contents
- settings_group = "i18n"
- The constant for the settings group
- $infos : array<string|int, mixed>
- The array with infos
- $language : string
- The current language
- $logger : object
- The object for logs
- $settings : object
- The object for settings
- $strings : array<string|int, mixed>
- The array with translations for the strings
- $translation : bool
- Shows if translation is available and ready
- __() : string
- Replaces the input string with the translation
- __construct() : mixed
- The class constructor
- check_input() : string
- Checks a string according to a regular expression
- get_all() : array<string|int, mixed>
- Returns all strings and translations
- get_infotext() : string
- Returns the information text (or hint/help) to a named element
- get_language() : string
- Returns the current language
- initialize() : true
- Includes the language file
- set_language() : string
- Sets a new language for the translation
- get_gender_string() : string
- Returns the string in the current language if available
- get_translation_filename() : string
- Returns the whole path of the translation file
Constants
settings_group
The constant for the settings group
public
mixed
settings_group
= "i18n"
Properties
$infos
The array with infos
private
array<string|int, mixed>
$infos
Tags
$language
The current language
private
string
$language
Tags
$logger
The object for logs
private
object
$logger
Tags
$settings
The object for settings
private
object
$settings
Tags
$strings
The array with translations for the strings
private
array<string|int, mixed>
$strings
Tags
$translation
Shows if translation is available and ready
private
bool
$translation
Tags
Methods
__()
Replaces the input string with the translation
public
__(string $text) : string
Parameters
- $text : string
-
The text for the translation
Return values
string —The translation
__construct()
The class constructor
public
__construct(string $language) : mixed
Initializes the translator class
Parameters
- $language : string
-
The international language code
Return values
mixed —check_input()
Checks a string according to a regular expression
public
check_input(string $text, string $type) : string
Parameters
- $text : string
-
The text to be checked
- $type : string
-
The type of regular expression
Return values
string —The translation
get_all()
Returns all strings and translations
public
get_all() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array with all strings and translations
get_infotext()
Returns the information text (or hint/help) to a named element
public
get_infotext(string $name[, bool $check = false ]) : string
Parameters
- $name : string
-
The name of the element
- $check : bool = false
-
Return html oj just check if info exists for this element
Return values
string —The information in the actual language (or only true if $check) or false
get_language()
Returns the current language
public
get_language() : string
Return values
string —The language
initialize()
Includes the language file
public
initialize() : true
Return values
true —set_language()
Sets a new language for the translation
public
set_language(string $language) : string
Parameters
- $language : string
-
The language of the file
Return values
string —The path
get_gender_string()
Returns the string in the current language if available
private
get_gender_string(string $match) : string
Parameters
- $match : string
-
The match for a gender part
Return values
string —The gender dependant phrase
get_translation_filename()
Returns the whole path of the translation file
private
get_translation_filename(string $language) : string
Parameters
- $language : string
-
The language of the file
Return values
string —The path