/*
* Methods for transforming message syntax.
*/
-( function ( mw, $ ) {
+( function () {
/**
* @class mw.language
*/
$.extend( mw.language, {
- /**
- * Process the PLURAL template substitution
- *
- * @private
- * @param {Object} template Template object
- * @param {string} template.title
- * @param {Array} template.parameters
- * @return {string}
- */
- procPLURAL: function ( template ) {
- var count;
- 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 )
- 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.
*
return forms[ form ][ word ];
}
- transformations = mediaWiki.language.getData( userLanguage, 'grammarTransformations' );
+ transformations = mw.language.getData( userLanguage, 'grammarTransformations' );
if ( !( transformations && transformations[ form ] ) ) {
return word;
},
/**
- * Formats language tags according the BCP 47 standard.
+ * Formats language tags according the BCP47 standard.
* See LanguageCode::bcp47 for the PHP implementation.
*
* @param {string} languageTag Well-formed language tag
* @return {string}
*/
bcp47: function ( languageTag ) {
- var bcp47Map,
- formatted,
- segments,
+ var formatted,
isFirstSegment = true,
- isPrivate = false;
-
- languageTag = languageTag.toLowerCase();
-
- bcp47Map = mw.language.getData( mw.config.get( 'wgUserLanguage' ), 'bcp47Map' );
- if ( bcp47Map && Object.prototype.hasOwnProperty.call( bcp47Map, languageTag ) ) {
- languageTag = bcp47Map[ languageTag ];
- }
+ isPrivate = false,
+ segments = languageTag.split( '-' );
- segments = languageTag.split( '-' );
formatted = segments.map( function ( segment ) {
var newSegment;
}
} );
-}( mediaWiki, jQuery ) );
+}() );