Tatar week days and months
[lhc/web/wiklou.git] / languages / Language.php
index e2c3500..54e8492 100644 (file)
@@ -132,6 +132,7 @@ define( 'MW_DATE_USER_FORMAT', true );
        'watchdefault',
        'minordefault',
        'previewontop',
+       'previewonfirst',
        'nocache',
 );
 
@@ -255,6 +256,7 @@ global $wgRightsText;
 'tog-watchdefault' => 'Add pages you edit to your watchlist',
 'tog-minordefault' => 'Mark all edits minor by default',
 'tog-previewontop' => 'Show preview before edit box and not after it',
+'tog-previewonfirst' => 'Show preview on first edit',
 'tog-nocache' => 'Disable page caching',
 
 # dates
@@ -641,9 +643,9 @@ You will have to merge your changes into the existing text.
 press \"Save page\".\n<p>",
 'yourtext'             => 'Your text',
 'storedversion' => 'Stored version',
-'editingold'   => '<strong>WARNING: You are editing an out-of-date
+'editingold'   => "<strong>WARNING: You are editing an out-of-date
 revision of this page.
-If you save it, any changes made since this revision will be lost.</strong>\n',
+If you save it, any changes made since this revision will be lost.</strong>\n",
 'yourdiff'             => 'Differences',
 'copyrightwarning' => "Please note that all contributions to {{SITENAME}} are
 considered to be released under the $2 (see $1 for details).
@@ -1958,17 +1960,65 @@ class Language {
                return $word;
        }
 
-       # Hook for Chinese traditional/simplified conversion
+    
+    # convert text to different variants of a language. the automatic
+    # conversion is done in autoConvert(). here we parse the text 
+    # marked with -{}-, which specifies special conversions of the 
+    # text that can not be accomplished in autoConvert()
+    #
+    # syntax of the markup:
+    # -{code1:text1;code2:text2;...}-  or
+    # -{text}- in which case no conversion should take place for text
        function convert( $text ) {
-               return $text;
+
+        $plang = $this->getPreferredVariant();
+        if(!$plang)
+            return $text;
+
+               // no conversion if redirecting
+               if(substr($text,0,9) == "#REDIRECT") {
+                       return $text;
+               }
+
+        $tarray = explode("-{", $text);
+        $tfirst = array_shift($tarray);
+        $text = $this->autoConvert($tfirst);
+
+        foreach($tarray as $txt) {
+            $marked = explode("}-", $txt);
+
+            $choice = explode(";", $marked{0});
+            if($choice{1}==NULL) {
+                $text .= $choice{0};
+            }
+            else {
+                foreach($choice as $c) {
+                    list($code, $content) = split(":", $c);
+                    $code = trim($code);
+                    $content = trim($content);
+                    if($code == $plang) {
+                        $text .= $content;
+                        break;
+                    }
+                }
+            }
+            $text .= $this->autoConvert($marked{1});
+        }
+
+        return $text;
        }
 
+    function autoConvert($text) {
+        return $text;
+    }
+
     # see if we have a list of language variants for conversion.
     # right now mainly used in the Chinese conversion
     function getVariants() {
         return array();
     }
 
+    # todo: write general code to get default language variant
     function getPreferredVariant() {
         return false;
     }