Merge "Move WikiEditor's special character data and messages into core for use in other extensions"

This commit is contained in:
jenkins-bot 2015-03-27 18:40:36 +00:00 committed by Gerrit Code Review
commit 39eeb0513d
7 changed files with 159 additions and 2 deletions

View file

@ -989,6 +989,7 @@ $wgAutoloadLocalClasses = array(
'ResourceLoaderModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderModule.php',
'ResourceLoaderSiteModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderSiteModule.php',
'ResourceLoaderSkinModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderSkinModule.php',
'ResourceLoaderSpecialCharacterDataModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderSpecialCharacterDataModule.php',
'ResourceLoaderStartUpModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderStartUpModule.php',
'ResourceLoaderUserCSSPrefsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserCSSPrefsModule.php',
'ResourceLoaderUserDefaultsModule' => __DIR__ . '/includes/resourceloader/ResourceLoaderUserDefaultsModule.php',

View file

@ -0,0 +1,107 @@
<?php
/**
* Resource loader module for populating special characters data for some
* editing extensions to use.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
/**
* Resource loader module for populating special characters data for some
* editing extensions to use.
*/
class ResourceLoaderSpecialCharacterDataModule extends ResourceLoaderModule {
private $path = "resources/src/mediawiki.language/specialcharacters.json";
protected $targets = array( 'desktop', 'mobile' );
/**
* Get all the dynamic data.
*
* @return array
*/
protected function getData() {
return json_decode( file_get_contents( $this->path ) );
}
/**
* @param ResourceLoaderContext $context
* @return string JavaScript code
*/
public function getScript( ResourceLoaderContext $context ) {
return Xml::encodeJsCall(
'mw.language.setSpecialCharacters',
array(
$this->getData()
),
ResourceLoader::inDebugMode()
);
}
/**
* @param ResourceLoaderContext $context
* @return int UNIX timestamp
*/
public function getModifiedTime( ResourceLoaderContext $context ) {
return static::safeFilemtime( $this->path );
}
/**
* @param ResourceLoaderContext $context
* @return string Hash
*/
public function getModifiedHash( ResourceLoaderContext $context ) {
return md5( serialize( $this->getData() ) );
}
/**
* @return array
*/
public function getDependencies() {
return array( 'mediawiki.language.init' );
}
/**
* @return array
*/
public function getMessages() {
return array(
'special-characters-group-latin',
'special-characters-group-latinextended',
'special-characters-group-ipa',
'special-characters-group-symbols',
'special-characters-group-greek',
'special-characters-group-cyrillic',
'special-characters-group-arabic',
'special-characters-group-arabicextended',
'special-characters-group-persian',
'special-characters-group-hebrew',
'special-characters-group-bangla',
'special-characters-group-tamil',
'special-characters-group-telugu',
'special-characters-group-sinhala',
'special-characters-group-devanagari',
'special-characters-group-gujarati',
'special-characters-group-thai',
'special-characters-group-lao',
'special-characters-group-khmer',
'special-characters-title-endash',
'special-characters-title-emdash',
'special-characters-title-minus'
);
}
}

View file

@ -3681,5 +3681,27 @@
"json-error-inf-or-nan": "One or more NAN or INF values in the value to be encoded",
"json-error-unsupported-type": "A value of a type that cannot be encoded was given",
"headline-anchor-title": "Link to this section",
"section-symbol": "§"
"section-symbol": "§",
"special-characters-group-latin": "Latin",
"special-characters-group-latinextended": "Latin extended",
"special-characters-group-ipa": "IPA",
"special-characters-group-symbols": "Symbols",
"special-characters-group-greek": "Greek",
"special-characters-group-cyrillic": "Cyrillic",
"special-characters-group-arabic": "Arabic",
"special-characters-group-arabicextended": "Arabic extended",
"special-characters-group-persian": "Persian",
"special-characters-group-hebrew": "Hebrew",
"special-characters-group-bangla": "Bangla",
"special-characters-group-tamil": "Tamil",
"special-characters-group-telugu": "Telugu",
"special-characters-group-sinhala": "Sinhala",
"special-characters-group-gujarati": "Gujarati",
"special-characters-group-devanagari": "Devanagari",
"special-characters-group-thai": "Thai",
"special-characters-group-lao": "Lao",
"special-characters-group-khmer": "Khmer",
"special-characters-title-endash": "en dash",
"special-characters-title-emdash": "em dash",
"special-characters-title-minus": "minus sign"
}

View file

@ -3844,5 +3844,23 @@
"json-error-utf8": "User error message when there are malformed UTF-8 characters, possibly incorrectly encoded.\nSee http://php.net/manual/en/function.json-last-error.php\n{{Related|Json-error}}",
"json-error-recursion": "PHP JSON encoding/decoding error. See http://php.net/manual/en/function.json-last-error.php\n{{Related|Json-error}}",
"json-error-inf-or-nan": "PHP JSON encoding/decoding error. See http://php.net/manual/en/function.json-last-error.php\n{{Related|Json-error}}",
"json-error-unsupported-type": "PHP JSON encoding/decoding error. See http://php.net/manual/en/function.json-last-error.php\n{{Related|Json-error}}"
"json-error-unsupported-type": "PHP JSON encoding/decoding error. See http://php.net/manual/en/function.json-last-error.php\n{{Related|Json-error}}",
"special-characters-group-latin": "This is the name of a script, or alphabet, not a language.",
"special-characters-group-latinextended": "The name of the Latin Extended character set.",
"special-characters-group-ipa": "IPA means a script: \"international phonetic alphabet\" here, and not \"international phonetic association\", the organization behind it.",
"special-characters-group-symbols": "The section name for symbols\n\n{{Identical|Symbol}}",
"special-characters-group-greek": "This is the name of a script, or alphabet, not a language.",
"special-characters-group-cyrillic": "This is the name of a script, or a group of alphabets, used mainly in Eastern Europe and North and Central Asia.",
"special-characters-group-arabic": "This is the name of a script, or alphabet, not a language.",
"special-characters-group-arabicextended": "This is a description of the additional group of Arabic script characters for languages such as a Persian, Urdu, Pashto and others. This message is supposed to be similar to {{msg-mw|special-characters-group-latinextended}}.",
"special-characters-group-persian": "The name of the Persian character set (alphabet).",
"special-characters-group-hebrew": "This is the name of a script, or alphabet, not a language.",
"special-characters-group-bangla": "The name of the [[w:Bengali alphabet|Bangla]] (a.k.a. Bengali) character set (alphabet).",
"special-characters-group-tamil": "The name of the [[w:Tamil_Script#Numerals_and_symbols|Tamil]] numerals and symbols.",
"special-characters-group-telugu": "The name of the [[w:Telugu language#Alphabet|Telugu]] character set (alphabet).",
"special-characters-group-lao": "{{Identical|Lao}}",
"special-characters-group-khmer": "{{Identical|Khmer}}",
"special-characters-title-endash": "Title tooltip for the en dash character (); See https://en.wikipedia.org/wiki/Dash",
"special-characters-title-emdash": "Title tooltip for the em dash character (—); See https://en.wikipedia.org/wiki/Dash",
"special-characters-title-minus": "Title tooltip for the minus sign character (), not to be confused with a hyphen"
}

View file

@ -1259,6 +1259,10 @@ return array(
'mediawiki.language.names' => array( 'class' => 'ResourceLoaderLanguageNamesModule' ),
'mediawiki.language.specialCharacters' => array(
'class' => 'ResourceLoaderSpecialCharacterDataModule'
),
/* MediaWiki Libs */
'mediawiki.libs.jpegmeta' => array(

View file

@ -146,6 +146,10 @@ $.extend( mw.language, {
}
}
return text;
},
setSpecialCharacters: function ( data ) {
this.specialCharacters = data;
}
} );

File diff suppressed because one or more lines are too long