Standard string_manager implementation.
More...
|
| __construct ($otherroot, $localroot, $translist, $transaliases=[]) |
| Create new instance of string manager. More...
|
|
| get_language_dependencies ($lang) |
| Returns list of all explicit parent languages for the given language. More...
|
|
| get_list_of_countries ($returnall=false, $lang=null) |
| Returns a localised list of all country names, sorted by localised name. More...
|
|
| get_list_of_currencies ($lang=null) |
| Returns localised list of currencies. More...
|
|
| get_list_of_languages ($lang=null, $standard='iso6391') |
| Returns a localised list of languages, sorted by code keys. More...
|
|
| get_list_of_translations ($returnall=false) |
| Returns localised list of installed translations. More...
|
|
| get_performance_summary () |
| Returns information about the core_string_manager performance. More...
|
|
| get_revision () |
| Returns string revision counter, this is incremented after any string cache reset. More...
|
|
| get_string ($identifier, $component='', $a=null, $lang=null) |
| Get String returns a requested string. More...
|
|
| load_component_strings ($component, $lang, $disablecache=false, $disablelocal=false) |
| Load all strings for one component. More...
|
|
| reset_caches ($phpunitreset=false) |
| Clears both in-memory and on-disk caches. More...
|
|
| string_deprecated ($identifier, $component) |
| Has string been deprecated? More...
|
|
| string_exists ($identifier, $component) |
| Does the string actually exist? More...
|
|
| translation_exists ($lang, $includeall=true) |
| Checks if the translation exists for the language. More...
|
|
Standard string_manager implementation.
Implements string_manager with getting and printing localised strings
- Copyright
- 2010 Petr Skoda http://skodak.org
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __construct()
core_string_manager_standard::__construct |
( |
|
$otherroot, |
|
|
|
$localroot, |
|
|
|
$translist, |
|
|
|
$transaliases = [] |
|
) |
| |
Create new instance of string manager.
- Parameters
-
string | $otherroot | location of downloaded lang packs - usually $CFG->dataroot/lang |
string | $localroot | usually the same as $otherroot |
array | $translist | limit list of visible translations |
array | $transaliases | aliases to use for the languages in the language selector |
◆ get_key_suffix()
core_string_manager_standard::get_key_suffix |
( |
| ) |
|
|
protected |
Returns cache key suffix, this enables us to store string + lang menu caches in local caches on cluster nodes.
We can not use prefix because it would cause problems when creating subdirs in cache file store.
- Return values
-
◆ get_language_dependencies()
core_string_manager_standard::get_language_dependencies |
( |
|
$lang | ) |
|
Returns list of all explicit parent languages for the given language.
English (en) is considered as the top implicit parent of all language packs and is not included in the returned list. The language itself is appended to the end of the list. The method is aware of circular dependency risk.
- See also
- self::populate_parent_languages()
- Parameters
-
string | $lang | the code of the language |
- Return values
-
array | all explicit parent languages with the lang itself appended |
◆ get_list_of_countries()
core_string_manager_standard::get_list_of_countries |
( |
|
$returnall = false , |
|
|
|
$lang = null |
|
) |
| |
Returns a localised list of all country names, sorted by localised name.
- Parameters
-
bool | $returnall | return all or just enabled |
string | $lang | moodle translation language, null means use current |
- Return values
-
array | two-letter country code => translated name. |
Implements core_string_manager.
◆ get_list_of_currencies()
core_string_manager_standard::get_list_of_currencies |
( |
|
$lang = null | ) |
|
Returns localised list of currencies.
- Parameters
-
string | $lang | moodle translation language, null means use current |
- Return values
-
array | currency code => localised currency name |
Implements core_string_manager.
◆ get_list_of_languages()
core_string_manager_standard::get_list_of_languages |
( |
|
$lang = null , |
|
|
|
$standard = 'iso6391' |
|
) |
| |
Returns a localised list of languages, sorted by code keys.
- Parameters
-
string | $lang | moodle translation language, null means use current |
string | $standard | language list standard
- iso6392: three-letter language code (ISO 639-2/T) => translated name
- iso6391: two-letter language code (ISO 639-1) => translated name
|
- Return values
-
array | language code => translated name |
Implements core_string_manager.
◆ get_list_of_translations()
core_string_manager_standard::get_list_of_translations |
( |
|
$returnall = false | ) |
|
Returns localised list of installed translations.
- Parameters
-
bool | $returnall | return all or just enabled |
- Return values
-
array | moodle translation code => localised translation name |
Implements core_string_manager.
◆ get_performance_summary()
core_string_manager_standard::get_performance_summary |
( |
| ) |
|
◆ get_revision()
core_string_manager_standard::get_revision |
( |
| ) |
|
Returns string revision counter, this is incremented after any string cache reset.
- Return values
-
int | lang string revision counter, -1 if unknown |
Implements core_string_manager.
◆ get_string()
core_string_manager_standard::get_string |
( |
|
$identifier, |
|
|
|
$component = '' , |
|
|
|
$a = null , |
|
|
|
$lang = null |
|
) |
| |
Get String returns a requested string.
- Parameters
-
string | $identifier | The identifier of the string to search for |
string | $component | The module the string is associated with |
string | object | array | $a | An object, string or number that can be used within translation strings |
string | $lang | moodle translation language, null means use current |
- Return values
-
Implements core_string_manager.
◆ load_component_strings()
core_string_manager_standard::load_component_strings |
( |
|
$component, |
|
|
|
$lang, |
|
|
|
$disablecache = false , |
|
|
|
$disablelocal = false |
|
) |
| |
Load all strings for one component.
- Parameters
-
string | $component | The module the string is associated with |
string | $lang | |
bool | $disablecache | Do not use caches, force fetching the strings from sources |
bool | $disablelocal | Do not use customized strings in xx_local language packs |
- Return values
-
array | of all string for given component and lang |
Implements core_string_manager.
◆ load_deprecated_strings()
core_string_manager_standard::load_deprecated_strings |
( |
| ) |
|
|
protected |
Parses all deprecated.txt in all plugins lang locations and returns the list of deprecated strings.
Static variable is used for caching, this function is only called in dev environment.
- Return values
-
array | of deprecated strings in the same format they appear in deprecated.txt files: "identifier,component" where component is a normalised component (i.e. "core_moodle", "mod_assign", etc.) |
◆ populate_parent_languages()
core_string_manager_standard::populate_parent_languages |
( |
|
$lang, |
|
|
array |
$stack = array() |
|
) |
| |
|
protected |
Helper method that recursively loads all parents of the given language.
- See also
- self::get_language_dependencies()
- Parameters
-
string | $lang | language code |
array | $stack | list of parent languages already populated in previous recursive calls |
- Return values
-
array | list of all parents of the given language with the $lang itself added as the last element |
◆ reset_caches()
core_string_manager_standard::reset_caches |
( |
|
$phpunitreset = false | ) |
|
Clears both in-memory and on-disk caches.
- Parameters
-
bool | $phpunitreset | true means called from our PHPUnit integration test reset |
Implements core_string_manager.
◆ string_deprecated()
core_string_manager_standard::string_deprecated |
( |
|
$identifier, |
|
|
|
$component |
|
) |
| |
Has string been deprecated?
Usually checked only inside get_string() to display debug warnings.
- Parameters
-
string | $identifier | The identifier of the string to search for |
string | $component | The module the string is associated with |
- Return values
-
Implements core_string_manager.
◆ string_exists()
core_string_manager_standard::string_exists |
( |
|
$identifier, |
|
|
|
$component |
|
) |
| |
Does the string actually exist?
get_string() is throwing debug warnings, sometimes we do not want them or we want to display better explanation of the problem. Note: Use with care!
- Parameters
-
string | $identifier | The identifier of the string to search for |
string | $component | The module the string is associated with |
- Return values
-
Implements core_string_manager.
◆ translation_exists()
core_string_manager_standard::translation_exists |
( |
|
$lang, |
|
|
|
$includeall = true |
|
) |
| |
Checks if the translation exists for the language.
- Parameters
-
string | $lang | moodle translation language code |
bool | $includeall | include also disabled translations |
- Return values
-
Implements core_string_manager.
The documentation for this class was generated from the following file: