Extension:Narayam

Narayam is a Mediawiki extension that helps to add different language input methods for the various text input fields quickly. The primary users of this extension are from wikis that use non-latin scripts. Currently supported typing schemes are given below. You can file an enhancement bug in Mediawiki Bugzilla against Narayam extension for adding a new input method.

See also user help for this extension.

Usage
The primary aim is to allow users to input text in the wiki without the support of any external typing tools.

Download instructions
Download Narayam and put it in to a directory named  under   Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation
To install this extension, add the following to LocalSettings.php:

Configuration parameters
These are available configurations you can optionally specify on your LocalSettings.php.
 * Whether the input method should be active as default or not


 * Number of recently used input methods to be shown in the menu.


 * Whether the extension should load input methods in beta status. By default this false.

Indic scripts

 * Assamese [as]
 * Avro (Phonetic)
 * InScript
 * Bornona
 * Transliteration
 * Bengali [bn]
 * Avro (Phonetic)
 * InScript
 * National Keyboard
 * Bodo [brx]
 * InScript
 * Gujarati [gu]
 * Transliteration
 * InScript
 * Hindi [hi]
 * Transliteration
 * InScript
 * Kannada [kn]
 * Transliteration
 * InScript
 * Malayalam [ml]
 * Transliteration (Mozhi)
 * InScript
 * Marathi [mr]
 * Transliteration
 * InScript
 * Nepali [ne]
 * Transliteration
 * InScript
 * Odia [or]
 * Transliteration
 * Lekhani
 * InScript
 * Gurmukhi Punjabi [pa]
 * Phonetic
 * InScript
 * Sanskrit [sa]
 * Transliteration
 * InScript
 * Sinhala [si]
 * Singlish (Partial phonetic)
 * Wijesekara
 * Tamil [ta]
 * Transliteration
 * Tamil99

Arabic

 * Urdu [ur]: Standard

Latin

 * Esperanto [eo]: x-code transcription
 * German [de]: umlauts and sz

Cyrillic

 * Russian [ru]
 * Sakha [sah]

Other

 * Amharic [am] (experimental)
 * Tifinagh for Berber (Tachelhit [shi] and Tarifit [rif])

Developing a key mapping
More input methods can be added by writing scheme data. Schemes should be in a special format, by following that format any one can develop their own input methods.

A scheme consists of rules used for transliteration. A rule is an array of three strings. You do not need to add $ to the end of either of the regexes so they match at the end, this is done automagically.
 * 1) The first string is a regex that is matched against the input string (the last few characters before the cursor followed by the character the user entered),
 * 2) the second string is a regex that is matched against the end of the key buffer (the last few keys the user pressed), and
 * 3) the third string is the replacement string (may contain placeholders like $1 for subexpressions).

The transliteration algorithm processes the rules in the order they are specified, and applies the first rule that matches. For a rule to match, both the first and second regex have to match (the first for the input, the second for the key buffer). Most rules do not use the keybuffer and specify an empty string as the second regex.

The scheme data object must have the following keys:
 * namemsg: Message key for the name of the scheme
 * extended_keyboard: Whether this scheme has an extended ruleset (bool)
 * lookbackLength: Number of characters before the cursor to include when matching the first regex of each rule. This is usually the maximum number of characters a rule regex can match minus one.
 * keyBufferLength: Length of the key buffer. May be zero if not needed
 * rules: Array of rules, which themselves are arrays of three strings.
 * rules_x: Extended ruleset. This is used instead of the normal ruleset when Alt is held. This key is only required if extended_keyboard is true

Let's consider sample parts from Sanskrit Transliteration scheme, since it utilizes most features of rules.

In this map

are direct maps, that is, when we type 'a' it will produce 'अ' in the text field.

Usage on Wikimedia projects

 * Assamese, Malayalam, Odiya, Sanskrit, Sinhala and Tamil Wikimedia projects
 * Meta-wiki, Incubator, Wikimedia Commons, MediaWiki wiki.

Similar JavaScript keyboarding helpers are used at various Wikimedia wikis, for instance AVIM at Wikimedia's Vietnamese wikis.

User level customization
It is possible to override a set of rules in a Narayam scheme. This is not recommended if you are not familiar with JavaScript. A user level JavaScript like the given below modifies a keymap. With the above code snippet, we assign 4 to ₹ in Malayalam transliteration scheme. Note that any kind of JavaScript errors will make the extension unusable. Regular expression and complex rules are possible, but in those cases you know what you are doing. If you think a customization is useful for others too, please inform the developers.

Known issues
Extended keyboards seems to do work only within Firefox. Also, browsers do not provide a way to differentiate normal Alt and AltGr key events.

Related documents

 * File:Narayam-proposal-annotated.pdf (implemented)
 * File:Narayam-proposal.pdf (implemented)