Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

Standard string manager.

Copyright: 2010 Petr Skoda {@link http://skodak.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 713 lines (30 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: core_string_manager_standard  - X-Ref

Standard string_manager implementation

Implements string_manager with getting and printing localised strings

__construct($otherroot, $localroot, $translist, $transaliases = [])   X-Ref
Create new instance of string manager

param: string $otherroot location of downloaded lang packs - usually $CFG->dataroot/lang
param: string $localroot usually the same as $otherroot
param: array $translist limit list of visible translations
param: array $transaliases aliases to use for the languages in the language selector

get_language_dependencies($lang)   X-Ref
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.

param: string $lang the code of the language
return: array all explicit parent languages with the lang itself appended

load_component_strings($component, $lang, $disablecache = false, $disablelocal = false)   X-Ref
Load all strings for one component

param: string $component The module the string is associated with
param: string $lang
param: bool $disablecache Do not use caches, force fetching the strings from sources
param: bool $disablelocal Do not use customized strings in xx_local language packs
return: array of all string for given component and lang

load_deprecated_strings()   X-Ref
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: array of deprecated strings in the same format they appear in deprecated.txt files: "identifier,component"

string_deprecated($identifier, $component)   X-Ref
Has string been deprecated?

Usually checked only inside get_string() to display debug warnings.

param: string $identifier The identifier of the string to search for
param: string $component The module the string is associated with
return: bool true if deprecated

string_exists($identifier, $component)   X-Ref
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!

param: string $identifier The identifier of the string to search for
param: string $component The module the string is associated with
return: boot true if exists

get_string($identifier, $component = '', $a = null, $lang = null)   X-Ref
Get String returns a requested string

param: string $identifier The identifier of the string to search for
param: string $component The module the string is associated with
param: string|object|array $a An object, string or number that can be used
param: string $lang moodle translation language, null means use current
return: string The String !

get_performance_summary()   X-Ref
Returns information about the core_string_manager performance.

return: array

get_list_of_countries($returnall = false, $lang = null)   X-Ref
Returns a localised list of all country names, sorted by localised name.

param: bool $returnall return all or just enabled
param: string $lang moodle translation language, null means use current
return: array two-letter country code => translated name.

get_list_of_languages($lang = null, $standard = 'iso6391')   X-Ref
Returns a localised list of languages, sorted by code keys.

param: string $lang moodle translation language, null means use current
param: string $standard language list standard
return: array language code => translated name

translation_exists($lang, $includeall = true)   X-Ref
Checks if the translation exists for the language

param: string $lang moodle translation language code
param: bool $includeall include also disabled translations
return: bool true if exists

get_list_of_translations($returnall = false)   X-Ref
Returns localised list of installed translations

param: bool $returnall return all or just enabled
return: array moodle translation code => localised translation name

get_list_of_currencies($lang = null)   X-Ref
Returns localised list of currencies.

param: string $lang moodle translation language, null means use current
return: array currency code => localised currency name

reset_caches($phpunitreset = false)   X-Ref
Clears both in-memory and on-disk caches

param: bool $phpunitreset true means called from our PHPUnit integration test reset

get_key_suffix()   X-Ref
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: string

get_revision()   X-Ref
Returns string revision counter, this is incremented after any string cache reset.

return: int lang string revision counter, -1 if unknown

populate_parent_languages($lang, array $stack = array()   X-Ref
Helper method that recursively loads all parents of the given language.

param: string $lang language code
param: array $stack list of parent languages already populated in previous recursive calls
return: array list of all parents of the given language with the $lang itself added as the last element