I'm making some changes to MediaWiki's localisation files, to make them easier to write, and to improve loading speed at runtime. I've often complained about the fact that MediaWiki's LanguageXx.php files force every would-be translator to also be a programmer. What I'm doing with this change is to make it so that in 90% of cases, a LanguageXx.php file won't be necessary, its function will be replaced by the simpler MessagesXx.php file.
The format of the MessagesXx.php file will look like this:
<?php $fallback = 'en'; $rtl = false; $timeBeforeDate = true; $timeSeparator = ':'; $timeDateSeparator = ', '; $digitTransformTable = null; $separatorTransformTable = null;
$namespaceNames = array( NS_MEDIA => 'Media', ... );
$quickbarSettings = array( ... );
$skinNames = array( ... );
$mathNames = array( ... );
$dateFormats = array( MW_DATE_DEFAULT => 'No preference', ... );
$bookstoreList = array( ... );
$weekdayNames = array( ... );
$monthNames = array( ... ); $monthNamesGen = array( ... );
$monthAbbreviations = array( ... );
$magicWords = array( # ID CASE SYNONYMS 'redirect' => array( 0, '#REDIRECT' ), ... );
$messages = array( ... ); ?>
Note that there are no globals, no classes, and no language code variable name suffixes. The language code is simply specified by the filename. The $fallback variable specifies a fallback language which should be used if anything in the present localisation file is missing. If $fallback is missing, English will be used.
If the localisation is sufficiently specified by these variables (and any others we think need to be added), then the LanguageXx.php file will not be needed. In cases where the language file needs to be kept, due to special code, all of the customised accessors for the above variables will be deleted, leaving only the special code.
The contents of the MessagesXx.php files will be cached, if a cache is available. The modification time of the file will be checked on every request, so when the file is updated, the cache is immediately invalidated.
I've already done most of the technical work for this change, including converting three languages as a pilot. Most of what remains is the rote work of converting all of the language files. I might consider committing what I've done to a branch, if someone else wants to help out with this.
Also in my working copy at the moment is a scheme to delay the initialisation of most object global variables, but that's a topic for another post.
-- Tim Starling
On Mon, 2006-17-07 at 16:45 +1000, Tim Starling wrote:
I've already done most of the technical work for this change, including converting three languages as a pilot. Most of what remains is the rote work of converting all of the language files.
Ugh. That is a lot of tedious rote work. Are the advantages of this new system worth the work and the instability?
~Evan
Evan Prodromou wrote:
On Mon, 2006-17-07 at 16:45 +1000, Tim Starling wrote:
I've already done most of the technical work for this change, including converting three languages as a pilot. Most of what remains is the rote work of converting all of the language files.
Ugh. That is a lot of tedious rote work. Are the advantages of this new system worth the work and the instability?
Yes. The language files as they stand are very difficult to maintain. There are so many ugly hacks, so many designs and programming styles, so many complex functions copied and pasted with a minor change. Separating the data from the code will pay dividends in the long term. It's only a few days' work anyway.
-- Tim Starling
On Tue, 2006-18-07 at 02:57 +1000, Tim Starling wrote:
Ugh. That is a lot of tedious rote work. Are the advantages of this new system worth the work and the instability?
Yes. The language files as they stand are very difficult to maintain. There are so many ugly hacks, so many designs and programming styles, so many complex functions copied and pasted with a minor change. Separating the data from the code will pay dividends in the long term. It's only a few days' work anyway.
Good, sounds like the right thing, then.
~Evan
wikitech-l@lists.wikimedia.org