[Mediawiki-l] Internalization for non-Special-Page extensions

Tim Cronin tccroninv at gmail.com
Thu Oct 15 23:52:38 UTC 2009


Hello All,

 

First off, sorry for using "internalization" rather than
"internationalization".  I noticed the errors just after hitting send.

 

I have solved my own problem with a bit more trial and error.  For those
that are finding this in the future here's the answer I came up with:

 

You use $wgExtensionMessagesFiles to add the extension message file that you
have set up.  It doesn't appear to matter where this is, so long as the file
in which it appears is require()'d iin some way. An example of this is as
follows:

 

$wgExtensionMessagesFiles['referenceName'] =
'/path/to/messages_file.i18n.php';

 

Note: It is common to have 'referenceName' match 'messages_file' and for
this to also be the name of the extension.

 

You then need to use wfLoadExtensionMessages inside any function that you
are using in which you want some translation.  This is what I was missing:
you apparently can't just use it in the constructor as you can with a
SpecialPage subclass.  An example would be:

 

wfLoadExtensionMessages('referenceName');

Note: referenceName is the same as in $wgExtensionMessagesFiles

 

Now you can use the multitude of wfMsg functions and the other i18n
functions to internationalize your content.  Again, it appears that after
the calling function is finished working, the messages are unloaded and you
need to load them again in any new function that you create.  

 

If I am sending people astray, please let me know,

 

Thanks,

Tim

 

 



More information about the MediaWiki-l mailing list