User talk:Conrad.Irwin/Transliterator.php

From Wiktionary, the free dictionary
Jump to navigation Jump to search
Many more details can be found at http://mediawiki.org/wiki/Extension:Transliterator.

This is a PHP extension designed to allow automatic transliteration where this is possible. I am told that it is possible for many languages, certainly for Armenian, Korean, and Greek, Serbian/Serbo-Croation should also be possible. For languages where it is not automatically possible, tough cookies.

The approach is very simplistic, it is supplied with a list of rules (those for Armenian are attached) and it transliterates by matching rules from longest to shortest against the string.

In order to use the extension, you simply call "{{transliterate:amn|խաչակրաց արշավանք}}" and it will give you "xačakrac’ aršavank’". The extension has been designed to be used in generic templates, so it is possible to use it without requiring any form of {{#ifexists:}} check (and internally it checks which rules exist much more efficiently).

For example, a template like term might use the form [[{{{word}}}]]{{transliteration:{{{lang}}}|{{{word}}}| ($1)|{{{tr|}}}}}. This would give the following:

The syntax for defining rules is fairly simple, and they can be specified in terms of either letters or NFD code-points. Most languages should use the letters form, so that "á" and "a" are different unrelated characters, however for some languages, like Korean, it is useful to be able to analyze the decomposed form.
















Start a discussion about User:Conrad.Irwin/Transliterator.php

Start a discussion