Author: rotemliss
Description:
Currently, all the extensions use $wgMessageCache->addMessages to add system
messages, and usually don't translate them into other languages.
Actually, translating the extensions into other languages is something hard
using the current tools. We can check $wgLanguageCode to get the current
language, use "if" structure and add the localized messages, but some messages
are interface messages and should be retrieved from the user-chosen language
($wgLanguageCode), while others are content messages and should retrieved from
the site content language ($wgContLanguageCode). We can build two "if"
statements, but the code is getting longer and more complicated. Finally, there
is a special type of messages – log entry messages. These messages should be
used as content messages when executing the action and getting the log entry
into the recent changes comment, and as interface messages in Special:Log. This
usage is completely not possible to implement with extension system messages,
and is not possible to implement using $wgMessageCache->addMessages.
Even without taking notice to the log entry messages, something like that should
be used to add a new user group:
Allow only privilleged users to import pages
$wgGroupPermissions["sysop"]["import"] = false;
$wgGroupPermissions["import"]["import"] = true;
Add the interface messages
if ($wgLanguageCode == 'en') {
$wgMessagesCache->addMessages( array(
"group-import" => "Importers", "group-import-member" => "Importer",
) );
} elseif ($wgLanguageCode == 'he') {
$wgMessagesCache->addMessages( array(
"group-import" => "מייבאים", "group-import-member" => "מייבא",
) );
}
Add the content messages
if ($wgContLanguageCode == 'en') {
$wgMessagesCache->addMessages( array(
"grouppage-import" => "{{ns:help}}:Import",
) );
} elseif ($wgContLanguageCode == 'he') {
$wgMessagesCache->addMessages( array(
"grouppage-import" => "{{ns:help}}:ייבוא",
) );
}
This code is complicated, not organized and not understandable. It breaks the
array $wgForceUIMsgAsContentMsg or a change in its use, bypasses wfMsg vs.
wfMsgForContent, and as I've already said, we cannot bypass the problem in such
way for log entries.
Therefore, I've suggested here:
http://mail.wikipedia.org/pipermail/mediawiki-i18n/2006-May/000063.html new
hooks, which pass the messages as an argument, and messages can be added to
them. I've published the code and checks here:
http://mail.wikipedia.org/pipermail/mediawiki-i18n/2006-June/000076.html and you
can see that the following code is much cleaner:
Allow only privilleged users to import pages
$wgGroupPermissions["sysop"]["import"] = false;
$wgGroupPermissions["import"]["import"] = true;
Translation hooks
$wgHooks['AddMessagesEn'][] = 'wfImportMessagesEn';
$wgHooks['AddMessagesHe'][] = 'wfImportMessagesHe';
English messages
function wfImportMessagesEn( &$messages ) {
$messages += array(
"group-import" => "Importers", "group-import-member" => "Importer", "grouppage-import" => "{{ns:help}}:Import",
);
return true;
}
Hebrew messages
function wfImportMessagesHe( &$messages ) {
$messages += array(
"group-import" => "מייבאים", "group-import-member" => "מייבא", "grouppage-import" => "{{ns:help}}:ייבוא",
);
return true;
}
I'm posting the most updated patch here, and it would be nice if you make some
comments about it, or suggest a better way.
Thanks.
Version: 1.7.x
Severity: enhancement
URL: http://mail.wikipedia.org/pipermail/mediawiki-i18n/2006-May/000063.html