diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2014-12-27 15:41:37 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2014-12-31 11:43:28 +0100 |
commit | c1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch) | |
tree | 2b38796e738dd74cb42ecd9bfd151803108386bc /resources/mediawiki.language | |
parent | b88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff) |
Update to MediaWiki 1.24.1
Diffstat (limited to 'resources/mediawiki.language')
18 files changed, 0 insertions, 987 deletions
diff --git a/resources/mediawiki.language/languages/bs.js b/resources/mediawiki.language/languages/bs.js deleted file mode 100644 index 65eb5a6d..00000000 --- a/resources/mediawiki.language/languages/bs.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Bosnian (bosanski) language functions - */ - -mediaWiki.language.convertGrammar = function ( word, form ) { - var grammarForms = mediaWiki.language.getData( 'bs', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - switch ( form ) { - case 'instrumental': // instrumental - word = 's ' + word; - break; - case 'lokativ': // locative - word = 'o ' + word; - break; - } - return word; -}; diff --git a/resources/mediawiki.language/languages/dsb.js b/resources/mediawiki.language/languages/dsb.js deleted file mode 100644 index b2c9c081..00000000 --- a/resources/mediawiki.language/languages/dsb.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Lower Sorbian (Dolnoserbski) language functions - */ - -mediaWiki.language.convertGrammar = function ( word, form ) { - var grammarForms = mediaWiki.language.getData( 'dsb', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - switch ( form ) { - case 'instrumental': // instrumental - word = 'z ' + word; - break; - case 'lokatiw': // lokatiw - word = 'wo ' + word; - break; - } - return word; -}; diff --git a/resources/mediawiki.language/languages/fi.js b/resources/mediawiki.language/languages/fi.js deleted file mode 100644 index 61c6c104..00000000 --- a/resources/mediawiki.language/languages/fi.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Finnish (Suomi) language functions - * @author Santhosh Thottingal - */ - -mediaWiki.language.convertGrammar = function ( word, form ) { - var grammarForms, aou, origWord; - - grammarForms = mediaWiki.language.getData( 'fi', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - - // vowel harmony flag - aou = word.match( /[aou][^äöy]*$/i ); - origWord = word; - if ( word.match( /wiki$/i ) ) { - aou = false; - } - //append i after final consonant - if ( word.match( /[bcdfghjklmnpqrstvwxz]$/i ) ) { - word += 'i'; - } - - switch ( form ) { - 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; - } - return word; -}; diff --git a/resources/mediawiki.language/languages/ga.js b/resources/mediawiki.language/languages/ga.js deleted file mode 100644 index c13e8321..00000000 --- a/resources/mediawiki.language/languages/ga.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Irish (Gaeilge) language functions - */ - -mediaWiki.language.convertGrammar = function ( word, form ) { - /*jshint onecase:true */ - var grammarForms = mediaWiki.language.getData( 'ga', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - switch ( form ) { - case '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; - } - } - return word; -}; diff --git a/resources/mediawiki.language/languages/he.js b/resources/mediawiki.language/languages/he.js deleted file mode 100644 index 13d457b2..00000000 --- a/resources/mediawiki.language/languages/he.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Hebrew (עברית) language functions - */ - -mediaWiki.language.convertGrammar = function( word, form ) { - var grammarForms = mediaWiki.language.getData( 'he', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - 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; - } - - // Remove the "He" if prefixed - if ( word.substr( 0, 1 ) === 'ה' ) { - word = word.substr( 1, word.length ); - } - - // Add a hyphen (maqaf) before numbers and non-Hebrew letters - if ( word.substr( 0, 1 ) < 'א' || word.substr( 0, 1 ) > 'ת' ) { - word = '־' + word; - } - } - return word; -}; diff --git a/resources/mediawiki.language/languages/hsb.js b/resources/mediawiki.language/languages/hsb.js deleted file mode 100644 index 77dca75e..00000000 --- a/resources/mediawiki.language/languages/hsb.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Upper Sorbian (Hornjoserbsce) language functions - */ - -mediaWiki.language.convertGrammar = function ( word, form ) { - var grammarForms = mediaWiki.language.getData( 'hsb', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - switch ( form ) { - case 'instrumental': // instrumental - word = 'z ' + word; - break; - case 'lokatiw': // lokatiw - word = 'wo ' + word; - break; - } - return word; -}; diff --git a/resources/mediawiki.language/languages/hu.js b/resources/mediawiki.language/languages/hu.js deleted file mode 100644 index 23b0c125..00000000 --- a/resources/mediawiki.language/languages/hu.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Hungarian language functions - * @author Santhosh Thottingal - */ - -mediaWiki.language.convertGrammar = function ( word, form ) { - var grammarForms = mediaWiki.language.getData( 'hu', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - switch ( form ) { - case 'rol': - word += 'ról'; - break; - case 'ba': - word += 'ba'; - break; - case 'k': - word += 'k'; - break; - } - return word; -}; diff --git a/resources/mediawiki.language/languages/hy.js b/resources/mediawiki.language/languages/hy.js deleted file mode 100644 index 65081bdd..00000000 --- a/resources/mediawiki.language/languages/hy.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Armenian (Հայերեն) language functions - */ - -mediaWiki.language.convertGrammar = function ( word, form ) { - /*jshint onecase:true */ - var grammarForms = mediaWiki.language.getData( 'hy', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - - // These rules are not perfect, but they are currently only used for site names so it doesn't - // matter if they are wrong sometimes. Just add a special case for your site name if necessary. - - switch ( form ) { - case '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 ) + 'գրքի'; - } else { - word = word + 'ի'; - } - break; - } - return word; -}; diff --git a/resources/mediawiki.language/languages/la.js b/resources/mediawiki.language/languages/la.js deleted file mode 100644 index 27110241..00000000 --- a/resources/mediawiki.language/languages/la.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Latin (lingua Latina) language functions - * @author Santhosh Thottingal - */ - -mediaWiki.language.convertGrammar = function ( word, form ) { - var grammarForms = mediaWiki.language.getData( 'la', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - switch ( form ) { - 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': - // 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': - // 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; - } - return word; -}; diff --git a/resources/mediawiki.language/languages/os.js b/resources/mediawiki.language/languages/os.js deleted file mode 100644 index 682b3903..00000000 --- a/resources/mediawiki.language/languages/os.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Ossetian (Ирон) language functions - * @author Santhosh Thottingal - */ - - -mediaWiki.language.convertGrammar = function ( word, form ) { - var grammarForms = mediaWiki.language.getData( 'os', 'grammarForms' ), - // Ending for allative case - endAllative = 'мæ', - // Variable for 'j' beetwen vowels - jot = '', - // Variable for "-" for not Ossetic words - hyphen = '', - // Variable for ending - ending = ''; - - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - // Checking if the $word is in plural form - if ( word.match( /тæ$/i ) ) { - word = word.substring( 0, word.length - 1 ); - endAllative = 'æм'; - } - // Works if word is in singular form. - // Checking if word ends on one of the vowels: е, ё, и, о, ы, э, ю, я. - else if ( word.match( /[аæеёиоыэюя]$/i ) ) { - jot = 'й'; - } - // Checking if word ends on 'у'. 'У' can be either consonant 'W' or vowel 'U' in cyrillic Ossetic. - // Examples: {{grammar:genitive|аунеу}} = аунеуы, {{grammar:genitive|лæппу}} = лæппуйы. - else if ( word.match( /у$/i ) ) { - if ( ! word.substring( word.length-2, word.length-1 ).match( /[аæеёиоыэюя]$/i ) ) { - jot = 'й'; - } - } else if ( !word.match( /[бвгджзйклмнопрстфхцчшщьъ]$/i ) ) { - hyphen = '-'; - } - - 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; - } - return word + ending; -}; diff --git a/resources/mediawiki.language/languages/ru.js b/resources/mediawiki.language/languages/ru.js deleted file mode 100644 index 1bc06326..00000000 --- a/resources/mediawiki.language/languages/ru.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Russian (Русский) language functions - */ - -// These tests were originally made for names of Wikimedia -// websites, so they don't currently cover all the possible -// cases. - -mediaWiki.language.convertGrammar = function ( word, form ) { - 'use strict'; - - var grammarForms = mediaWiki.language.getData( 'ru', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - switch ( form ) { - case 'genitive': // родительный падеж - if ( word.substr( word.length - 1 ) === 'ь' ) { - word = word.substr(0, word.length - 1 ) + 'я'; - } else if ( word.substr( word.length - 2 ) === 'ия' ) { - word = word.substr(0, word.length - 2 ) + 'ии'; - } else if ( word.substr( word.length - 2 ) === 'ка' ) { - word = word.substr(0, word.length - 2 ) + 'ки'; - } else if ( word.substr( word.length - 2 ) === 'ти' ) { - word = word.substr(0, word.length - 2 ) + 'тей'; - } else if ( word.substr( word.length - 2 ) === 'ды' ) { - word = word.substr(0, word.length - 2 ) + 'дов'; - } else if ( word.substr( word.length - 3 ) === 'ные' ) { - word = word.substr(0, word.length - 3 ) + 'ных'; - } else if ( word.substr( word.length - 3 ) === 'ник' ) { - word = word.substr(0, word.length - 3 ) + 'ника'; - } - break; - case 'prepositional': // предложный падеж - if ( word.substr( word.length - 1 ) === 'ь' ) { - word = word.substr(0, word.length - 1 ) + 'е'; - } else if ( word.substr( word.length - 2 ) === 'ия' ) { - word = word.substr(0, word.length - 2 ) + 'ии'; - } else if ( word.substr( word.length - 2 ) === 'ка' ) { - word = word.substr(0, word.length - 2 ) + 'ке'; - } else if ( word.substr( word.length - 2 ) === 'ти' ) { - word = word.substr(0, word.length - 2 ) + 'тях'; - } else if ( word.substr( word.length - 2 ) === 'ды' ) { - word = word.substr(0, word.length - 2 ) + 'дах'; - } else if ( word.substr( word.length - 3 ) === 'ные' ) { - word = word.substr(0, word.length - 3 ) + 'ных'; - } else if ( word.substr( word.length - 3 ) === 'ник' ) { - word = word.substr(0, word.length - 3 ) + 'нике'; - } - break; - } - return word; -}; diff --git a/resources/mediawiki.language/languages/sl.js b/resources/mediawiki.language/languages/sl.js deleted file mode 100644 index fb335b6a..00000000 --- a/resources/mediawiki.language/languages/sl.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Slovenian (Slovenščina) language functions - */ - -mediaWiki.language.convertGrammar = function ( word, form ) { - var grammarForms = mediaWiki.language.getData( 'sl', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - switch ( form ) { - case 'mestnik': // locative - word = 'o ' + word; - break; - case 'orodnik': // instrumental - word = 'z ' + word; - break; - } - return word; -}; diff --git a/resources/mediawiki.language/languages/uk.js b/resources/mediawiki.language/languages/uk.js deleted file mode 100644 index 5e56b66f..00000000 --- a/resources/mediawiki.language/languages/uk.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Ukrainian (Українська) language functions - */ - -mediaWiki.language.convertGrammar = function ( word, form ) { - /*jshint noempty:false */ - var grammarForms = mediaWiki.language.getData( 'uk', 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word]; - } - switch ( form ) { - case 'genitive': // родовий відмінок - if ( ( word.substr( word.length - 4 ) === 'вікі' ) || ( word.substr( word.length - 4 ) === 'Вікі' ) ) { - } else if ( word.substr( word.length - 1 ) === 'ь' ) { - word = word.substr(0, word.length - 1 ) + 'я'; - } else if ( word.substr( word.length - 2 ) === 'ія' ) { - word = word.substr(0, word.length - 2 ) + 'ії'; - } else if ( word.substr( word.length - 2 ) === 'ка' ) { - word = word.substr(0, word.length - 2 ) + 'ки'; - } else if ( word.substr( word.length - 2 ) === 'ти' ) { - word = word.substr(0, word.length - 2 ) + 'тей'; - } else if ( word.substr( word.length - 2 ) === 'ды' ) { - word = word.substr(0, word.length - 2 ) + 'дов'; - } else if ( word.substr( word.length - 3 ) === 'ник' ) { - word = word.substr(0, word.length - 3 ) + 'ника'; - } - break; - case 'accusative': // знахідний відмінок - if ( ( word.substr( word.length - 4 ) === 'вікі' ) || ( word.substr( word.length - 4 ) === 'Вікі' ) ) { - } - else if ( word.substr( word.length - 2 ) === 'ія' ) { - word = word.substr(0, word.length - 2 ) + 'ію'; - } - break; - } - return word; -}; diff --git a/resources/mediawiki.language/mediawiki.cldr.js b/resources/mediawiki.language/mediawiki.cldr.js deleted file mode 100644 index c3023cd5..00000000 --- a/resources/mediawiki.language/mediawiki.cldr.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * CLDR related utility methods. - */ -( function ( mw ) { - 'use strict'; - - var cldr = { - /** - * For the number, get the plural for index - * In case none of the rules passed, we return pluralRules.length - * That means it is the "other" form. - * @param number - * @param {Array} pluralRules - * @return {number} plural form index - */ - getPluralForm: function ( number, pluralRules ) { - var i; - for ( i = 0; i < pluralRules.length; i++ ) { - if ( mw.libs.pluralRuleParser( pluralRules[i], number ) ) { - break; - } - } - return i; - } - }; - - mw.cldr = cldr; - -}( mediaWiki ) ); diff --git a/resources/mediawiki.language/mediawiki.language.init.js b/resources/mediawiki.language/mediawiki.language.init.js deleted file mode 100644 index 937b89bb..00000000 --- a/resources/mediawiki.language/mediawiki.language.init.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Base language object with methods for storing and getting - * language data. - */ -( function ( mw ) { - - var language = { - /** - * @var data {Object} Language related data (keyed by language, - * contains instances of mw.Map). - * @example Set data - * <code> - * // Override, extend or create the language data object of 'nl' - * mw.language.setData( 'nl', 'myKey', 'My value' ); - * - * // Set multiple values at once - * mw.language.setData( 'nl', { 'foo': 'X', 'bar': 'Y' } ); - * </code> - * @example Get GrammarForms data for language 'nl': - * <code> - * var grammarForms = mw.language.getData( 'nl', 'grammarForms' ); - * </code> - */ - data: {}, - - /** - * Convenience method for retreiving language data by language code and data key, - * covering for the potential inexistance of a data object for this langiage. - * @param langCode {String} - * @param dataKey {String} - * @return {mixed} Value stored in the mw.Map (or undefined if there is no map for - the specified langCode). - */ - getData: function ( langCode, dataKey ) { - var langData = language.data; - if ( langData && langData[langCode] instanceof mw.Map ) { - return langData[langCode].get( dataKey ); - } - return undefined; - }, - - /** - * Convenience method for setting language data by language code and data key. - * Creates the data mw.Map if there isn't one for the specified language already. - * - * @param langCode {String} - * @param dataKey {String|Object} Key or object of key/values. - * @param value {mixed} Value for dataKey, ignored if dataKey is an object. - */ - setData: function ( langCode, dataKey, value ) { - var langData = language.data; - if ( !( langData[langCode] instanceof mw.Map ) ) { - langData[langCode] = new mw.Map(); - } - langData[langCode].set( dataKey, value ); - } - }; - - mw.language = language; - -}( mediaWiki ) ); diff --git a/resources/mediawiki.language/mediawiki.language.js b/resources/mediawiki.language/mediawiki.language.js deleted file mode 100644 index 631d13df..00000000 --- a/resources/mediawiki.language/mediawiki.language.js +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Localized Language support attempts to mirror some of the functionality of - * Language.php in MediaWiki. - * This adds methods for transforming message text. - */ -( function ( mw, $ ) { - -var language = { - - /** - * Process the PLURAL template substitution - * - * @param {object} template Template object - * @format template - * { - * 'title': [title of template], - * 'parameters': [template parameters] - * } - * @example {{Template:title|params}} - */ - procPLURAL: function ( template ) { - if ( template.title && template.parameters && mw.language.convertPlural ) { - // Check if we have forms to replace - if ( template.parameters.length === 0 ) { - return ''; - } - // Restore the count into a Number ( if it got converted earlier ) - var count = mw.language.convertNumber( template.title, true ); - // Do convertPlural call - return mw.language.convertPlural( parseInt( count, 10 ), template.parameters ); - } - // Could not process plural return first form or nothing - if ( template.parameters[0] ) { - return template.parameters[0]; - } - return ''; - }, - - /** - * 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 - */ - convertPlural: function ( count, forms ) { - var pluralRules, - formCount, - form, - index, - equalsPosition, - pluralFormIndex = 0; - - if ( !forms || forms.length === 0 ) { - return ''; - } - - // Handle for explicit n= forms - for ( index = 0; index < forms.length; index++ ) { - form = forms[index]; - if ( /^\d+=/.test( form ) ) { - equalsPosition = form.indexOf( '=' ); - formCount = parseInt( form.substring( 0, equalsPosition ), 10 ); - if ( formCount === count ) { - return form.substr( equalsPosition + 1 ); - } - forms[index] = undefined; - } - } - - // Remove explicit plural forms from the forms. - forms = $.map( forms, function ( form ) { - return form; - } ); - - pluralRules = mw.language.getData( mw.config.get( 'wgUserLanguage' ), 'pluralRules' ); - if ( !pluralRules ) { - // default fallback. - return ( count === 1 ) ? forms[0] : forms[1]; - } - pluralFormIndex = mw.cldr.getPluralForm( count, pluralRules ); - pluralFormIndex = Math.min( pluralFormIndex, forms.length - 1 ); - return forms[pluralFormIndex]; - }, - - /** - * Pads an array to a specific length by copying the last one element. - * - * @param forms array Number of forms given to convertPlural - * @param count integer Number of forms required - * @return array Padded array of forms - */ - preConvertPlural: function ( forms, count ) { - while ( forms.length < count ) { - forms.push( forms[ forms.length-1 ] ); - } - return forms; - }, - - /** - * Provides an alternative text depending on specified gender. - * Usage {{gender:[gender|user object]|masculine|feminine|neutral}}. - * If second or third parameter are not specified, masculine is used. - * - * These details may be overriden per language. - * - * @param gender string male, female, or anything else for neutral. - * @param forms array List of gender forms - * - * @return string - */ - gender: function ( gender, forms ) { - if ( !forms || forms.length === 0 ) { - return ''; - } - forms = mw.language.preConvertPlural( forms, 2 ); - if ( gender === 'male' ) { - return forms[0]; - } - if ( gender === 'female' ) { - return forms[1]; - } - return ( forms.length === 3 ) ? forms[2] : forms[0]; - }, - - /** - * Grammatical transformations, needed for inflected languages. - * Invoked by putting {{grammar:form|word}} in a message. - * The rules can be defined in $wgGrammarForms global or grammar - * forms can be computed dynamically by overriding this method per language - * - * @param word {String} - * @param form {String} - * @return {String} - */ - convertGrammar: function ( word, form ) { - var grammarForms = mw.language.getData( mw.config.get( 'wgUserLanguage' ), 'grammarForms' ); - if ( grammarForms && grammarForms[form] ) { - return grammarForms[form][word] || word; - } - return word; - } - -}; - -$.extend( mw.language, language ); - -}( mediaWiki, jQuery ) ); diff --git a/resources/mediawiki.language/mediawiki.language.months.js b/resources/mediawiki.language/mediawiki.language.months.js deleted file mode 100644 index 3d4b7ee7..00000000 --- a/resources/mediawiki.language/mediawiki.language.months.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Transfer of month names from messages into mw.language. - * - * Loading this module also ensures the availability of appropriate messages via mw.msg. - */ -( function ( mw, $ ) { - var - monthMessages = [ - 'january', 'february', 'march', 'april', - 'may_long', 'june', 'july', 'august', - 'september', 'october', 'november', 'december' - ], - monthGenMessages = [ - 'january-gen', 'february-gen', 'march-gen', 'april-gen', - 'may-gen', 'june-gen', 'july-gen', 'august-gen', - 'september-gen', 'october-gen', 'november-gen', 'december-gen' - ], - monthAbbrevMessages = [ - 'jan', 'feb', 'mar', 'apr', - 'may', 'jun', 'jul', 'aug', - 'sep', 'oct', 'nov', 'dec' - ]; - - // Function suitable for passing to jQuery.map - // Can't use mw.msg directly because jQuery.map passes element index as second argument - function mwMsgMapper( key ) { - return mw.msg( key ); - } - - /** - * Information about month names in current UI language. - * - * Object keys: - * - `names`: array of month names (in nominative case in languages which have the distinction), - * zero-indexed - * - `genitive`: array of month names in genitive case, zero-indexed - * - `abbrev`: array of three-letter-long abbreviated month names, zero-indexed - * - `keys`: object with three keys like the above, containing zero-indexed arrays of message keys - * for appropriate messages which can be passed to mw.msg. - * - * @property - */ - mw.language.months = { - keys: { - names: monthMessages, - genitive: monthGenMessages, - abbrev: monthAbbrevMessages - }, - names: $.map( monthMessages, mwMsgMapper ), - genitive: $.map( monthGenMessages, mwMsgMapper ), - abbrev: $.map( monthAbbrevMessages, mwMsgMapper ) - }; - -}( mediaWiki, jQuery ) ); diff --git a/resources/mediawiki.language/mediawiki.language.numbers.js b/resources/mediawiki.language/mediawiki.language.numbers.js deleted file mode 100644 index fada6ce1..00000000 --- a/resources/mediawiki.language/mediawiki.language.numbers.js +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Number related utilities for mediawiki.language - */ -( function ( mw, $ ) { - - /** - * Pad a string to guarantee that it is at least `size` length by - * filling with the character `ch` at either the start or end of the - * string. Pads at the start, by default. - * example: - * Fill the string to length 10 with '+' characters on the right. Yields 'blah++++++'. - * pad('blah', 10, '+', true); - * - * @param {string} text The string to pad - * @param {Number} size To provide padding - * @param {string} ch Character to pad, defaults to '0' - * @param {Boolean} end Adds padding at the end if true, otherwise pads at start - * @return {string} - */ - function pad ( text, size, ch, end ) { - if ( !ch ) { - ch = '0'; - } - - var out = String( text ), - padStr = replicate( ch, Math.ceil( ( size - out.length ) / ch.length ) ); - - return end ? out + padStr : padStr + out; - } - - /** - * Efficiently replicate a string n times. - * - * @param {string} str The string to replicate - * @param {Number} num Number of times to replicate the string - * @return {string} - */ - function replicate ( str, num ) { - if ( num <= 0 || !str ) { - return ''; - } - - var buf = []; - while (num) { - buf.push( str ); - str += str; - } - return buf.join( '' ); - } - - /** - * Apply numeric pattern to absolute value using options. Gives no - * consideration to local customs. - * - * Adapted from dojo/number library with thanks - * http://dojotoolkit.org/reference-guide/1.8/dojo/number.html - * - * @param {Number} value the number to be formatted, ignores sign - * @param {string} pattern the number portion of a pattern (e.g. `#,##0.00`) - * @param {string} options.decimalThe decimal separator - * @param {string} options.group The group separator - * - * @return {string} - */ - function commafyNumber( value, pattern, options ) { - options = options || { - group: ',', - decimal: '.' - }; - - if ( isNaN( value) ) { - return value; - } - - var padLength, - patternDigits, - index, - whole, - off, - remainder, - patternParts = pattern.split( '.' ), - maxPlaces = ( patternParts[1] || [] ).length, - valueParts = String( Math.abs( value ) ).split( '.' ), - fractional = valueParts[1] || '', - groupSize = 0, - groupSize2 = 0, - pieces = []; - - if ( patternParts[1] ) { - // Pad fractional with trailing zeros - padLength = ( patternParts[1] && patternParts[1].lastIndexOf( '0' ) + 1 ); - - if ( padLength > fractional.length ) { - valueParts[1] = pad( fractional, padLength, '0', true ); - } - - // Truncate fractional - if ( maxPlaces < fractional.length ) { - valueParts[1] = fractional.substr( 0, maxPlaces ); - } - } else { - if ( valueParts[1] ) { - valueParts.pop(); - } - } - - // Pad whole with leading zeros - patternDigits = patternParts[0].replace( ',', '' ); - - padLength = patternDigits.indexOf( '0' ); - - if ( padLength !== -1 ) { - padLength = patternDigits.length - padLength; - - if ( padLength > valueParts[0].length ) { - valueParts[0] = pad( valueParts[0], padLength ); - } - - // Truncate whole - if ( patternDigits.indexOf( '#' ) === -1 ) { - valueParts[0] = valueParts[0].substr( valueParts[0].length - padLength ); - } - } - - // Add group separators - index = patternParts[0].lastIndexOf( ',' ); - - if ( index !== -1 ) { - groupSize = patternParts[0].length - index - 1; - remainder = patternParts[0].substr( 0, index ); - index = remainder.lastIndexOf( ',' ); - if ( index !== -1 ) { - groupSize2 = remainder.length - index - 1; - } - } - - for ( whole = valueParts[0]; whole; ) { - off = whole.length - groupSize; - - pieces.push( ( off > 0 ) ? whole.substr( off ) : whole ); - whole = ( off > 0 ) ? whole.slice( 0, off ) : ''; - - if ( groupSize2 ) { - groupSize = groupSize2; - } - } - valueParts[0] = pieces.reverse().join( options.group ); - - return valueParts.join( options.decimal ); - } - - $.extend( mw.language, { - - /** - * Converts a number using digitTransformTable. - * - * @param {Number} num Value to be converted - * @param {boolean} integer Convert the return value to an integer - * @return {Number|string} Formatted number - */ - convertNumber: function ( num, integer ) { - var i, tmp, transformTable, numberString, convertedNumber, pattern; - - pattern = mw.language.getData( mw.config.get( 'wgUserLanguage' ), - 'digitGroupingPattern' ) || '#,##0.###'; - - // Set the target transform table: - transformTable = mw.language.getDigitTransformTable(); - - if ( !transformTable ) { - return num; - } - - // Check if the 'restore' to Latin number flag is set: - if ( integer ) { - if ( parseInt( num, 10 ) === num ) { - return num; - } - tmp = []; - for ( i in transformTable ) { - tmp[ transformTable[ i ] ] = i; - } - transformTable = tmp; - numberString = num + ''; - } else { - numberString = mw.language.commafy( num, pattern ); - } - - convertedNumber = ''; - for ( i = 0; i < numberString.length; i++ ) { - if ( transformTable[ numberString[i] ] ) { - convertedNumber += transformTable[numberString[i]]; - } else { - convertedNumber += numberString[i]; - } - } - return integer ? parseInt( convertedNumber, 10 ) : convertedNumber; - }, - - getDigitTransformTable: function () { - return mw.language.getData( mw.config.get( 'wgUserLanguage' ), - 'digitTransformTable' ) || []; - }, - - getSeparatorTransformTable: function () { - return mw.language.getData( mw.config.get( 'wgUserLanguage' ), - 'separatorTransformTable' ) || []; - }, - - /** - * Apply pattern to format value as a string using as per - * unicode.org TR35 - http://www.unicode.org/reports/tr35/#Number_Format_Patterns. - * - * @param {Number} value - * @param {string} pattern Pattern string as described by Unicode TR35 - * @throws Error - * @returns {String} - */ - commafy: function ( value, pattern ) { - var numberPattern, - transformTable = mw.language.getSeparatorTransformTable(), - group = transformTable[','] || ',', - numberPatternRE = /[#0,]*[#0](?:\.0*#*)?/, // not precise, but good enough - decimal = transformTable['.'] || '.', - patternList = pattern.split( ';' ), - positivePattern = patternList[0]; - - pattern = patternList[ ( value < 0 ) ? 1 : 0] || ( '-' + positivePattern ); - numberPattern = positivePattern.match( numberPatternRE ); - - if ( !numberPattern ) { - throw new Error( 'unable to find a number expression in pattern: ' + pattern ); - } - - return pattern.replace( numberPatternRE, commafyNumber( value, numberPattern[0], { - decimal: decimal, - group: group - } ) ); - } - - } ); - -}( mediaWiki, jQuery ) ); |