resources: Upgrade jquery.i18n from 1.0.4 to 1.0.5
authorJames D. Forrester <jforrester@wikimedia.org>
Wed, 25 Jul 2018 14:58:24 +0000 (07:58 -0700)
committerJames D. Forrester <jforrester@wikimedia.org>
Wed, 1 Aug 2018 17:29:55 +0000 (13:29 -0400)
Change-Id: I9b7eebaec8fea6c328543ebf18afa8062c54efbe

26 files changed:
RELEASE-NOTES-1.32
resources/lib/jquery.i18n/CODE_OF_CONDUCT.md [new file with mode: 0644]
resources/lib/jquery.i18n/CREDITS
resources/lib/jquery.i18n/README.md
resources/lib/jquery.i18n/package.json [deleted file]
resources/lib/jquery.i18n/src/jquery.i18n.emitter.bidi.js
resources/lib/jquery.i18n/src/jquery.i18n.emitter.js
resources/lib/jquery.i18n/src/jquery.i18n.fallbacks.js
resources/lib/jquery.i18n/src/jquery.i18n.js
resources/lib/jquery.i18n/src/jquery.i18n.language.js
resources/lib/jquery.i18n/src/jquery.i18n.messagestore.js
resources/lib/jquery.i18n/src/jquery.i18n.parser.js
resources/lib/jquery.i18n/src/languages/bs.js
resources/lib/jquery.i18n/src/languages/dsb.js
resources/lib/jquery.i18n/src/languages/fi.js
resources/lib/jquery.i18n/src/languages/ga.js
resources/lib/jquery.i18n/src/languages/he.js
resources/lib/jquery.i18n/src/languages/hsb.js
resources/lib/jquery.i18n/src/languages/hu.js
resources/lib/jquery.i18n/src/languages/hy.js
resources/lib/jquery.i18n/src/languages/la.js
resources/lib/jquery.i18n/src/languages/ml.js
resources/lib/jquery.i18n/src/languages/os.js
resources/lib/jquery.i18n/src/languages/ru.js
resources/lib/jquery.i18n/src/languages/sl.js
resources/lib/jquery.i18n/src/languages/uk.js

index 95459b2..006476f 100644 (file)
@@ -79,6 +79,7 @@ production.
 * Updated wikimedia/wrappedstring from 2.3.0 to 3.0.1.
 * Updated mediawiki/mediawiki-codesniffer from v20.0.0 to v21.0.0.
 * Updated composer/spdx-licenses from 1.3.0 to 1.4.0.
+* Updated jquery.i18n from 1.0.4 to 1.0.5.
 
 ==== New external libraries ====
 * Added wikimedia/xmp-reader 0.5.1
diff --git a/resources/lib/jquery.i18n/CODE_OF_CONDUCT.md b/resources/lib/jquery.i18n/CODE_OF_CONDUCT.md
new file mode 100644 (file)
index 0000000..d8e5d08
--- /dev/null
@@ -0,0 +1 @@
+The development of this software is covered by a [Code of Conduct](https://www.mediawiki.org/wiki/Code_of_Conduct).
index 3a4eb5e..0ab6e56 100644 (file)
@@ -1,9 +1,24 @@
 Credits
 =======
 
-Santhosh Thottingal
-Amir E. Aharoni
-Siebrand Mazeland
-Niklas Laxström
-Neil Kandalgaonkar
-David Chan
+Major contributors
+
+Santhosh Thottingal <santhosh.thottingal@gmail.com>
+Amir E. Aharoni <amir.aharoni@mail.huji.ac.il>
+Niklas Laxström <niklas.laxstrom@gmail.com>
+James D. Forrester <jforrester@wikimedia.org>
+Siebrand Mazeland <s.mazeland@xs4all.nl>
+Kartik Mistry <kartik.mistry@gmail.com>
+Ricordisamoa <ricordisamoa@openmailbox.org>
+Timo Tijhof <krinklemail@gmail.com>
+Neil Kandalgaonkar <neilk@brevity.org>
+David Chan <david@troi.org>
+
+Libraries used
+
+CLDRPluralRuleParser
+ - https://github.com/santhoshtr/CLDRPluralRuleParser
+ – MIT license
+ - Santhosh Thottingal and other contributors
+
+And thanks to all patch contributors
\ No newline at end of file
index da82c2b..126cc93 100644 (file)
@@ -3,7 +3,7 @@ jQuery.i18n
 
 jQuery.i18n is a jQuery based Javascript internationalization library. It helps you to internationalize your web applications easily.
 
-This is a project by Wikimedia foundation's [Language Engineering team](http://wikimediafoundation.org/wiki/Language_Engineering_team) and used in some of the Wikimedia Foundation projects like Universal Language Selector.
+This is a project by Wikimedia foundation's [Language Engineering team](https://www.mediawiki.org/wiki/Wikimedia_Language_engineering) and used in some of the Wikimedia Foundation projects like Universal Language Selector.
 
 The jquery.i18n library uses a json based localization file format, "banana", which is used as the localization file format for  MediaWiki and other projects.
 
@@ -20,7 +20,7 @@ Features
 * Dynamic change of interface language without refreshing a webpage.
 * Nestable grammar, plural, gender support. These constructs can be nested to any arbitrary level for supporting sophisticated message localization
 * Message documentation through special language code ```qqq```
-* Extensible message parser to add or customize magic words in the messages. Example: ```{sitename}``` or ```[[link]]``
+* Extensible message parser to add or customize magic words in the messages. Example: ```{sitename}``` or ```[[link]]```
 
 
 Quick start
@@ -231,7 +231,7 @@ It is also possible to refer messages from an external URL. See below example
 $.i18n().load( {
        en: {
                message_hello: 'Hello World',
-       message_welcome: 'Welcome'
+               message_welcome: 'Welcome'
        },
        hi: 'i18n/messages-hi.json', // Messages for Hindi
        de: 'i18n/messages-de.json'
@@ -244,7 +244,7 @@ Messages for a locale can be also loaded in parts. Example
 $.i18n().load( {
        en: {
                message_hello: 'Hello World',
-       message_welcome: 'Welcome'
+               message_welcome: 'Welcome'
        }
 } );
 
@@ -273,7 +273,7 @@ $.i18n( 'message-key-sample1' );
 $.i18n( 'message-key-sample1' );
 $.i18n( 'Found $1 {{plural:$1|result|results}}', 10 ); // Message key itself is message text
 $.i18n( 'Showing $1 out of $2 {{plural:$2|result|results}}', 5,100 );
-$.i18n(User X updated {{gender|his|her}} profile', 'male' );
+$.i18n( 'User X updated {{gender|his|her}} profile', 'male' );
 
 $( '#foo' ).i18n(); // to translate the element matching jquery selector based on data-i18n key
 ```
@@ -299,7 +299,7 @@ Note that if data-i18n contains html markup, that html will not be used as the e
 Examples
 ========
 
-See http://thottingal.in/projects/js/jquery.i18n/demo/
+See https://thottingal.in/projects/js/jquery.i18n/demo/
 
 Message format
 ==============
@@ -327,7 +327,20 @@ $.i18n(message, 4); // This gives "Found 4 results"
 ```
 Note that {{PLURAL:...}} is not case sensitive. It can be {{plural:...}} too.
 
-In case of English, there are only 2 plural forms, but many languages use more than 2 plural forms. All the plural forms can be given in the above syntax, separated by pipe(|)
+In case of English, there are only 2 plural forms, but many languages use more than 2 plural forms. All the plural forms can be given in the above syntax, separated by pipe(|). The number of plural forms for each language is defined in [CLDR](https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html). You need to provide all those plural forms for a language.
+
+For example, English has 2 plural forms and the message format will look like `{{PLURAL:$1|one|other}}`. for Arabic there are 6 plural forms and format will look like `{{PLURAL:$1|zero|one|two|few|many|other}}`.
+
+You cannot skip a plural form from the middle or beginning. However you can skip from end. For example, in arabic, if the message is like
+`{{PLURAL:$1|A|B}}`, for 0, A will be used, for numbers that fall under one,two,few,many,other categories B will be used.
+
+If there is an explicit plural form to be given for a specific number, it is possible with the following syntax
+
+```
+var message = 'Box has {{PLURAL:$1|one egg|$1 eggs|12=a dozen eggs}}.';
+$.i18n(message, 4 ); // Gives "Box has 4 eggs."
+$.i18n(message, 12 ); // Gives "Box has a dozen eggs."
+```
 
 ## Gender
 Similar to plural, depending on gender of placeholders, mostly user names, the syntax changes dynamically. An example in English is "Alice changed her profile picture" and "Bob changed his profile picture". To support this {{GENDER...}} syntax can be used as show in example
@@ -397,13 +410,13 @@ $.extend( $.i18n.parser.emitter, {
 
 This will parse the message
 ```javascript
-$.i18n( '{{link:{{SITENAME}}|http://en.wikipedia.org}}' );
+$.i18n( '{{link:{{SITENAME}}|https://en.wikipedia.org}}' );
 ```
 
 to
 
 ```html
-<a href="http://en.wikipedia.org">Wikipedia</a>
+<a href="https://en.wikipedia.org">Wikipedia</a>
 ```
 
 Message documentation
diff --git a/resources/lib/jquery.i18n/package.json b/resources/lib/jquery.i18n/package.json
deleted file mode 100644 (file)
index d1c7f84..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-{
-  "name": "jquery.i18n",
-  "version": "1.0.4",
-  "description": "jQuery based internationalization library",
-  "homepage": "https://github.com/wikimedia/jquery.i18n",
-  "keywords": [
-    "internationalization",
-    "localization",
-    "i18n",
-    "jquery",
-    "l10n"
-  ],
-  "author": {
-    "name": "Santhosh Thottingal",
-    "email": "santhosh.thottingal@gmail.com"
-  },
-  "contributors": [
-    "Amir Aharoni <amir.aharoni@mail.huji.ac.il>",
-    "Niklas Laxström <nlaxstrom@wikimedia.org>",
-    "Neil Kandalgaonkar <neilk@brevity.org>",
-    "David Chan <david@troi.org>"
-  ],
-  "devDependencies": {
-    "qunit": "0.7.6",
-    "grunt": "0.4.5",
-    "grunt-cli": "0.1.13",
-    "grunt-contrib-jshint": "0.11.3",
-    "grunt-contrib-connect": "0.10.1",
-    "grunt-contrib-qunit": "0.7.0",
-    "grunt-contrib-watch": "0.6.1",
-    "grunt-jscs": "1.8.0"
-  },
-  "repository": {
-    "type": "git",
-    "url": "git://github.com/wikimedia/jquery.i18n.git"
-  },
-  "bugs": {
-      "url" : "http://github.com/wikimedia/jquery.i18n/issues"
-  },
-  "engine": {
-    "node": ">=0.8.x"
-  },
-  "license": "(MIT OR GPL-2.0)",
-  "scripts": {
-    "test": "grunt test --verbose"
-  }
-}
index 3a5b625..e245557 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*!
  * BIDI embedding support for jQuery.i18n
  *
  * Copyright (C) 2015, David Chan
@@ -24,7 +24,7 @@
         * Does not match if there is no strong directionality codepoint.
         *
         * Generated by UnicodeJS (see tools/strongDir) from the UCD; see
-        * https://git.wikimedia.org/summary/unicodejs.git .
+        * https://phabricator.wikimedia.org/diffusion/GUJS/ .
         */
        strongDirRegExp = new RegExp(
                '(?:' +
         *
         * TODO: Does not handle BIDI control characters inside the text.
         * TODO: Does not handle unallocated characters.
+        *
+        * @param {string} text The text from which to extract initial directionality.
+        * @return {string} Directionality (either 'ltr' or 'rtl')
         */
        function strongDirFromContent( text ) {
                var m = text.match( strongDirRegExp );
                if ( !m ) {
                        return null;
                }
-               if ( m[2] === undefined ) {
+               if ( m[ 2 ] === undefined ) {
                        return 'ltr';
                }
                return 'rtl';
                 * strong directional codepoint" rule. Essentially, this works round the fact that
                 * there is no embedding equivalent of U+2068 FSI (isolation with heuristic
                 * direction inference). The latter is cleaner but still not widely supported.
+                *
+                * @param {string[]} nodes The text nodes from which to take the first item.
+                * @return {string} Wrapped String of content as needed.
                 */
                bidi: function ( nodes ) {
-                       var dir = strongDirFromContent( nodes[0] );
+                       var dir = strongDirFromContent( nodes[ 0 ] );
                        if ( dir === 'ltr' ) {
                                // Wrap in LEFT-TO-RIGHT EMBEDDING ... POP DIRECTIONAL FORMATTING
-                               return '\u202A' + nodes[0] + '\u202C';
+                               return '\u202A' + nodes[ 0 ] + '\u202C';
                        }
                        if ( dir === 'rtl' ) {
                                // Wrap in RIGHT-TO-LEFT EMBEDDING ... POP DIRECTIONAL FORMATTING
-                               return '\u202B' + nodes[0] + '\u202C';
+                               return '\u202B' + nodes[ 0 ] + '\u202C';
                        }
                        // No strong directionality: do not wrap
-                       return nodes[0];
+                       return nodes[ 0 ];
                }
        } );
 }( jQuery ) );
index b26f147..330e50c 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*!
  * jQuery Internationalization library
  *
  * Copyright (C) 2011-2013 Santhosh Thottingal, Neil Kandalgaonkar
@@ -17,7 +17,7 @@
        'use strict';
 
        var MessageParserEmitter = function () {
-               this.language = $.i18n.languages[String.locale] || $.i18n.languages['default'];
+               this.language = $.i18n.languages[ String.locale ] || $.i18n.languages[ 'default' ];
        };
 
        MessageParserEmitter.prototype = {
                                messageParserEmitter = this;
 
                        switch ( typeof node ) {
-                       case 'string':
-                       case 'number':
-                               ret = node;
-                               break;
-                       case 'object':
+                               case 'string':
+                               case 'number':
+                                       ret = node;
+                                       break;
+                               case 'object':
                                // node is an array of nodes
-                               subnodes = $.map( node.slice( 1 ), function ( n ) {
-                                       return messageParserEmitter.emit( n, replacements );
-                               } );
+                                       subnodes = $.map( node.slice( 1 ), function ( n ) {
+                                               return messageParserEmitter.emit( n, replacements );
+                                       } );
 
-                               operation = node[0].toLowerCase();
+                                       operation = node[ 0 ].toLowerCase();
 
-                               if ( typeof messageParserEmitter[operation] === 'function' ) {
-                                       ret = messageParserEmitter[operation]( subnodes, replacements );
-                               } else {
-                                       throw new Error( 'unknown operation "' + operation + '"' );
-                               }
+                                       if ( typeof messageParserEmitter[ operation ] === 'function' ) {
+                                               ret = messageParserEmitter[ operation ]( subnodes, replacements );
+                                       } else {
+                                               throw new Error( 'unknown operation "' + operation + '"' );
+                                       }
 
-                               break;
-                       case 'undefined':
+                                       break;
+                               case 'undefined':
                                // Parsing the empty string (as an entire expression, or as a
                                // paramExpression in a template) results in undefined
                                // Perhaps a more clever parser can detect this, and return the
                                // empty string? Or is that useful information?
                                // The logical thing is probably to return the empty string here
                                // when we encounter undefined.
-                               ret = '';
-                               break;
-                       default:
-                               throw new Error( 'unexpected type in AST: ' + typeof node );
+                                       ret = '';
+                                       break;
+                               default:
+                                       throw new Error( 'unexpected type in AST: ' + typeof node );
                        }
 
                        return ret;
@@ -80,7 +80,7 @@
                 * in our children and pass them upwards
                 *
                 * @param {Array} nodes Mixed, some single nodes, some arrays of nodes.
-                * @return String
+                * @return {string}
                 */
                concat: function ( nodes ) {
                        var result = '';
                 * @return {string} replacement
                 */
                replace: function ( nodes, replacements ) {
-                       var index = parseInt( nodes[0], 10 );
+                       var index = parseInt( nodes[ 0 ], 10 );
 
                        if ( index < replacements.length ) {
                                // replacement is not a string, don't touch!
-                               return replacements[index];
+                               return replacements[ index ];
                        } else {
                                // index not found, fallback to displaying variable
                                return '$' + ( index + 1 );
                 * convertNumber.
                 *
                 * @param {Array} nodes List [ {String|Number}, {String}, {String} ... ]
-                * @return {String} selected pluralized form according to current
+                * @return {string} selected pluralized form according to current
                 *  language.
                 */
                plural: function ( nodes ) {
-                       var count = parseFloat( this.language.convertNumber( nodes[0], 10 ) ),
+                       var count = parseFloat( this.language.convertNumber( nodes[ 0 ], 10 ) ),
                                forms = nodes.slice( 1 );
 
                        return forms.length ? this.language.convertPlural( count, forms ) : '';
                 * {{gender:gender|masculine|feminine|neutral}}.
                 *
                 * @param {Array} nodes List [ {String}, {String}, {String} , {String} ]
-                * @return {String} selected gender form according to current language
+                * @return {string} selected gender form according to current language
                 */
                gender: function ( nodes ) {
-                       var gender = nodes[0],
+                       var gender = nodes[ 0 ],
                                forms = nodes.slice( 1 );
 
                        return this.language.gender( gender, forms );
                 * putting {{grammar:form|word}} in a message
                 *
                 * @param {Array} nodes List [{Grammar case eg: genitive}, {String word}]
-                * @return {String} selected grammatical form according to current
+                * @return {string} selected grammatical form according to current
                 *  language.
                 */
                grammar: function ( nodes ) {
-                       var form = nodes[0],
-                               word = nodes[1];
+                       var form = nodes[ 0 ],
+                               word = nodes[ 1 ];
 
                        return word && form && this.language.convertGrammar( word, form );
                }
index 4584c5f..74b16f2 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*!
  * jQuery Internationalization library
  *
  * Copyright (C) 2012 Santhosh Thottingal
@@ -11,7 +11,7 @@
  * @licence GNU General Public Licence 2.0 or later
  * @licence MIT License
  */
-( function ( $, undefined ) {
+( function ( $ ) {
        'use strict';
 
        $.i18n = $.i18n || {};
index 9236e4e..ef2fcc2 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*!
  * jQuery Internationalization library
  *
  * Copyright (C) 2012 Santhosh Thottingal
@@ -16,7 +16,7 @@
 ( function ( $ ) {
        'use strict';
 
-       var nav, I18N,
+       var I18N,
                slice = Array.prototype.slice;
        /**
         * @constructor
                this.locale = this.options.locale;
                this.messageStore = this.options.messageStore;
                this.languages = {};
-
-               this.init();
        };
 
        I18N.prototype = {
                /**
-                * Initialize by loading locales and setting up
-                * String.prototype.toLocaleString and String.locale.
+                * Localize a given messageKey to a locale.
+                * @param {String} messageKey
+                * @return {String} Localized message
                 */
-               init: function () {
-                       var i18n = this;
-
-                       // Set locale of String environment
-                       String.locale = i18n.locale;
-
-                       // Override String.localeString method
-                       String.prototype.toLocaleString = function () {
-                               var localeParts, localePartIndex, value, locale, fallbackIndex,
-                                       tryingLocale, message;
-
-                               value = this.valueOf();
-                               locale = i18n.locale;
-                               fallbackIndex = 0;
+               localize: function ( messageKey ) {
+                       var localeParts, localePartIndex, locale, fallbackIndex,
+                               tryingLocale, message;
 
-                               while ( locale ) {
-                                       // Iterate through locales starting at most-specific until
-                                       // localization is found. As in fi-Latn-FI, fi-Latn and fi.
-                                       localeParts = locale.split( '-' );
-                                       localePartIndex = localeParts.length;
+                       locale = this.locale;
+                       fallbackIndex = 0;
 
-                                       do {
-                                               tryingLocale = localeParts.slice( 0, localePartIndex ).join( '-' );
-                                               message = i18n.messageStore.get( tryingLocale, value );
+                       while ( locale ) {
+                               // Iterate through locales starting at most-specific until
+                               // localization is found. As in fi-Latn-FI, fi-Latn and fi.
+                               localeParts = locale.split( '-' );
+                               localePartIndex = localeParts.length;
 
-                                               if ( message ) {
-                                                       return message;
-                                               }
+                               do {
+                                       tryingLocale = localeParts.slice( 0, localePartIndex ).join( '-' );
+                                       message = this.messageStore.get( tryingLocale, messageKey );
 
-                                               localePartIndex--;
-                                       } while ( localePartIndex );
-
-                                       if ( locale === 'en' ) {
-                                               break;
+                                       if ( message ) {
+                                               return message;
                                        }
 
-                                       locale = ( $.i18n.fallbacks[i18n.locale] && $.i18n.fallbacks[i18n.locale][fallbackIndex] ) ||
-                                               i18n.options.fallbackLocale;
-                                       $.i18n.log( 'Trying fallback locale for ' + i18n.locale + ': ' + locale );
+                                       localePartIndex--;
+                               } while ( localePartIndex );
 
-                                       fallbackIndex++;
+                               if ( locale === 'en' ) {
+                                       break;
                                }
 
-                               // key not found
-                               return '';
-                       };
+                               locale = ( $.i18n.fallbacks[ this.locale ] &&
+                                               $.i18n.fallbacks[ this.locale ][ fallbackIndex ] ) ||
+                                               this.options.fallbackLocale;
+                               $.i18n.log( 'Trying fallback locale for ' + this.locale + ': ' + locale + ' (' + messageKey + ')' );
+
+                               fallbackIndex++;
+                       }
+
+                       // key not found
+                       return '';
                },
 
                /*
                 * If the data argument is null/undefined/false,
                 * all cached messages for the i18n instance will get reset.
                 *
-                * @param {String|Object} source
-                * @param {String} locale Language tag
-                * @returns {jQuery.Promise}
+                * @param {string|Object} source
+                * @param {string} locale Language tag
+                * @return {jQuery.Promise}
                 */
                load: function ( source, locale ) {
                        var fallbackLocales, locIndex, fallbackLocale, sourceMap = {};
                                source = 'i18n/' + $.i18n().locale + '.json';
                                locale = $.i18n().locale;
                        }
-                       if ( typeof source === 'string' &&
-                               source.split( '.' ).pop() !== 'json'
+                       if ( typeof source === 'string' &&
+                               // source extension should be json, but can have query params after that.
+                               source.split( '?' )[ 0 ].split( '.' ).pop() !== 'json'
                        ) {
-                               // Load specified locale then check for fallbacks when directory is specified in load()
-                               sourceMap[locale] = source + '/' + locale + '.json';
-                               fallbackLocales = ( $.i18n.fallbacks[locale] || [] )
+                               // Load specified locale then check for fallbacks when directory is
+                               // specified in load()
+                               sourceMap[ locale ] = source + '/' + locale + '.json';
+                               fallbackLocales = ( $.i18n.fallbacks[ locale ] || [] )
                                        .concat( this.options.fallbackLocale );
-                               for ( locIndex in fallbackLocales ) {
-                                       fallbackLocale = fallbackLocales[locIndex];
-                                       sourceMap[fallbackLocale] = source + '/' + fallbackLocale + '.json';
+                               for ( locIndex = 0; locIndex < fallbackLocales.length; locIndex++ ) {
+                                       fallbackLocale = fallbackLocales[ locIndex ];
+                                       sourceMap[ fallbackLocale ] = source + '/' + fallbackLocale + '.json';
                                }
                                return this.load( sourceMap );
                        } else {
                 * @return {string}
                 */
                parse: function ( key, parameters ) {
-                       var message = key.toLocaleString();
+                       var message = this.localize( key );
                        // FIXME: This changes the state of the I18N object,
                        // should probably not change the 'this.parser' but just
                        // pass it to the parser.
-                       this.parser.language = $.i18n.languages[$.i18n().locale] || $.i18n.languages['default'];
+                       this.parser.language = $.i18n.languages[ $.i18n().locale ] || $.i18n.languages[ 'default' ];
                        if ( message === '' ) {
                                message = key;
                        }
                // NOTE: It should only change language for this one call.
                // Then cache instances of I18N somewhere.
                if ( options && options.locale && i18n && i18n.locale !== options.locale ) {
-                       String.locale = i18n.locale = options.locale;
+                       i18n.locale = options.locale;
                }
 
                if ( !i18n ) {
                        i18n = new I18N();
                        $.data( document, 'i18n', i18n );
                }
-               String.locale = i18n.locale;
+
                return this.each( function () {
                        var $this = $( this ),
-                               messageKey = $this.data( 'i18n' );
+                               messageKey = $this.data( 'i18n' ),
+                               lBracket, rBracket, type, key;
 
                        if ( messageKey ) {
-                               $this.text( i18n.parse( messageKey ) );
+                               lBracket = messageKey.indexOf( '[' );
+                               rBracket = messageKey.indexOf( ']' );
+                               if ( lBracket !== -1 && rBracket !== -1 && lBracket < rBracket ) {
+                                       type = messageKey.slice( lBracket + 1, rBracket );
+                                       key = messageKey.slice( rBracket + 1 );
+                                       if ( type === 'html' ) {
+                                               $this.html( i18n.parse( key ) );
+                                       } else {
+                                               $this.attr( type, i18n.parse( key ) );
+                                       }
+                               } else {
+                                       $this.text( i18n.parse( messageKey ) );
+                               }
                        } else {
                                $this.find( '[data-i18n]' ).i18n();
                        }
                } );
        };
 
-       String.locale = String.locale || $( 'html' ).attr( 'lang' );
+       function getDefaultLocale() {
+               var nav, locale = $( 'html' ).attr( 'lang' );
 
-       if ( !String.locale ) {
-               if ( typeof window.navigator !== undefined ) {
-                       nav = window.navigator;
-                       String.locale = nav.language || nav.userLanguage || '';
-               } else {
-                       String.locale = '';
+               if ( !locale ) {
+                       if ( typeof window.navigator !== undefined ) {
+                               nav = window.navigator;
+                               locale = nav.language || nav.userLanguage || '';
+                       } else {
+                               locale = '';
+                       }
                }
+               return locale;
        }
 
        $.i18n.languages = {};
                parse: function ( message, parameters ) {
                        return message.replace( /\$(\d+)/g, function ( str, match ) {
                                var index = parseInt( match, 10 ) - 1;
-                               return parameters[index] !== undefined ? parameters[index] : '$' + match;
+                               return parameters[ index ] !== undefined ? parameters[ index ] : '$' + match;
                        } );
                },
                emitter: {}
        };
        /* Static members */
        I18N.defaults = {
-               locale: String.locale,
+               locale: getDefaultLocale(),
                fallbackLocale: 'en',
                parser: $.i18n.parser,
                messageStore: $.i18n.messageStore
index e596fbc..4e34576 100644 (file)
@@ -1,7 +1,8 @@
-/*global pluralRuleParser */
+/* global pluralRuleParser */
 ( function ( $ ) {
        'use strict';
 
+       // jscs:disable
        var language = {
                // CLDR plural rules generated using
                // libs/CLDRPluralRuleParser/tools/PluralXML2JSON.html
                                few: 'n % 100 = 3..10',
                                many: 'n % 100 = 11..99'
                        },
+                       ars: {
+                               zero: 'n = 0',
+                               one: 'n = 1',
+                               two: 'n = 2',
+                               few: 'n % 100 = 3..10',
+                               many: 'n % 100 = 11..99'
+                       },
+                       as: {
+                               one: 'i = 0 or n = 1'
+                       },
                        be: {
                                one: 'n % 10 = 1 and n % 100 != 11',
                                few: 'n % 10 = 2..4 and n % 100 != 12..14',
                        da: {
                                one: 'n = 1 or t != 0 and i = 0,1'
                        },
+                       dsb: {
+                               one: 'v = 0 and i % 100 = 1 or f % 100 = 1',
+                               two: 'v = 0 and i % 100 = 2 or f % 100 = 2',
+                               few: 'v = 0 and i % 100 = 3..4 or f % 100 = 3..4'
+                       },
                        fa: {
                                one: 'i = 0 or n = 1'
                        },
@@ -62,7 +78,7 @@
                                one: 'i = 0,1'
                        },
                        fil: {
-                               one: 'i = 0..1 and v = 0'
+                               one: 'v = 0 and i = 1,2,3 or v = 0 and i % 10 != 4,6,9 or v != 0 and f % 10 != 4,6,9'
                        },
                        fr: {
                                one: 'i = 0,1'
                                one: 'n = 0..1'
                        },
                        gv: {
-                               one: 'n % 10 = 1',
-                               two: 'n % 10 = 2',
-                               few: 'n % 100 = 0,20,40,60'
+                               one: 'v = 0 and i % 10 = 1',
+                               two: 'v = 0 and i % 10 = 2',
+                               few: 'v = 0 and i % 100 = 0,20,40,60,80',
+                               many: 'v != 0'
                        },
                        he: {
                                one: 'i = 1 and v = 0',
                                one: 'v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11',
                                few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14'
                        },
+                       hsb: {
+                               one: 'v = 0 and i % 100 = 1 or f % 100 = 1',
+                               two: 'v = 0 and i % 100 = 2 or f % 100 = 2',
+                               few: 'v = 0 and i % 100 = 3..4 or f % 100 = 3..4'
+                       },
                        hy: {
                                one: 'i = 0,1'
                        },
                                few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14',
                                many: 'v = 0 and i != 1 and i % 10 = 0..1 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 12..14'
                        },
-                       pt: {
-                               one: 'i = 1 and v = 0 or i = 0 and t = 1'
+                       prg: {
+                               zero: 'n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19',
+                               one: 'n % 10 = 1 and n % 100 != 11 or v = 2 and f % 10 = 1 and f % 100 != 11 or v != 2 and f % 10 = 1'
                        },
-                       // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
-                       pt_PT: {
-                               one: 'n = 1 and v = 0'
+                       pt: {
+                               one: 'i = 0..1'
                        },
-                       // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
                        ro: {
                                one: 'i = 1 and v = 0',
                                few: 'v != 0 or n = 0 or n != 1 and n % 100 = 1..19'
                        },
                        ru: {
                                one: 'v = 0 and i % 10 = 1 and i % 100 != 11',
+                               few: 'v = 0 and i % 10 = 2..4 and i % 100 != 12..14',
                                many: 'v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14'
                        },
                        se: {
                                one: 'n = 0..1'
                        },
                        tl: {
-                               one: 'i = 0..1 and v = 0'
+                               one: 'v = 0 and i = 1,2,3 or v = 0 and i % 10 != 4,6,9 or v != 0 and f % 10 != 4,6,9'
                        },
                        tzm: {
                                one: 'n = 0..1 or n = 11..99'
                                one: 'i = 0 or n = 1'
                        }
                },
+               // jscs:enable
 
                /**
                 * Plural form transformations, needed for some languages.
                 *
-                * @param count
-                *            integer Non-localized quantifier
-                * @param forms
-                *            array List of plural forms
-                * @return string Correct form for quantifier in this language
+                * @param {integer} count
+                *            Non-localized quantifier
+                * @param {Array} forms
+                *            List of plural forms
+                * @return {string} Correct form for quantifier in this language
                 */
                convertPlural: function ( count, forms ) {
                        var pluralRules,
 
                        // Handle for Explicit 0= & 1= values
                        for ( index = 0; index < forms.length; index++ ) {
-                               form = forms[index];
+                               form = forms[ index ];
                                if ( explicitPluralPattern.test( form ) ) {
-                                       formCount = parseInt( form.substring( 0, form.indexOf( '=' ) ), 10 );
+                                       formCount = parseInt( form.slice( 0, form.indexOf( '=' ) ), 10 );
                                        if ( formCount === count ) {
-                                               return ( form.substr( form.indexOf( '=' ) + 1 ) );
+                                               return ( form.slice( form.indexOf( '=' ) + 1 ) );
                                        }
-                                       forms[index] = undefined;
+                                       forms[ index ] = undefined;
                                }
                        }
 
                                }
                        } );
 
-                       pluralRules = this.pluralRules[$.i18n().locale];
+                       pluralRules = this.pluralRules[ $.i18n().locale ];
 
                        if ( !pluralRules ) {
                                // default fallback.
-                               return ( count === 1 ) ? forms[0] : forms[1];
+                               return ( count === 1 ) ? forms[ 0 ] : forms[ 1 ];
                        }
 
                        pluralFormIndex = this.getPluralForm( count, pluralRules );
                        pluralFormIndex = Math.min( pluralFormIndex, forms.length - 1 );
 
-                       return forms[pluralFormIndex];
+                       return forms[ pluralFormIndex ];
                },
 
                /**
                 * For the number, get the plural for index
                 *
-                * @param number
-                * @param pluralRules
-                * @return plural form index
+                * @param {integer} number
+                * @param {Object} pluralRules
+                * @return {integer} plural form index
                 */
                getPluralForm: function ( number, pluralRules ) {
                        var i,
                                pluralFormIndex = 0;
 
                        for ( i = 0; i < pluralForms.length; i++ ) {
-                               if ( pluralRules[pluralForms[i]] ) {
-                                       if ( pluralRuleParser( pluralRules[pluralForms[i]], number ) ) {
+                               if ( pluralRules[ pluralForms[ i ] ] ) {
+                                       if ( pluralRuleParser( pluralRules[ pluralForms[ i ] ], number ) ) {
                                                return pluralFormIndex;
                                        }
 
                 *
                 * @param {number} num Value to be converted
                 * @param {boolean} integer Convert the return value to an integer
+                * @return {string} The number converted into a String.
                 */
                convertNumber: function ( num, integer ) {
                        var tmp, item, i,
                                tmp = [];
 
                                for ( item in transformTable ) {
-                                       tmp[transformTable[item]] = item;
+                                       tmp[ transformTable[ item ] ] = item;
                                }
 
                                transformTable = tmp;
                        }
 
                        for ( i = 0; i < numberString.length; i++ ) {
-                               if ( transformTable[numberString[i]] ) {
-                                       convertedNumber += transformTable[numberString[i]];
+                               if ( transformTable[ numberString[ i ] ] ) {
+                                       convertedNumber += transformTable[ numberString[ i ] ];
                                } else {
-                                       convertedNumber += numberString[i];
+                                       convertedNumber += numberString[ i ];
                                }
                        }
 
                 * Override this method for languages that need special grammar rules
                 * applied dynamically.
                 *
-                * @param word {String}
-                * @param form {String}
-                * @return {String}
+                * @param {string} word
+                * @param {string} form
+                * @return {string}
                 */
-               convertGrammar: function ( word, form ) { /*jshint unused: false */
+               // eslint-disable-next-line no-unused-vars
+               convertGrammar: function ( word, form ) {
                        return word;
                },
 
                 *
                 * These details may be overriden per language.
                 *
-                * @param gender
-                *      string male, female, or anything else for neutral.
-                * @param forms
-                *      array List of gender forms
+                * @param {string} gender
+                *      male, female, or anything else for neutral.
+                * @param {Array} forms
+                *      List of gender forms
                 *
-                * @return string
+                * @return {string}
                 */
                gender: function ( gender, forms ) {
                        if ( !forms || forms.length === 0 ) {
                        }
 
                        while ( forms.length < 2 ) {
-                               forms.push( forms[forms.length - 1] );
+                               forms.push( forms[ forms.length - 1 ] );
                        }
 
                        if ( gender === 'male' ) {
-                               return forms[0];
+                               return forms[ 0 ];
                        }
 
                        if ( gender === 'female' ) {
-                               return forms[1];
+                               return forms[ 1 ];
                        }
 
-                       return ( forms.length === 3 ) ? forms[2] : forms[0];
+                       return ( forms.length === 3 ) ? forms[ 2 ] : forms[ 0 ];
                },
 
                /**
                 * Get the digit transform table for the given language
                 * See http://cldr.unicode.org/translation/numbering-systems
-                * @param language
-                * @returns {Array|boolean} List of digits in the passed language or false
+                *
+                * @param {string} language
+                * @return {Array|boolean} List of digits in the passed language or false
                 * representation, or boolean false if there is no information.
                 */
                digitTransformTable: function ( language ) {
                                bo: '༠༡༢༣༤༥༦༧༨༩' // FIXME use iso 639 codes
                        };
 
-                       if ( !tables[language] ) {
+                       if ( !tables[ language ] ) {
                                return false;
                        }
 
-                       return tables[language].split( '' );
+                       return tables[ language ].split( '' );
                }
        };
 
index 759295c..350be10 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*!
  * jQuery Internationalization library - Message Store
  *
  * Copyright (C) 2012 Santhosh Thottingal
@@ -12,7 +12,7 @@
  * @licence MIT License
  */
 
-( function ( $, window, undefined ) {
+( function ( $ ) {
        'use strict';
 
        var MessageStore = function () {
                this.sources = {};
        };
 
+       function jsonMessageLoader( url ) {
+               var deferred = $.Deferred();
+
+               $.getJSON( url )
+                       .done( deferred.resolve )
+                       .fail( function ( jqxhr, settings, exception ) {
+                               $.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception );
+                               // Ignore 404 exception, because we are handling fallabacks explicitly
+                               deferred.resolve();
+                       } );
+
+               return deferred.promise();
+       }
+
        /**
         * See https://github.com/wikimedia/jquery.i18n/wiki/Specification#wiki-Message_File_Loading
         */
@@ -41,8 +55,8 @@
                 * null/undefined/false,
                 * all cached messages for the i18n instance will get reset.
                 *
-                * @param {String|Object} source
-                * @param {String} locale Language tag
+                * @param {string|Object} source
+                * @param {string} locale Language tag
                 * @return {jQuery.Promise}
                 */
                load: function ( source, locale ) {
@@ -74,7 +88,7 @@
                                                locale = key;
                                                // No {locale} given, assume data is a group of languages,
                                                // call this function again for each language.
-                                               deferreds.push( messageStore.load( source[key], locale ) );
+                                               deferreds.push( messageStore.load( source[ key ], locale ) );
                                        }
                                }
                                return $.when.apply( $, deferreds );
                /**
                 * Set messages to the given locale.
                 * If locale exists, add messages to the locale.
-                * @param locale
-                * @param messages
+                *
+                * @param {string} locale
+                * @param {Object} messages
                 */
                set: function ( locale, messages ) {
-                       if ( !this.messages[locale] ) {
-                               this.messages[locale] = messages;
+                       if ( !this.messages[ locale ] ) {
+                               this.messages[ locale ] = messages;
                        } else {
-                               this.messages[locale] = $.extend( this.messages[locale], messages );
+                               this.messages[ locale ] = $.extend( this.messages[ locale ], messages );
                        }
                },
 
                /**
                 *
-                * @param locale
-                * @param messageKey
-                * @returns {Boolean}
+                * @param {string} locale
+                * @param {string} messageKey
+                * @return {boolean}
                 */
                get: function ( locale, messageKey ) {
-                       return this.messages[locale] && this.messages[locale][messageKey];
+                       return this.messages[ locale ] && this.messages[ locale ][ messageKey ];
                }
        };
 
-       function jsonMessageLoader( url ) {
-               var deferred = $.Deferred();
-
-               $.getJSON( url )
-                       .done( deferred.resolve )
-                       .fail( function ( jqxhr, settings, exception ) {
-                               $.i18n.log( 'Error in loading messages from ' + url + ' Exception: ' + exception );
-                               // Ignore 404 exception, because we are handling fallabacks explicitly
-                               deferred.resolve();
-                       } );
-
-               return deferred.promise();
-       }
-
        $.extend( $.i18n.messageStore, new MessageStore() );
-}( jQuery, window ) );
+}( jQuery ) );
index 3dea284..8c47e55 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*!
  * jQuery Internationalization library
  *
  * Copyright (C) 2011-2013 Santhosh Thottingal, Neil Kandalgaonkar
@@ -18,7 +18,7 @@
 
        var MessageParser = function ( options ) {
                this.options = $.extend( {}, $.i18n.parser.defaults, options );
-               this.language = $.i18n.languages[String.locale] || $.i18n.languages['default'];
+               this.language = $.i18n.languages[ String.locale ] || $.i18n.languages[ 'default' ];
                this.emitter = $.i18n.parser.emitter;
        };
 
@@ -30,7 +30,7 @@
                        return message.replace( /\$(\d+)/g, function ( str, match ) {
                                var index = parseInt( match, 10 ) - 1;
 
-                               return parameters[index] !== undefined ? parameters[index] : '$' + match;
+                               return parameters[ index ] !== undefined ? parameters[ index ] : '$' + match;
                        } );
                },
 
@@ -39,8 +39,8 @@
                                return this.simpleParse( message, replacements );
                        }
 
-                       this.emitter.language = $.i18n.languages[$.i18n().locale] ||
-                               $.i18n.languages['default'];
+                       this.emitter.language = $.i18n.languages[ $.i18n().locale ] ||
+                               $.i18n.languages[ 'default' ];
 
                        return this.emitter.emit( this.ast( message ), replacements );
                },
@@ -58,7 +58,7 @@
                                        var i, result;
 
                                        for ( i = 0; i < parserSyntax.length; i++ ) {
-                                               result = parserSyntax[i]();
+                                               result = parserSyntax[ i ]();
 
                                                if ( result !== null ) {
                                                        return result;
@@ -78,7 +78,7 @@
                                        result = [];
 
                                for ( i = 0; i < parserSyntax.length; i++ ) {
-                                       res = parserSyntax[i]();
+                                       res = parserSyntax[ i ]();
 
                                        if ( res === null ) {
                                                pos = originalPos;
                                return function () {
                                        var result = null;
 
-                                       if ( message.substr( pos, len ) === s ) {
+                                       if ( message.slice( pos, pos + len ) === s ) {
                                                result = s;
                                                pos += len;
                                        }
 
                        function makeRegexParser( regex ) {
                                return function () {
-                                       var matches = message.substr( pos ).match( regex );
+                                       var matches = message.slice( pos ).match( regex );
 
                                        if ( matches === null ) {
                                                return null;
                                        }
 
-                                       pos += matches[0].length;
+                                       pos += matches[ 0 ].length;
 
-                                       return matches[0];
+                                       return matches[ 0 ];
                                };
                        }
 
                        anyCharacter = makeRegexParser( /^./ );
                        dollar = makeStringParser( '$' );
                        digits = makeRegexParser( /^\d+/ );
-                       regularLiteral = makeRegexParser( /^[^{}\[\]$\\]/ );
-                       regularLiteralWithoutBar = makeRegexParser( /^[^{}\[\]$\\|]/ );
-                       regularLiteralWithoutSpace = makeRegexParser( /^[^{}\[\]$\s]/ );
+                       regularLiteral = makeRegexParser( /^[^{}[\]$\\]/ );
+                       regularLiteralWithoutBar = makeRegexParser( /^[^{}[\]$\\|]/ );
+                       regularLiteralWithoutSpace = makeRegexParser( /^[^{}[\]$\s]/ );
 
                        // There is a general pattern:
                        // parse a thing;
                        function escapedLiteral() {
                                var result = sequence( [ backslash, anyCharacter ] );
 
-                               return result === null ? null : result[1];
+                               return result === null ? null : result[ 1 ];
                        }
 
                        choice( [ escapedLiteral, regularLiteralWithoutSpace ] );
                                        return null;
                                }
 
-                               return [ 'REPLACE', parseInt( result[1], 10 ) - 1 ];
+                               return [ 'REPLACE', parseInt( result[ 1 ], 10 ) - 1 ];
                        }
 
                        templateName = transform(
                                // see $wgLegalTitleChars
                                // not allowing : due to the need to catch "PLURAL:$1"
-                               makeRegexParser( /^[ !"$&'()*,.\/0-9;=?@A-Z\^_`a-z~\x80-\xFF+\-]+/ ),
+                               makeRegexParser( /^[ !"$&'()*,./0-9;=?@A-Z^_`a-z~\x80-\xFF+-]+/ ),
 
                                function ( result ) {
                                        return result.toString();
                                        return null;
                                }
 
-                               expr = result[1];
+                               expr = result[ 1 ];
 
                                // use a "CONCAT" operator if there are multiple nodes,
                                // otherwise return the first node, raw.
-                               return expr.length > 1 ? [ 'CONCAT' ].concat( expr ) : expr[0];
+                               return expr.length > 1 ? [ 'CONCAT' ].concat( expr ) : expr[ 0 ];
                        }
 
                        function templateWithReplacement() {
                                var result = sequence( [ templateName, colon, replacement ] );
 
-                               return result === null ? null : [ result[0], result[2] ];
+                               return result === null ? null : [ result[ 0 ], result[ 2 ] ];
                        }
 
                        function templateWithOutReplacement() {
                                var result = sequence( [ templateName, colon, paramExpression ] );
 
-                               return result === null ? null : [ result[0], result[2] ];
+                               return result === null ? null : [ result[ 0 ], result[ 2 ] ];
                        }
 
                        templateContents = choice( [
                                                nOrMore( 0, templateParam )
                                        ] );
 
-                                       return res === null ? null : res[0].concat( res[1] );
+                                       return res === null ? null : res[ 0 ].concat( res[ 1 ] );
                                },
                                function () {
                                        var res = sequence( [ templateName, nOrMore( 0, templateParam ) ] );
                                                return null;
                                        }
 
-                                       return [ res[0] ].concat( res[1] );
+                                       return [ res[ 0 ] ].concat( res[ 1 ] );
                                }
                        ] );
 
                        function template() {
                                var result = sequence( [ openTemplate, templateContents, closeTemplate ] );
 
-                               return result === null ? null : result[1];
+                               return result === null ? null : result[ 1 ];
                        }
 
                        expression = choice( [ template, replacement, literal ] );
                        /*
                         * For success, the pos must have gotten to the end of the input
                         * and returned a non-null.
-                        * n.b. This is part of language infrastructure, so we do not throw an internationalizable message.
+                        * n.b. This is part of language infrastructure, so we do not throw an
+                        * internationalizable message.
                         */
                        if ( result === null || pos !== message.length ) {
                                throw new Error( 'Parse error at position ' + pos.toString() + ' in input: ' + message );
index 5370069..41862ac 100644 (file)
@@ -4,15 +4,15 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.bs = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.bs = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        switch ( form ) {
-                       case 'instrumental': // instrumental
-                               word = 's ' + word;
-                               break;
-                       case 'lokativ': // locative
-                               word = 'o ' + word;
-                               break;
+                               case 'instrumental': // instrumental
+                                       word = 's ' + word;
+                                       break;
+                               case 'lokativ': // locative
+                                       word = 'o ' + word;
+                                       break;
                        }
 
                        return word;
index cc069eb..a1d33ac 100644 (file)
@@ -4,7 +4,7 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.dsb = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.dsb = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        switch ( form ) {
                                case 'instrumental': // instrumental
index d8e9578..3452601 100644 (file)
@@ -7,7 +7,7 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.fi = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.fi = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        // vowel harmony flag
                        var aou = word.match( /[aou][^äöy]*$/i ),
                        }
 
                        switch ( form ) {
-                       case 'genitive':
-                               word += 'n';
-                               break;
-                       case 'elative':
-                               word += ( aou ? 'sta' : 'stä' );
-                               break;
-                       case 'partitive':
-                               word += ( aou ? 'a' : 'ä' );
-                               break;
-                       case 'illative':
+                               case 'genitive':
+                                       word += 'n';
+                                       break;
+                               case 'elative':
+                                       word += ( aou ? 'sta' : 'stä' );
+                                       break;
+                               case 'partitive':
+                                       word += ( aou ? 'a' : 'ä' );
+                                       break;
+                               case 'illative':
                                // Double the last letter and add 'n'
-                               word += word.substr( word.length - 1 ) + 'n';
-                               break;
-                       case 'inessive':
-                               word += ( aou ? 'ssa' : 'ssä' );
-                               break;
-                       default:
-                               word = origWord;
-                               break;
+                                       word += word.slice( -1 ) + 'n';
+                                       break;
+                               case 'inessive':
+                                       word += ( aou ? 'ssa' : 'ssä' );
+                                       break;
+                               default:
+                                       word = origWord;
+                                       break;
                        }
 
                        return word;
index 1aceab7..843673a 100644 (file)
@@ -4,31 +4,31 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.ga = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.ga = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        if ( form === 'ainmlae' ) {
                                switch ( word ) {
-                               case 'an Domhnach':
-                                       word = 'Dé Domhnaigh';
-                                       break;
-                               case 'an Luan':
-                                       word = 'Dé Luain';
-                                       break;
-                               case 'an Mháirt':
-                                       word = 'Dé Mháirt';
-                                       break;
-                               case 'an Chéadaoin':
-                                       word = 'Dé Chéadaoin';
-                                       break;
-                               case 'an Déardaoin':
-                                       word = 'Déardaoin';
-                                       break;
-                               case 'an Aoine':
-                                       word = 'Dé hAoine';
-                                       break;
-                               case 'an Satharn':
-                                       word = 'Dé Sathairn';
-                                       break;
+                                       case 'an Domhnach':
+                                               word = 'Dé Domhnaigh';
+                                               break;
+                                       case 'an Luan':
+                                               word = 'Dé Luain';
+                                               break;
+                                       case 'an Mháirt':
+                                               word = 'Dé Mháirt';
+                                               break;
+                                       case 'an Chéadaoin':
+                                               word = 'Dé Chéadaoin';
+                                               break;
+                                       case 'an Déardaoin':
+                                               word = 'Déardaoin';
+                                               break;
+                                       case 'an Aoine':
+                                               word = 'Dé hAoine';
+                                               break;
+                                       case 'an Satharn':
+                                               word = 'Dé Sathairn';
+                                               break;
                                }
                        }
 
index cbbe90b..b593429 100644 (file)
@@ -4,25 +4,25 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.he = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.he = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        switch ( form ) {
-                       case 'prefixed':
-                       case 'תחילית': // the same word in Hebrew
-                               // Duplicate prefixed "Waw", but only if it's not already double
-                               if ( word.substr( 0, 1 ) === 'ו' && word.substr( 0, 2 ) !== 'וו' ) {
-                                       word = 'ו' + word;
-                               }
+                               case 'prefixed':
+                               case 'תחילית': // the same word in Hebrew
+                                       // Duplicate prefixed "Waw", but only if it's not already double
+                                       if ( word.slice( 0, 1 ) === 'ו' && word.slice( 0, 2 ) !== 'וו' ) {
+                                               word = 'ו' + word;
+                                       }
 
-                               // Remove the "He" if prefixed
-                               if ( word.substr( 0, 1 ) === 'ה' ) {
-                                       word = word.substr( 1, word.length );
-                               }
+                                       // Remove the "He" if prefixed
+                                       if ( word.slice( 0, 1 ) === 'ה' ) {
+                                               word = word.slice( 1 );
+                                       }
 
-                               // Add a hyphen (maqaf) before numbers and non-Hebrew letters
-                               if ( word.substr( 0, 1 ) < 'א' || word.substr( 0, 1 ) > 'ת' ) {
-                                       word = '־' + word;
-                               }
+                                       // Add a hyphen (maqaf) before numbers and non-Hebrew letters
+                                       if ( word.slice( 0, 1 ) < 'א' || word.slice( 0, 1 ) > 'ת' ) {
+                                               word = '־' + word;
+                                       }
                        }
 
                        return word;
index 957616f..2beb8de 100644 (file)
@@ -4,15 +4,15 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.hsb = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.hsb = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        switch ( form ) {
-                       case 'instrumental': // instrumental
-                               word = 'z ' + word;
-                               break;
-                       case 'lokatiw': // lokatiw
-                               word = 'wo ' + word;
-                               break;
+                               case 'instrumental': // instrumental
+                                       word = 'z ' + word;
+                                       break;
+                               case 'lokatiw': // lokatiw
+                                       word = 'wo ' + word;
+                                       break;
                        }
 
                        return word;
index 1177b85..ec52f4c 100644 (file)
@@ -6,18 +6,18 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.hu = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.hu = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        switch ( form ) {
-                       case 'rol':
-                               word += 'ról';
-                               break;
-                       case 'ba':
-                               word += 'ba';
-                               break;
-                       case 'k':
-                               word += 'k';
-                               break;
+                               case 'rol':
+                                       word += 'ról';
+                                       break;
+                               case 'ba':
+                                       word += 'ba';
+                                       break;
+                               case 'k':
+                                       word += 'k';
+                                       break;
                        }
 
                        return word;
index 9c56899..5ecf7ba 100644 (file)
@@ -5,15 +5,15 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.hy = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.hy = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        if ( form === 'genitive' ) { // սեռական հոլով
-                               if ( word.substr( -1 ) === 'ա' ) {
-                                       word = word.substr( 0, word.length - 1 ) + 'այի';
-                               } else if ( word.substr( -1 ) === 'ո' ) {
-                                       word = word.substr( 0, word.length - 1 ) + 'ոյի';
-                               } else if ( word.substr( -4 ) === 'գիրք' ) {
-                                       word = word.substr( 0, word.length - 4 ) + 'գրքի';
+                               if ( word.slice( -1 ) === 'ա' ) {
+                                       word = word.slice( 0, -1 ) + 'այի';
+                               } else if ( word.slice( -1 ) === 'ո' ) {
+                                       word = word.slice( 0, -1 ) + 'ոյի';
+                               } else if ( word.slice( -4 ) === 'գիրք' ) {
+                                       word = word.slice( 0, -4 ) + 'գրքի';
                                } else {
                                        word = word + 'ի';
                                }
index 11c1122..1a6c92b 100644 (file)
@@ -7,45 +7,45 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.la = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.la = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        switch ( form ) {
-                       case 'genitive':
+                               case 'genitive':
                                // only a few declensions, and even for those mostly the singular only
-                               word = word.replace( /u[ms]$/i, 'i' ); // 2nd declension singular
-                               word = word.replace( /ommunia$/i, 'ommunium' ); // 3rd declension neuter plural (partly)
-                               word = word.replace( /a$/i, 'ae' ); // 1st declension singular
-                               word = word.replace( /libri$/i, 'librorum' ); // 2nd declension plural (partly)
-                               word = word.replace( /nuntii$/i, 'nuntiorum' ); // 2nd declension plural (partly)
-                               word = word.replace( /tio$/i, 'tionis' ); // 3rd declension singular (partly)
-                               word = word.replace( /ns$/i, 'ntis' );
-                               word = word.replace( /as$/i, 'atis' );
-                               word = word.replace( /es$/i, 'ei' ); // 5th declension singular
-                               break;
-                       case 'accusative':
+                                       word = word.replace( /u[ms]$/i, 'i' ); // 2nd declension singular
+                                       word = word.replace( /ommunia$/i, 'ommunium' ); // 3rd declension neuter plural (partly)
+                                       word = word.replace( /a$/i, 'ae' ); // 1st declension singular
+                                       word = word.replace( /libri$/i, 'librorum' ); // 2nd declension plural (partly)
+                                       word = word.replace( /nuntii$/i, 'nuntiorum' ); // 2nd declension plural (partly)
+                                       word = word.replace( /tio$/i, 'tionis' ); // 3rd declension singular (partly)
+                                       word = word.replace( /ns$/i, 'ntis' );
+                                       word = word.replace( /as$/i, 'atis' );
+                                       word = word.replace( /es$/i, 'ei' ); // 5th declension singular
+                                       break;
+                               case 'accusative':
                                // only a few declensions, and even for those mostly the singular only
-                               word = word.replace( /u[ms]$/i, 'um' ); // 2nd declension singular
-                               word = word.replace( /ommunia$/i, 'am' ); // 3rd declension neuter plural (partly)
-                               word = word.replace( /a$/i, 'ommunia' ); // 1st declension singular
-                               word = word.replace( /libri$/i, 'libros' ); // 2nd declension plural (partly)
-                               word = word.replace( /nuntii$/i, 'nuntios' );// 2nd declension plural (partly)
-                               word = word.replace( /tio$/i, 'tionem' ); // 3rd declension singular (partly)
-                               word = word.replace( /ns$/i, 'ntem' );
-                               word = word.replace( /as$/i, 'atem' );
-                               word = word.replace( /es$/i, 'em' ); // 5th declension singular
-                               break;
-                       case 'ablative':
+                                       word = word.replace( /u[ms]$/i, 'um' ); // 2nd declension singular
+                                       word = word.replace( /ommunia$/i, 'am' ); // 3rd declension neuter plural (partly)
+                                       word = word.replace( /a$/i, 'ommunia' ); // 1st declension singular
+                                       word = word.replace( /libri$/i, 'libros' ); // 2nd declension plural (partly)
+                                       word = word.replace( /nuntii$/i, 'nuntios' );// 2nd declension plural (partly)
+                                       word = word.replace( /tio$/i, 'tionem' ); // 3rd declension singular (partly)
+                                       word = word.replace( /ns$/i, 'ntem' );
+                                       word = word.replace( /as$/i, 'atem' );
+                                       word = word.replace( /es$/i, 'em' ); // 5th declension singular
+                                       break;
+                               case 'ablative':
                                // only a few declensions, and even for those mostly the singular only
-                               word = word.replace( /u[ms]$/i, 'o' ); // 2nd declension singular
-                               word = word.replace( /ommunia$/i, 'ommunibus' ); // 3rd declension neuter plural (partly)
-                               word = word.replace( /a$/i, 'a' ); // 1st declension singular
-                               word = word.replace( /libri$/i, 'libris' ); // 2nd declension plural (partly)
-                               word = word.replace( /nuntii$/i, 'nuntiis' ); // 2nd declension plural (partly)
-                               word = word.replace( /tio$/i, 'tione' ); // 3rd declension singular (partly)
-                               word = word.replace( /ns$/i, 'nte' );
-                               word = word.replace( /as$/i, 'ate' );
-                               word = word.replace( /es$/i, 'e' ); // 5th declension singular
-                               break;
+                                       word = word.replace( /u[ms]$/i, 'o' ); // 2nd declension singular
+                                       word = word.replace( /ommunia$/i, 'ommunibus' ); // 3rd declension neuter plural (partly)
+                                       word = word.replace( /a$/i, 'a' ); // 1st declension singular
+                                       word = word.replace( /libri$/i, 'libris' ); // 2nd declension plural (partly)
+                                       word = word.replace( /nuntii$/i, 'nuntiis' ); // 2nd declension plural (partly)
+                                       word = word.replace( /tio$/i, 'tione' ); // 3rd declension singular (partly)
+                                       word = word.replace( /ns$/i, 'nte' );
+                                       word = word.replace( /as$/i, 'ate' );
+                                       word = word.replace( /es$/i, 'e' ); // 5th declension singular
+                                       break;
                        }
 
                        return word;
index f724b7b..d9c82cf 100644 (file)
@@ -7,40 +7,40 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.ml = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.ml = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        form = form.toLowerCase();
                        switch ( form ) {
                                case 'ഉദ്ദേശിക':
                                case 'dative':
-                                       if ( word.substr( -1 ) === 'ു' ||
-                                               word.substr( -1 ) === 'ൂ' ||
-                                               word.substr( -1 ) === 'ൗ' ||
-                                               word.substr( -1 ) === 'ൌ'
+                                       if ( word.slice( -1 ) === 'ു' ||
+                                               word.slice( -1 ) === 'ൂ' ||
+                                               word.slice( -1 ) === 'ൗ' ||
+                                               word.slice( -1 ) === 'ൌ'
                                        ) {
                                                word += 'വിന്';
-                                       } else if ( word.substr( -1 ) === 'ം' ) {
-                                               word = word.substr( 0, word.length - 1 ) + 'ത്തിന്';
-                                       } else if ( word.substr( -1 ) === 'ൻ' ) {
+                                       } else if ( word.slice( -1 ) === 'ം' ) {
+                                               word = word.slice( 0, -1 ) + 'ത്തിന്';
+                                       } else if ( word.slice( -1 ) === 'ൻ' ) {
                                                // Atomic chillu n. അവൻ -> അവന്
-                                               word = word.substr( 0, word.length - 1 ) + 'ന്';
-                                       } else if ( word.substr( -3 ) === 'ന്\u200d' ) {
+                                               word = word.slice( 0, -1 ) + 'ന്';
+                                       } else if ( word.slice( -3 ) === 'ന്\u200d' ) {
                                                // chillu n. അവൻ -> അവന്
-                                               word = word.substr( 0, word.length - 1 );
-                                       } else if ( word.substr( -1 ) === 'ൾ' || word.substr( -3 ) === 'ള്\u200d' ) {
+                                               word = word.slice( 0, -1 );
+                                       } else if ( word.slice( -1 ) === 'ൾ' || word.slice( -3 ) === 'ള്\u200d' ) {
                                                word += 'ക്ക്';
-                                       } else if ( word.substr( -1 ) === 'ർ' || word.substr( -3 ) === 'ര്\u200d' ) {
+                                       } else if ( word.slice( -1 ) === 'ർ' || word.slice( -3 ) === 'ര്\u200d' ) {
                                                word += 'ക്ക്';
-                                       } else if ( word.substr( -1 ) === 'ൽ' ) {
+                                       } else if ( word.slice( -1 ) === 'ൽ' ) {
                                                // Atomic chillu ൽ , ഫയൽ -> ഫയലിന്
-                                               word = word.substr( 0, word.length - 1 ) + 'ലിന്';
-                                       } else if ( word.substr( -3 ) === 'ല്\u200d' ) {
+                                               word = word.slice( 0, -1 ) + 'ലിന്';
+                                       } else if ( word.slice( -3 ) === 'ല്\u200d' ) {
                                                // chillu ല്\u200d , ഫയല്\u200d -> ഫയലിന്
-                                               word = word.substr( 0, word.length - 2 ) + 'ിന്';
-                                       } else if ( word.substr( -2 ) === 'ു്' ) {
-                                               word = word.substr( 0, word.length - 2 ) + 'ിന്';
-                                       } else if ( word.substr( -1 ) === '്' ) {
-                                               word = word.substr( 0, word.length - 1 ) + 'ിന്';
+                                               word = word.slice( 0, -2 ) + 'ിന്';
+                                       } else if ( word.slice( -2 ) === 'ു്' ) {
+                                               word = word.slice( 0, -2 ) + 'ിന്';
+                                       } else if ( word.slice( -1 ) === '്' ) {
+                                               word = word.slice( 0, -1 ) + 'ിന്';
                                        } else {
                                                // കാവ്യ -> കാവ്യയ്ക്ക്, ഹരി -> ഹരിയ്ക്ക്, മല -> മലയ്ക്ക്
                                                word += 'യ്ക്ക്';
                                        break;
                                case 'സംബന്ധിക':
                                case 'genitive':
-                                       if ( word.substr( -1 ) === 'ം' ) {
-                                               word = word.substr( 0, word.length - 1 ) + 'ത്തിന്റെ';
-                                       } else if ( word.substr( -2 ) === 'ു്' ) {
-                                               word = word.substr( 0, word.length - 2 ) + 'ിന്റെ';
-                                       } else if ( word.substr( -1 ) === '്' ) {
-                                               word = word.substr( 0, word.length - 1 ) + 'ിന്റെ';
-                                       } else if (  word.substr( -1 ) === 'ു' ||
-                                               word.substr( -1 ) === 'ൂ' ||
-                                               word.substr( -1 ) === 'ൗ' ||
-                                               word.substr( -1 ) === 'ൌ'
+                                       if ( word.slice( -1 ) === 'ം' ) {
+                                               word = word.slice( 0, -1 ) + 'ത്തിന്റെ';
+                                       } else if ( word.slice( -2 ) === 'ു്' ) {
+                                               word = word.slice( 0, -2 ) + 'ിന്റെ';
+                                       } else if ( word.slice( -1 ) === '്' ) {
+                                               word = word.slice( 0, -1 ) + 'ിന്റെ';
+                                       } else if ( word.slice( -1 ) === 'ു' ||
+                                               word.slice( -1 ) === 'ൂ' ||
+                                               word.slice( -1 ) === 'ൗ' ||
+                                               word.slice( -1 ) === 'ൌ'
                                        ) {
                                                word += 'വിന്റെ';
-                                       } else if ( word.substr( -1 ) === 'ൻ' ) {
+                                       } else if ( word.slice( -1 ) === 'ൻ' ) {
                                                // Atomic chillu n. അവൻ -> അവന്റെ
-                                               word = word.substr( 0, word.length - 1 ) + 'ന്റെ';
-                                       } else if ( word.substr( -3 ) === 'ന്\u200d' ) {
+                                               word = word.slice( 0, -1 ) + 'ന്റെ';
+                                       } else if ( word.slice( -3 ) === 'ന്\u200d' ) {
                                                // chillu n. അവൻ -> അവന്റെ
-                                               word = word.substr( 0, word.length - 1 ) + 'റെ';
-                                       } else if ( word.substr( -3 ) === 'ള്\u200d' ) {
+                                               word = word.slice( 0, -1 ) + 'റെ';
+                                       } else if ( word.slice( -3 ) === 'ള്\u200d' ) {
                                                // chillu n. അവൾ -> അവളുടെ
-                                               word = word.substr( 0, word.length - 2 ) + 'ുടെ';
-                                       } else if ( word.substr( -1 ) === 'ൾ' ) {
+                                               word = word.slice( 0, -2 ) + 'ുടെ';
+                                       } else if ( word.slice( -1 ) === 'ൾ' ) {
                                                // Atomic chillu n. അവള്\u200d -> അവളുടെ
-                                               word = word.substr( 0, word.length - 1 ) + 'ളുടെ';
-                                       } else if ( word.substr( -1 ) === 'ൽ' ) {
+                                               word = word.slice( 0, -1 ) + 'ളുടെ';
+                                       } else if ( word.slice( -1 ) === 'ൽ' ) {
                                                // Atomic l. മുയല്\u200d -> മുയലിന്റെ
-                                               word = word.substr( 0, word.length - 1 ) + 'ലിന്റെ';
-                                       } else if ( word.substr( -3 ) === 'ല്\u200d' ) {
+                                               word = word.slice( 0, -1 ) + 'ലിന്റെ';
+                                       } else if ( word.slice( -3 ) === 'ല്\u200d' ) {
                                                // chillu l. മുയല്\u200d -> അവളുടെ
-                                               word = word.substr( 0, word.length - 2 ) + 'ിന്റെ';
-                                       } else if ( word.substr( -3 ) === 'ര്\u200d' ) {
+                                               word = word.slice( 0, -2 ) + 'ിന്റെ';
+                                       } else if ( word.slice( -3 ) === 'ര്\u200d' ) {
                                                // chillu r. അവര്\u200d -> അവരുടെ
-                                               word = word.substr( 0, word.length - 2 ) + 'ുടെ';
-                                       } else if ( word.substr( -1 ) === 'ർ' ) {
+                                               word = word.slice( 0, -2 ) + 'ുടെ';
+                                       } else if ( word.slice( -1 ) === 'ർ' ) {
                                                // Atomic chillu r. അവർ -> അവരുടെ
-                                               word = word.substr( 0, word.length - 1 ) + 'രുടെ';
+                                               word = word.slice( 0, -1 ) + 'രുടെ';
                                        } else {
                                                word += 'യുടെ';
                                        }
index 4744367..e788db9 100644 (file)
@@ -7,7 +7,7 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.os = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.os = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        var endAllative, jot, hyphen, ending;
 
@@ -22,7 +22,7 @@
 
                        if ( word.match( /тæ$/i ) ) {
                                // Checking if the $word is in plural form
-                               word = word.substring( 0, word.length - 1 );
+                               word = word.slice( 0, -1 );
                                endAllative = 'æм';
                        } else if ( word.match( /[аæеёиоыэюя]$/i ) ) {
                                // Works if word is in singular form.
@@ -34,8 +34,7 @@
                                // vowel 'U' in cyrillic Ossetic.
                                // Examples: {{grammar:genitive|аунеу}} = аунеуы,
                                // {{grammar:genitive|лæппу}} = лæппуйы.
-                               if ( !word.substring( word.length - 2, word.length - 1 )
-                                               .match( /[аæеёиоыэюя]$/i ) ) {
+                               if ( !word.slice( -2, -1 ).match( /[аæеёиоыэюя]$/i ) ) {
                                        jot = 'й';
                                }
                        } else if ( !word.match( /[бвгджзйклмнопрстфхцчшщьъ]$/i ) ) {
                        }
 
                        switch ( form ) {
-                       case 'genitive':
-                               ending = hyphen + jot + 'ы';
-                               break;
-                       case 'dative':
-                               ending = hyphen + jot + 'æн';
-                               break;
-                       case 'allative':
-                               ending = hyphen + endAllative;
-                               break;
-                       case 'ablative':
-                               if ( jot === 'й' ) {
-                                       ending = hyphen + jot + 'æ';
-                               } else {
-                                       ending = hyphen + jot + 'æй';
-                               }
-                               break;
-                       case 'superessive':
-                               ending = hyphen + jot + 'ыл';
-                               break;
-                       case 'equative':
-                               ending = hyphen + jot + 'ау';
-                               break;
-                       case 'comitative':
-                               ending = hyphen + 'имæ';
-                               break;
+                               case 'genitive':
+                                       ending = hyphen + jot + 'ы';
+                                       break;
+                               case 'dative':
+                                       ending = hyphen + jot + 'æн';
+                                       break;
+                               case 'allative':
+                                       ending = hyphen + endAllative;
+                                       break;
+                               case 'ablative':
+                                       if ( jot === 'й' ) {
+                                               ending = hyphen + jot + 'æ';
+                                       } else {
+                                               ending = hyphen + jot + 'æй';
+                                       }
+                                       break;
+                               case 'superessive':
+                                       ending = hyphen + jot + 'ыл';
+                                       break;
+                               case 'equative':
+                                       ending = hyphen + jot + 'ау';
+                                       break;
+                               case 'comitative':
+                                       ending = hyphen + 'имæ';
+                                       break;
                        }
 
                        return word + ending;
index 893b238..60fefff 100644 (file)
@@ -5,21 +5,21 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.ru = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.ru = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        if ( form === 'genitive' ) { // родительный падеж
-                               if ( word.substr( -1 ) === 'ь' ) {
-                                       word = word.substr( 0, word.length - 1 ) + 'я';
-                               } else if ( word.substr( -2 ) === 'ия' ) {
-                                       word = word.substr( 0, word.length - 2 ) + 'ии';
-                               } else if ( word.substr( -2 ) === 'ка' ) {
-                                       word = word.substr( 0, word.length - 2 ) + 'ки';
-                               } else if ( word.substr( -2 ) === 'ти' ) {
-                                       word = word.substr( 0, word.length - 2 ) + 'тей';
-                               } else if ( word.substr( -2 ) === 'ды' ) {
-                                       word = word.substr( 0, word.length - 2 ) + 'дов';
-                               } else if ( word.substr( -3 ) === 'ник' ) {
-                                       word = word.substr( 0, word.length - 3 ) + 'ника';
+                               if ( word.slice( -1 ) === 'ь' ) {
+                                       word = word.slice( 0, -1 ) + 'я';
+                               } else if ( word.slice( -2 ) === 'ия' ) {
+                                       word = word.slice( 0, -2 ) + 'ии';
+                               } else if ( word.slice( -2 ) === 'ка' ) {
+                                       word = word.slice( 0, -2 ) + 'ки';
+                               } else if ( word.slice( -2 ) === 'ти' ) {
+                                       word = word.slice( 0, -2 ) + 'тей';
+                               } else if ( word.slice( -2 ) === 'ды' ) {
+                                       word = word.slice( 0, -2 ) + 'дов';
+                               } else if ( word.slice( -3 ) === 'ник' ) {
+                                       word = word.slice( 0, -3 ) + 'ника';
                                }
                        }
 
index a3aafc3..0e14ed5 100644 (file)
@@ -5,7 +5,7 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.sl = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.sl = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        switch ( form ) {
                                // locative
index 8e69efc..f5292cf 100644 (file)
@@ -5,31 +5,31 @@
 ( function ( $ ) {
        'use strict';
 
-       $.i18n.languages.uk = $.extend( {}, $.i18n.languages['default'], {
+       $.i18n.languages.uk = $.extend( {}, $.i18n.languages[ 'default' ], {
                convertGrammar: function ( word, form ) {
                        switch ( form ) {
-                       case 'genitive': // родовий відмінок
-                               if ( word.substr( -1 ) === 'ь' ) {
-                                       word = word.substr( 0, word.length - 1 ) + 'я';
-                               } else if ( word.substr( -2 ) === 'ія' ) {
-                                       word = word.substr( 0, word.length - 2 ) + 'ії';
-                               } else if ( word.substr( -2 ) === 'ка' ) {
-                                       word = word.substr( 0, word.length - 2 ) + 'ки';
-                               } else if ( word.substr( -2 ) === 'ти' ) {
-                                       word = word.substr( 0, word.length - 2 ) + 'тей';
-                               } else if ( word.substr( -2 ) === 'ды' ) {
-                                       word = word.substr( 0, word.length - 2 ) + 'дов';
-                               } else if ( word.substr( -3 ) === 'ник' ) {
-                                       word = word.substr( 0, word.length - 3 ) + 'ника';
-                               }
+                               case 'genitive': // родовий відмінок
+                                       if ( word.slice( -1 ) === 'ь' ) {
+                                               word = word.slice( 0, -1 ) + 'я';
+                                       } else if ( word.slice( -2 ) === 'ія' ) {
+                                               word = word.slice( 0, -2 ) + 'ії';
+                                       } else if ( word.slice( -2 ) === 'ка' ) {
+                                               word = word.slice( 0, -2 ) + 'ки';
+                                       } else if ( word.slice( -2 ) === 'ти' ) {
+                                               word = word.slice( 0, -2 ) + 'тей';
+                                       } else if ( word.slice( -2 ) === 'ды' ) {
+                                               word = word.slice( 0, -2 ) + 'дов';
+                                       } else if ( word.slice( -3 ) === 'ник' ) {
+                                               word = word.slice( 0, -3 ) + 'ника';
+                                       }
 
-                               break;
-                       case 'accusative': // знахідний відмінок
-                               if ( word.substr( -2 ) === 'ія' ) {
-                                       word = word.substr( 0, word.length - 2 ) + 'ію';
-                               }
+                                       break;
+                               case 'accusative': // знахідний відмінок
+                                       if ( word.slice( -2 ) === 'ія' ) {
+                                               word = word.slice( 0, -2 ) + 'ію';
+                                       }
 
-                               break;
+                                       break;
                        }
 
                        return word;