Extension:Narayam

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png

Release status: stable

Implementation Hook
Description Allows to add custom input methods for input fields.
Author(s) Junaid P V (JunaidpvTalk)
Last version 0.2 (2011-02-25)
MediaWiki 1.18 or later
PHP 5.1 or later
License GPLv3
Download Download snapshot
Subversion [Help]

Browse source code
View code changes

Parameters

$wgNarayamConfig['shortcut_controlkey'] = true; $wgNarayamConfig['shortcut_altkey'] = false; $wgNarayamConfig['shortcut_shiftkey'] = false; $wgNarayamConfig['shortcut_metakey'] = false; $wgNarayamConfig['shortcut_key'] = 'M'; $wgNarayamConfig['schemes'] = array('ml', 'ta99', 'ml_inscript'); $wgNarayamConfig['default_scheme_index'] = 0; $wgNarayamConfig['enabled'] = true;

Hooks used
BeforePageDisplay

GetPreferences

Check usage (experimental)

Contents

[edit] What can this extension do?

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 here. You can file an enhancement bug in Mediawiki Bugzilla against Narayam extension for adding a new input method.

[edit] Usage

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

[edit] Download instructions

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

[edit] Installation

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

require_once("$IP/extensions/Narayam/Narayam.php");

[edit] 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
$wgNarayamEnabledByDefault = true;
  • Number of recently used input methods to be shown in the menu.
$wgNarayamRecentItemsLength = 3;
  • Whether the extension should load input methods in beta status. By default this false.
$wgNarayamUseBetaMapping = true;

[edit] Supported schemes

[edit] 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

[edit] Arabic

  • Urdu [ur]: Standard

[edit] Latin

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

[edit] Cyrillic

  • Russian [ru]
  • Sakha [sah]

[edit] Other

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

[edit] 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.

  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).

You do not need to add $ to the end of either of the regexes so they match at the end, this is done automagically.

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.

var rules = [
['क्h','c','च्'],
['\\\\([A-Za-z\\>_~\\.0-9])','\\\\','$1'],
['([क-ह]़?)्A', '','$1ा'],
['अa', '','आ'],
['a', '','अ'],
['b', '','ब्'],
['\\.', '','।'],
];
 
jQuery.narayam.addScheme( 'sa', {
        'namemsg': 'narayam-sa',
        'extended_keyboard': false,
        'lookbackLength': 4,
        'keyBufferLength': 1,
        'rules': rules
} );

In this map

['a', '','अ'],
['b', '','ब्'],

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

[edit] 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.

[edit] 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.

[edit] See also

[edit] Related documents

Personal tools
Namespaces

Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox