Added optional setting to allow UI messages act as content.
This commit is contained in:
parent
e6bb9de12b
commit
b6f4bb64ea
3 changed files with 49 additions and 3 deletions
|
|
@ -865,6 +865,24 @@ $wgLoggedInGroupId = 2;
|
|||
|
||||
$wgWhitelistRead = array ( ':Accueil', ':Main_Page');
|
||||
|
||||
/*
|
||||
When translating messages with wfMsg(), it is not always clear what should
|
||||
be considered UI messages and what shoud be content messages.
|
||||
|
||||
For example, for regular wikipedia site like en, there should be only one
|
||||
'mainpage', therefore when getting the link of 'mainpage', we should
|
||||
treate it as content of the site and call wfMsgForContent(), while for
|
||||
rendering the text of the link, we call wfMsg(). The code in default
|
||||
behaves this way. However, sites like common do offer different versions
|
||||
of 'mainpage' and the like for different languages. This array provides a
|
||||
way to override the default behavior. For example, to allow language specific
|
||||
mainpage and community portal, set
|
||||
|
||||
$wgForceUIMsgAsContentMsg = array( 'mainpage', 'portal-url' );
|
||||
|
||||
*/
|
||||
$wgForceUIMsgAsContentMsg = array();
|
||||
|
||||
/**
|
||||
* Authentication plugin.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -342,9 +342,14 @@ function wfMsg( $key ) {
|
|||
* Get a message from anywhere, for the content
|
||||
*/
|
||||
function wfMsgForContent( $key ) {
|
||||
global $wgForceUIMsgAsContentMsg;
|
||||
$args = func_get_args();
|
||||
array_shift( $args );
|
||||
return wfMsgReal( $key, $args, true, true );
|
||||
$forcontent = true;
|
||||
if( is_array( $wgForceUIMsgAsContentMsg ) &&
|
||||
in_array( $key, $wgForceUIMsgAsContentMsg ) )
|
||||
$forcontent = false;
|
||||
return wfMsgReal( $key, $args, true, $forcontent );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -360,9 +365,14 @@ function wfMsgNoDB( $key ) {
|
|||
* Get a message from the language file, for the content
|
||||
*/
|
||||
function wfMsgNoDBForContent( $key ) {
|
||||
global $wgForceUIMsgAsContentMsg;
|
||||
$args = func_get_args();
|
||||
array_shift( $args );
|
||||
return wfMsgReal( $key, $args, false, true );
|
||||
$forcontent = true;
|
||||
if( is_array( $wgForceUIMsgAsContentMsg ) &&
|
||||
in_array( $key, $wgForceUIMsgAsContentMsg ) )
|
||||
$forcontent = false;
|
||||
return wfMsgReal( $key, $args, false, $forcontent );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@
|
|||
* @subpackage Maintenance
|
||||
*/
|
||||
|
||||
|
||||
require_once('languages/Names.php');
|
||||
|
||||
function initialiseMessages( $overwrite = false, $messageArray = false ) {
|
||||
global $wgContLang, $wgContLanguageCode;
|
||||
global $wgContLangClass, $wgAllMessagesEn;
|
||||
global $wgDisableLangConversion;
|
||||
global $wgForceUIMsgAsContentMsg;
|
||||
global $wgLanguageNames;
|
||||
global $IP;
|
||||
|
||||
# overwrite language conversion option so that all variants
|
||||
|
|
@ -51,6 +53,22 @@ function initialiseMessages( $overwrite = false, $messageArray = false ) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
initialize all messages in $wgForceUIMsgAsContentMsg for all
|
||||
languages in Names.php
|
||||
*/
|
||||
if( is_array( $wgForceUIMsgAsContentMsg ) ) {
|
||||
foreach( $wgForceUIMsgAsContentMsg as $uikey ) {
|
||||
foreach( $wgLanguageNames as $code => $name) {
|
||||
if( $code == $wgContLanguageCode )
|
||||
continue;
|
||||
$msg = $wgContLang->getMessage( $uikey );
|
||||
if( $msg )
|
||||
$messages[$uikey. '/' . $code] = $msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initialiseMessagesReal( $overwrite, $messages );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue