Jump to content

手册:$wgMessagesDirs

From mediawiki.org
This page is a translated version of the page Manual:$wgMessagesDirs and the translation is 38% complete.
Outdated translations are marked like this.
扩展: $wgMessagesDirs
扩展消息目录。
引进版本:1.24.0 (Gerrit change 102957; git #2f7b68ff)
移除版本:仍在使用
允许的值:(数组)
默认值:[]

A configurable global variable pointing to the path of a directory that contains message files. It works with associative arrays as demonstrated below. The message files are expected to be JSON files named for their language code, e.g. en.json, de.json, etc. Extensions with messages in multiple places may specify an array of message directories.

The modern approach that is recommended for extensions is not to use $wgMessagesDirs directly but to use the equivalent key in extension.json.

Examples

简单例子:

PHP extension.json
$wgMessagesDirs['ConfirmEdit'] = __DIR__ . '/i18n';
"MessagesDirs": {
 "ConfirmEdit": [
  "i18n"
 ]
}

复杂例子:

PHP extension.json
$wgMessagesDirs['VisualEditor'] = [
    __DIR__ . '/i18n',
    __DIR__ . '/modules/ve-core/i18n',
    __DIR__ . '/modules/qunit/localisation',
    __DIR__ . '/modules/oojs-ui/messages',
];
"MessagesDirs": {
 "VisualEditor": [
  "i18n",
  "modules/ve-core/i18n",
  "modules/qunit/localisation",
  "modules/oojs-ui/messages"
 ]
}

$wgMessagesDirs can co-exist with $wgExtensionMessagesFiles ; both should be set, if you want to preserve compatibility when converting old PHP l10n files.

參見