Stubs for hebrew and arabic language files; support for 'dir=rtl' on html element
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 8 Jul 2003 20:17:36 +0000 (20:17 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 8 Jul 2003 20:17:36 +0000 (20:17 +0000)
includes/OutputPage.php
languages/Language.php
languages/LanguageAr.php [new file with mode: 0644]
languages/LanguageHe.php [new file with mode: 0644]

index 17586b0..0c623f3 100644 (file)
@@ -1361,14 +1361,15 @@ class OutputPage {
 
        /* private */ function headElement()
        {
-               global $wgDocType, $wgDTD, $wgUser, $wgLanguageCode, $wgOutputEncoding;
+               global $wgDocType, $wgDTD, $wgUser, $wgLanguageCode, $wgOutputEncoding, $wgLang;
 
                $ret = "<!DOCTYPE HTML PUBLIC \"$wgDocType\"\n        \"$wgDTD\">\n";
 
                if ( "" == $this->mHTMLtitle ) {
                        $this->mHTMLtitle = $this->mPagetitle;
                }
-               $ret .= "<html lang=\"$wgLanguageCode\"><head><title>{$this->mHTMLtitle}</title>\n";
+               $rtl = $wgLang->isRTL() ? " dir='RTL'" : "";
+               $ret .= "<html lang=\"$wgLanguageCode\"$rtl><head><title>{$this->mHTMLtitle}</title>\n";
                array_push( $this->mMetatags, array( "http:Content-type", "text/html; charset={$wgOutputEncoding}" ) );
                foreach ( $this->mMetatags as $tag ) {
                        if ( 0 == strcasecmp( "http:", substr( $tag[0], 0, 5 ) ) ) {
index 232089a..2150a97 100644 (file)
@@ -1450,9 +1450,13 @@ class Language {
                }
                return $text;
        }
+
+       # For right-to-left language support
+       function isRTL() { return false; }
 }
 
 global $IP;
 @include_once( "{$IP}/Language" . ucfirst( $wgLanguageCode ) . ".php" );
 
 ?>
+v
\ No newline at end of file
diff --git a/languages/LanguageAr.php b/languages/LanguageAr.php
new file mode 100644 (file)
index 0000000..b08b06b
--- /dev/null
@@ -0,0 +1,29 @@
+<?
+# See language.doc
+include_once("Utf8Case.php");
+
+class LanguageAr extends LanguageUtf8 {
+       # Inherit everything
+
+       # TODO: right-to-left support functions...?
+       function isRTL() { return true; }
+
+       # There may be a partial translation; get this merged in.
+
+       function checkTitleEncoding( $s ) {
+               global $wgInputEncoding;
+               
+               # Check for non-UTF-8 URLs; assume they are windows-1256?
+               $ishigh = preg_match( '/[\x80-\xff]/', $s);
+               $isutf = ($ishigh ? preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
+                '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s ) : true );
+
+               if( $ishigh and !$isutf )
+                       return iconv( "windows-1256", "utf-8", $s );
+               
+               return $s;
+       }
+
+}
+
+?>
diff --git a/languages/LanguageHe.php b/languages/LanguageHe.php
new file mode 100644 (file)
index 0000000..d7a0c11
--- /dev/null
@@ -0,0 +1,29 @@
+<?
+# See language.doc
+include_once("Utf8Case.php");
+
+class LanguageHe extends LanguageUtf8 {
+       # Inherit everything
+
+       # TODO: right-to-left support functions...?
+       function isRTL() { return true; }
+
+       # There may be a partial translation; get this merged in.
+
+       function checkTitleEncoding( $s ) {
+               global $wgInputEncoding;
+               
+               # Check for non-UTF-8 URLs; assume they are 8859-8?
+               $ishigh = preg_match( '/[\x80-\xff]/', $s);
+               $isutf = ($ishigh ? preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
+                '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s ) : true );
+
+               if( $ishigh and !$isutf )
+                       return iconv( "iso8859-8", "utf-8", $s );
+               
+               return $s;
+       }
+
+}
+
+?>