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
In case the previous description was unclear, below is an example of what the extension does:
original wikitext:
Hello this is English, τηφσ ισ θοδδω, and back to English again.
processed to become this:
Hello this is English, <span lang="grc">τηφσ ισ θοδδω,</span> and back to English again.
The span attributes can be configured with a global configuration variable, as can the range of characters that should be enclosed in it.
Again, any response would be very welcome.
Nick
If the fonts are installed, willn't the operating system itself take care of rendering the correct fonts?
2012/11/19 Nick White nick.white@durham.ac.uk
In case the previous description was unclear, below is an example of what the extension does:
original wikitext:
Hello this is English, τηφσ ισ θοδδω, and back to English again.
processed to become this:
Hello this is English, <span lang="grc">τηφσ ισ θοδδω,</span> and back to English again.
The span attributes can be configured with a global configuration variable, as can the range of characters that should be enclosed in it.
Again, any response would be very welcome.
Nick
Mediawiki-i18n mailing list Mediawiki-i18n@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-i18n
2012/11/19 Harish mgharish@gmail.com:
If the fonts are installed, willn't the operating system itself take care of rendering the correct fonts?
Maybe, maybe not. Sometimes the default font doesn't work well with the text that the site author published. And very often the fonts are not installed. And most people hate installing fonts and don't bother doing it. That's why various web-fonts technologies are needed.
-- Amir
On Mon, Nov 19, 2012 at 10:59:12PM +0530, Harish wrote:
If the fonts are installed, willn't the operating system itself take care of rendering the correct fonts?
In my case there are two scripts used in different parts of the website, which require two different fonts in order to be correctly and attractively displayed.
So this extension ensures that the appropriate font is chosen for each script. Even if fonts with support for both scripts were installed, the browser would not automatically switch to a different font when showing different scripts. The extension uses the span tag linked to CSS to tell it which script certain parts are in, and hence which font to use.
mediawiki-i18n@lists.wikimedia.org