Page MenuHomePhabricator

Languageconversion.patch

Authored By
bzimport
Nov 21 2014, 10:14 PM
Size
3 KB
Referenced Files
None
Subscribers
None

Languageconversion.patch

Index: LanguageConverter.php
===================================================================
--- LanguageConverter.php (revision 36804)
+++ LanguageConverter.php (working copy)
@@ -220,9 +220,9 @@
3. place holders created by the parser
*/
global $wgParser;
- if (isset($wgParser) && $wgParser->UniqPrefix()!='')
+ if (isset($wgParser) && $wgParser->UniqPrefix()!=''){
$marker = '|' . $wgParser->UniqPrefix() . '[\-a-zA-Z0-9]+';
- else
+ } else
$marker = "";
// this one is needed when the text is inside an html markup
@@ -232,8 +232,10 @@
$codefix = '<code>.+?<\/code>|';
// disable convertsion of <script type="text/javascript"> ... </script>
$scriptfix = '<script.*?>.*?<\/script>|';
+ // disable conversion of <pre xxxx> ... </pre>
+ $prefix = '<pre.*?>.*?<\/pre>|';
- $reg = '/'.$codefix . $scriptfix . '<[^>]+>|&[a-zA-Z#][a-z0-9]+;' . $marker . $htmlfix . '/s';
+ $reg = '/'.$codefix . $scriptfix . $prefix . '<[^>]+>|&[a-zA-Z#][a-z0-9]+;' . $marker . $htmlfix . '/s';
$matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);
@@ -257,6 +259,7 @@
* @param string $text Text to convert
* @param string $variant Variant language code
* @return string Translated text
+ * @private
*/
function translate( $text, $variant ) {
wfProfileIn( __METHOD__ );
@@ -324,6 +327,7 @@
/**
* Convert text using a parser object for context
+ * @public
*/
function parserConvert( $text, &$parser ) {
global $wgDisableLangConversion;
@@ -344,7 +348,7 @@
/**
* Parse flags with syntax -{FLAG| ... }-
- *
+ * @private
*/
function parseFlags($marked){
$flags = array();
@@ -401,10 +405,12 @@
}
if ( count($flags)==0 )
$flags = array('S');
-
return array($rules,$flags);
}
+ /**
+ * @private
+ */
function getRulesDesc($bidtable,$unidtable){
$text='';
foreach($bidtable as $k => $v)
@@ -475,8 +481,9 @@
// proces H,- flag or T only: output nothing
$disp = '';
} elseif ( in_array('S',$flags) ){
- // the text converted
- if($doConvert){
+ if( count($bidtable) + count($unidtable) == 0 ){
+ $disp = $rules;
+ } elseif ($doConvert){// the text converted
// display current variant in bidirectional array
$disp = $this->getTextInCArray($variant,$bidtable);
// or display current variant in fallbacks
@@ -496,7 +503,7 @@
$disp = array_values($unidtable);
$disp = array_values($disp[0]);
$disp = $disp[0];
- }
+ }
}
} else {// no convert
$disp = $rules;
@@ -511,7 +518,10 @@
return $disp;
}
- function applyManualFlag($flags,$bidtable,$unidtable,$variant=false){
+ /**
+ * @access private
+ */
+ function applyManualFlag($rules,$flags,$bidtable,$unidtable,$variant=false){
if(!$variant) $variant = $this->getPreferredVariant();
$is_title_flag = in_array('T', $flags);
@@ -583,11 +593,15 @@
$bidtable,$unidtable,
$variant,
$this->mDoContentConvert);
- $this->applyManualFlag($flags,$bidtable,$unidtable);
+ $this->applyManualFlag($rules,$flags,$bidtable,$unidtable);
return $disp;
}
+ /**
+ * convert title
+ * @private
+ */
function convertTitle($text){
// check for __NOTC__ tag
if( !$this->mDoTitleConvert ) {
@@ -932,6 +946,7 @@
*
* @param string $text text to be tagged for no conversion
* @return string the tagged text
+ * @public
*/
function markNoConversion($text, $noParse=false) {
# don't mark if already marked
@@ -973,6 +988,7 @@
/**
* Armour rendered math against conversion
* Wrap math into rawoutput -{R| math }- syntax
+ * @public
*/
function armourMath($text){
$ret = $this->mMarkup['begin'] . 'R|' . $text . $this->mMarkup['end'];

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4545
Default Alt Text
Languageconversion.patch (3 KB)

Event Timeline