[Mediawiki-i18n] Extension to wrap certain characters in a span

Nick White nick.white at durham.ac.uk
Thu Nov 15 18:12:32 UTC 2012


Hi i18n folks,

I'm working on a wiki at the moment that has two different
languages, which need different fonts (English and Ancient Greek).
I'm setting the font with CSS using font-family (the same way it's
done in the WebFonts extension, but I'm just using my own little
extension for now), matching <span lang="mylang"> tags as appropriate.

However it's annoying to have to manually specify which language is
being used, when the range of characters contains this information.
So I wrote a little extension which automatically adds the needed
span tags before outputting the HTML. This means the correct font
will be chosen automatically.

I'm posting it here for a few reasons:
1) In the hopes that it may be useful to others (if it is seen as
   generally useful I'll add it to the wiki).
2) In case there's a better way to do this that I haven't thought
   of.
3) So somebody can pick holes in the code, if there are any.

The major flaw in it at the moment is that you can only specify one
set of characters and language attribute, so it won't work well for
wikis with multiple different scripts. This could probably be fixed
by using global variables to set things up more smartly.

The attached .php file is the whole extension. Any feedback would be
very warmly accepted.

Nick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: charspan.php
Type: application/x-httpd-php
Size: 1843 bytes
Desc: not available
URL: <http://lists.wikimedia.org/pipermail/mediawiki-i18n/attachments/20121115/ad0788c3/attachment.php>


More information about the Mediawiki-i18n mailing list