I18n
MMO\core · 1 symbol · generated 30 Sep 2026
I18n
I18n.php:18Internationalization module.
- Namespace
MMO\core- Extends
- aModule
Index
| LANGUAGE_REGEX | ||
| dateMDY | Country that use notation month/day/year | |
| lang | ||
| translations | ||
| DefaultConfig() static | ||
| findLanguage($lang, $languages, $useValues) | Find language in a list of languages | |
| formatDate($format, $date, $lang) | Format a date, then translate its textual parts (translateDate). | |
| get($text, $lang) | Look up a single translation, with no placeholder substitution (translate for that). | |
| getByPrefix($prefix, $lang) | Returns a list of translation with a given prefix, removing the prefix from the id | |
| isMDYFormat($lang) | ||
| load($lang, $translations) | Register (merging into any already-loaded for the same language) a set of message => translation pairs. | |
| matchLanguage($range, $lang) | RFC 4647 §3.3.2, the exact matching algorithm, transcribed step by step: | |
| onInc($event) | ||
| setLanguage($lang) | Set language. | |
| splitLanguage($lang) | Match the full input against the RFC 5646 §2.1 'langtag' production: | |
| translate($message, $context, $prefix, $lang) | Translate a message and its context | |
| translateDate($date, $lang) | Translate the textual parts of an already-formatted date (e.g. | |
| _($message, $context, $prefix, $lang) static | Main entry point to translate a string |
Constants1
LANGUAGE_REGEX
Properties3
dateMDY
Country that use notation month/day/year
- Type
- array
lang
- Type
- string
translations
- Type
- array
Methods14
DefaultConfig()
staticI18n.php:42| returns | array | default configuration: the current language defaults to the LANGUAGE constant. |
findLanguage($lang, $languages, $useValues)
I18n.php:253Find language in a list of languages
formatDate($format, $date, $lang)
I18n.php:308Format a date, then translate its textual parts (translateDate).
| $format = 'l d F Y' | string | a DateTime::format format string. |
| $date = 'now' | DateTimeInterface | string | int | dateTime. |
| $lang = null | null | string | |
| returns |
get($text, $lang)
I18n.php:76Look up a single translation, with no placeholder substitution (translate for that).
| $text | string | the message to translate. |
| $lang = null | null | string | defaults to the current language (setLanguage); resolved via findLanguage (so a close-enough loaded language, e.g. 'en' for a requested 'en-GB', is used if there's no exact match). |
| returns | string | the translation, or $text itself if none is found. |
getByPrefix($prefix, $lang)
I18n.php:88Returns a list of translation with a given prefix, removing the prefix from the id
isMDYFormat($lang)
I18n.php:283load($lang, $translations)
I18n.php:64Register (merging into any already-loaded for the same language) a set of message => translation pairs.
matchLanguage($range, $lang)
I18n.php:203RFC 4647 §3.3.2, the exact matching algorithm, transcribed step by step:
onInc($event)
I18n.php:127- See
Incevent handler: registers a hook so the manifest also loads its translations for the current language once included.
setLanguage($lang)
I18n.php:139Set language.
splitLanguage($lang)
I18n.php:179Match the full input against the RFC 5646 §2.1 'langtag' production:
translate($message, $context, $prefix, $lang)
I18n.php:110Translate a message and its context
translateDate($date, $lang)
I18n.php:295Translate the textual parts of an already-formatted date (e.g. month/day names), via translations loaded under the /dates: prefix (getByPrefix/load).
_($message, $context, $prefix, $lang)
staticI18n.php:54Main entry point to translate a string
Inherited members (47)
| Constants | Declared by | Description | |
|---|---|---|---|
ALERT | iLogLevel | Alert: Action must be taken immediately. | |
ALL | iLogLevel | Mask for all | |
ALL_PLUS | iLogLevel | debug everything | |
BACKTRACE | iLogLevel | ||
CRITICAL | iLogLevel | Critical: Critical conditions. | |
DEBUG | iLogLevel | Debug: Detailed debug information. | |
DEEP | iLogLevel | debug everything with arguments | |
EMERGENCY | iLogLevel | Emergency: System is unusable. | |
ERROR | iLogLevel | Error: Runtime errors that do not require immediate action but should typically be logged and monitored. | |
ERROR_PLUS | iLogLevel | Mask for all error | |
FATAL | iLogLevel | Mask for all fatal error | |
INFO | iLogLevel | Info: Interesting events. | |
INFO_PLUS | iLogLevel | Mask for all errors/warning/notices/info | |
MEMORY | iLogLevel | include backtrace object | |
NOTICE | iLogLevel | Notice: Normal but significant events. | |
NOTICE_PLUS | iLogLevel | Mask for all errors/warning/notices/info | |
TRACE | iLogLevel | include backtrace as origins | |
WARNING | iLogLevel | Warning: Exceptional occurrences that are not errors. | |
WARNING_PLUS | iLogLevel | Mask for all errors and warnings |
| Properties | Declared by | Description | |
|---|---|---|---|
verbosity | aModule |
| Methods | Declared by | Description | |
|---|---|---|---|
alert($message, $context) | aModule | Action must be taken immediately. | |
backtraces($message, $context) | aModule | Force-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it). | |
Configure($config) | aModule | Merge $config into this module's configuration in the shared Configuration. | |
critical($message, $context) | aModule | Critical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask. | |
debug($message, $context) | aModule | Detailed debug information. | |
debugName() | aModule | Human-readable identifier used as the default {origin} in this instance's log messages. | |
emergency($message, $context) | aModule | System is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask. | |
error($message, $context) | aModule | Runtime errors that do not require immediate action but should typically be logged and monitored. | |
getVerbosity() | aModule | ||
info($message, $context) | aModule | Interesting events. No-op if INFO is currently filtered out by the verbosity mask. | |
Instantiate($config) | aModule | (Re)create the shared instance immediately, configured with $config merged into the class's existing config. | |
IsShared() | aModule | ||
log($level, $message, $context) | aModule | Logs with an arbitrary level. | |
notice($message, $context) | aModule | Normal but significant events. | |
offsetExists($key) | aModule | \ArrayAccess::offsetExists -- tells whether $key is a declared property at all, regardless of whether it is currently readable/writable through array access. | |
offsetGet($key) | aModule | \ArrayAccess::offsetGet -- reads a property directly, unless it has a #[Serialize(serialize: 'methodName')] attribute, in which case that zero-argument method is called instead (e.g. | |
offsetSet($key, $value) | aModule | \ArrayAccess::offsetSet -- sets a property directly, unless it has a #[Serialize(unserialize: 'methodName')] attribute, in which case that method is called with $value instead (e.g. | |
offsetUnset($key) | aModule | \ArrayAccess::offsetUnset -- equivalent to $module[$key] = null. | |
serialize($path, $serializer) | aModule | \MMO\core\interfaces\iSerializable::serialize -- exports every property (via | |
setVerbosity($verb) | aModule | Set the current verbosity mask, replacing whatever it was before. | |
Shared() | aModule | Get the shared instance, creating (and configuring) it on first call. | |
testVerbosity($level) | aModule | Test whether a given level (or set of levels) is currently enabled by this instance's verbosity mask. | |
traitUnshare($serialize) | aModule | Remove the shared instance, so the next Shared() call creates a fresh one. | |
unserialize($data, $path, $instances) | aModule | \MMO\core\interfaces\iSerializable::unserialize -- merges $data onto DefaultConfig, runs it through the (possibly overridden) constructor, then applies each resulting value to its property (via | |
Unshare($serialize) | aModule | Like tSingleton::Unshare, but also disconnects this module's instance from every event it was listening to (via Event::DisconnectListeners) before dropping it. | |
warning($message, $context) | aModule | Exceptional occurrences that are not errors. | |
__construct($config) | aModule | protected constructor, so it is not possible to do new Module(...) called by the serialization process just before being injected with data. |