PHP Класс SimpleSAML\Locale\Translate

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

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

Метод Описание
__construct ( SimpleSAML_Configuration $configuration, string | null $defaultDictionary = null ) Constructor
getAttributeTranslation ( string $name ) : string Translate the name of an attribute.
getLanguage ( ) : Language Return the internal language object used by this translator.
getPreferredTranslation ( array $translations ) : string Retrieve the preferred translation of a given text.
getTag ( string $tag ) : array This method retrieves a tag as an array with language => string mappings.
includeInlineTranslation ( string $tag, array | string $translation ) Include a translation inline instead of putting translations in dictionaries. This function is recommended to be used ONLU from variable data, or when the translation is already provided by an external source, as a database or in metadata.
includeLanguageFile ( string $file, SimpleSAML_Configuration | null $otherConfig = null ) Include a language file from the dictionaries directory.
noop ( string $tag ) : string Mark a string for translation without translating it.
t ( string | array $tag, array $replacements = [], boolean $fallbackdefault = true, $oldreplacements = [], $striptags = false ) : string Translate a tag into the current language, with a fallback to english.
translatePluralGettext ( $original, $plural, $value )
translateSingularGettext ( $original )

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

Метод Описание
getDictionary ( string $name ) : array This method retrieves a dictionary with the name given.
getStringNotTranslated ( string $tag, boolean $fallbacktag ) : string Return the string that should be used when no translation was found.
readDictionaryFile ( string $filename ) : array Read a dictionary file.
readDictionaryJSON ( string $filename ) : array Read a dictionary file in JSON format.
readDictionaryPHP ( string $filename ) : array Read a dictionary file in PHP format.

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

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

Constructor
public __construct ( SimpleSAML_Configuration $configuration, string | null $defaultDictionary = null )
$configuration SimpleSAML_Configuration Configuration object
$defaultDictionary string | null The default dictionary where tags will come from.

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

Translate the name of an attribute.
public getAttributeTranslation ( string $name ) : string
$name string The attribute name.
Результат string The translated attribute name, or the original attribute name if no translation was found.

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

Return the internal language object used by this translator.
public getLanguage ( ) : Language
Результат Language

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

Retrieve the preferred translation of a given text.
public getPreferredTranslation ( array $translations ) : string
$translations array The translations, as an associative array with language => text mappings.
Результат string The preferred translation.

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

This method retrieves a tag as an array with language => string mappings.
public getTag ( string $tag ) : array
$tag string The tag name. The tag name can also be on the form '{:}', to retrieve a tag from the specific dictionary.
Результат array An associative array with language => string mappings, or null if the tag wasn't found.

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

Include a translation inline instead of putting translations in dictionaries. This function is recommended to be used ONLU from variable data, or when the translation is already provided by an external source, as a database or in metadata.
public includeInlineTranslation ( string $tag, array | string $translation )
$tag string The tag that has a translation
$translation array | string The translation array

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

Include a language file from the dictionaries directory.
public includeLanguageFile ( string $file, SimpleSAML_Configuration | null $otherConfig = null )
$file string File name of dictionary to include
$otherConfig SimpleSAML_Configuration | null Optionally provide a different configuration object than the one provided in the constructor to be used to find the directory of the dictionary. This allows to combine dictionaries inside the SimpleSAMLphp main code distribution together with external dictionaries. Defaults to null.

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

Mark a string for translation without translating it.
public static noop ( string $tag ) : string
$tag string A tag name to mark for translation.
Результат string The tag, unchanged.

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

This function is used to look up a translation tag in dictionaries, and return the translation into the current language. If no translation into the current language can be found, english will be tried, and if that fails, placeholder text will be returned. An array can be passed as the tag. In that case, the array will be assumed to be on the form (language => text), and will be used as the source of translations. This function can also do replacements into the translated tag. It will search the translated tag for the keys provided in $replacements, and replace any found occurrences with the value of the key.
Устаревший: Not used in twig, gettext
public t ( string | array $tag, array $replacements = [], boolean $fallbackdefault = true, $oldreplacements = [], $striptags = false ) : string
$tag string | array A tag name for the translation which should be looked up, or an array with (language => text) mappings. The array version will go away in 2.0
$replacements array An associative array of keys that should be replaced with values in the translated string.
$fallbackdefault boolean Default translation to use as a fallback if no valid translation was found.
Результат string The translated tag, or a placeholder value if the tag wasn't found.

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

public static translatePluralGettext ( $original, $plural, $value )

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

public static translateSingularGettext ( $original )