I've created a patch applying this for all the languages: http://www.mediawiki.org/w/index.php?title=User:Rotemliss/Suggested_translat... http://www.mediawiki.org/w/index.php?title=User:Rotemliss/Suggested_translation_patch&action=edit
This patch actually adds a line like the following:
wfRunHooks( 'AddMessagesEn', array( &$wgAllMessagesEn ) );
in each language. I've tested this patch on the latest trunk, and it works just fine. What do you think about this patch? Should it be commited and used, or there is another, better way?
Example code for testing:
# 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; }
By the way, it will be hard to produce the same result when checking $wgContLanguageCode, as it won't be changed when we use "uselang" or change the language in the user preferences; we will have to write something like:
# 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}}:ייבוא", ) ); }
which is much less organized and understandable. Also, in Newuserlog it's impossible to produce such a result when checking the languages code, because the log entries are used as interface messages in the log page, and as content messages in the recent changes.
By the way, I'm not sure using $wgAllMessagesEn as a parameter to the functions is OK. Should I replace the parameter with a new array – $wgMoreMessagesEn – then add it to $wgAllMessagesEn? For example:
$wgMoreMessagesEn = array(); wfRunHooks( 'AddMessagesEn', array( &$wgMoreMessagesEn ) ); $wgAllMessagesEn += $wgMoreMessagesEn;
Is it much more efficient?