Currently, I think there is no easy way to translate the extensions of MediaWiki into other languages. I suggest to create a hook, or something like that, in the end of every messages list in every languages (named "addMessages", "addMessagesDe", etc.), and to add their returned value to the array. The extensions will add functions like "MakeSysopMessages", "MakeSysopMessagesDe", etc., to these hooks. Is it possible?
On 25/05/06, Rotem Liss mail@rotemliss.com wrote:
Currently, I think there is no easy way to translate the extensions of MediaWiki into other languages.
In the initialisation function, one could check $wgContLanguageCode and then determine what to add to the message cache via those means.
Rob Church
On 25/05/06, Rob Church robchur@gmail.com wrote:
On 25/05/06, Rotem Liss mail@rotemliss.com wrote:
Currently, I think there is no easy way to translate the extensions of MediaWiki into other languages.
In the initialisation function, one could check $wgContLanguageCode and then determine what to add to the message cache via those means.
Wouldn't that be a wrong behaviour? Users should be able to change their UI language independently of the content-language.
The real problem is where to place all the translations. If every extension would have one file for each language, it would be quite a mess...
-- [[cs:User:Mormegil | Petr Kadlec]]
Petr Kadlec wrote:
On 25/05/06, Rob Church robchur@gmail.com wrote:
On 25/05/06, Rotem Liss mail@rotemliss.com wrote:
Currently, I think there is no easy way to translate the extensions of MediaWiki into other languages.
In the initialisation function, one could check $wgContLanguageCode and then determine what to add to the message cache via those means.
Wouldn't that be a wrong behaviour? Users should be able to change their UI language independently of the content-language.
I agree. Also, Makesysop and Newuserlog create log entries, but they are used as the content language when adding the logs to the recent changes, and as the user-chosen language when displaying the logs in Special:Log. The check of $wgContLanguageCode breaks the current languages mechanism.
The real problem is where to place all the translations. If every extension would have one file for each language, it would be quite a mess...
I think we can place it in the extension file, as each extension has only a few messages.
-- [[cs:User:Mormegil | Petr Kadlec]] _______________________________________________ Mediawiki-i18n mailing list Mediawiki-i18n@mail.wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-i18n
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?
mediawiki-i18n@lists.wikimedia.org