$_library
$_library : string
The name of the locale library we use, this is usually a component's name.
This is the L10n main interface class, used by the components. It allows you to get entries from the l10n string tables in the current language with an automatic conversion to the destination character set.
L10n language database file format specification:
Lines starting with --- are considered command lines and treated specially, unless they occur within string data. All commands are separated with at least a single space from their content, unless they don't have an argument.
Empty lines are ignored, unless within string data.
All keys and values will be trim'ed when encountered, so leading and trailing whitespace will be eliminated completely.
Windows-style line endings (\r\n) will be silently converted to the UNIX \n style.
Commented example:
---# Lines starting with a # command are ignored. ---# File format version ---VERSION 2.1.0 ---# Language of the table ---LANGUAGE en ---STRING string identifier TRANSLATED STRING taken literally until ---STRINGEND, which is the only reserved value at the beginning of the line, everything else is fine. Linebreaks within the translation are preserved. \r\n sequences are translated into to \n ---STRINGEND
File naming scheme: {$component_directory}/locale/{$database_name}.{$lang}.txt
__construct(string $library, string $database)
The constructor loads the translation library indicated by the snippetdir path $library and initializes the system completely. The output character set will be initialized to the language's default.
string | $library | Name of the locale library to use. |
string | $database | Name of the database in the library to load. |
get_formatter() : \midcom_services_i18n_formatter
string_exists(string $string, string $language = null) : boolean
Checks if a localized string for $string exists. If $language is unset, the current language is used.
string | $string | The string-ID to search for. |
string | $language | The language to search in. |
Indicating availability.
string_available(string $string) : boolean
Checks whether the given string is available in either the current or the fallback language. Use this to determine if an actually processed result is returned by get. This is helpful especially if you want to "catch" cases where a string might translate to itself in some languages.
string | $string | The string-ID to search for |
Indicating availability.
get(string $string, string $language = null) : string
Retrieves a localized string from the database using $language as destination. If $language is unset, the currently set default language is used. If the string is not found in the selected language, the fallback is checked. If even the fallback cannot be found, then $string is returned and the event is logged to MidCOMs Debugging system.
L10n DB loads are done through string_exists.
string | $string | The string-ID to search for. |
string | $language | The language to search in, uses the current language as default. |
The translated string if available, the fallback string otherwise.
show(string $string, string $language = null)
This is a shortcut for "echo $this->get(.
..);", useful in style code.
Note, that due to the stupidity of the Zend engine, it is not possible to call this function echo, like it should have been called.
string | $string | The string-ID to search for. |
string | $language | The language to search in, uses the current language as default. |