本文整理汇总了PHP中ResourceLoader::addMessageJs方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceLoader::addMessageJs方法的具体用法?PHP ResourceLoader::addMessageJs怎么用?PHP ResourceLoader::addMessageJs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResourceLoader
的用法示例。
在下文中一共展示了ResourceLoader::addMessageJs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transformScriptText
function transformScriptText($scriptText, $moduleName)
{
global $wgEnableScriptLocalization;
// Strip out mw.log debug lines (if not in debug mode)
if (!$this->debug) {
$scriptText = $this->removeLogStatements($scriptText);
}
// Do language swap by index:
if ($wgEnableScriptLocalization) {
// NOTE getResourceMessageJS could identify which mode we are in and we would not need to
// try each of these search patterns in the same order as before.
// Get the mw.addMessage javascript
self::$addMessageJs = $this->getAddMessagesFromScriptText($scriptText, $moduleName);
// Check for mw.includeAllModuleMsgs() call to be replaced with all the msgs
// Use preg_replace_callback to avoid back-refrence substitution
$scriptText = preg_replace_callback(self::$includeAllMsgsRegEx, 'ResourceLoader::preg_addMessageJs', $scriptText, 1, $count);
if ($count != 0) {
return $scriptText;
}
// Replace mw.addMessages with localized msgs in javascript string
$inx = self::getAddMessagesIndex($scriptText);
if ($inx) {
// Return the final string (without double {})
return substr($scriptText, 0, $inx['sfull']) . self::$addMessageJs . substr($scriptText, $inx['efull']);
}
// Replace mw.addMessageKeys with localized msgs in javascript string
$inx = self::getAddMessageKeyIndex($scriptText);
if ($inx) {
// Return the final string (without double {})
return substr($scriptText, 0, $inx['sfull']) . self::$addMessageJs . substr($scriptText, $inx['efull']);
}
}
// Return the javascript str unmodified if we did not transform with the localisation
return $scriptText;
}