From c5d5f81ea23e8ac32789b165791e02c0771d8f31 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Sat, 31 Oct 2009 19:14:55 +0000 Subject: [PATCH] * some js2 language updates --- js2/mwEmbed/jsScriptLoader.php | 23 ++-- js2/mwEmbed/php/script-cache/README | 7 +- js2/mwEmbed/tests/testLang.html | 184 +++++++++++++++------------- js2/mwEmbed/tests/testLang.js | 9 +- 4 files changed, 120 insertions(+), 103 deletions(-) diff --git a/js2/mwEmbed/jsScriptLoader.php b/js2/mwEmbed/jsScriptLoader.php index 259675b46b..d65b1dd77e 100644 --- a/js2/mwEmbed/jsScriptLoader.php +++ b/js2/mwEmbed/jsScriptLoader.php @@ -173,19 +173,19 @@ class jsScriptLoader { echo $this->jsout; } } - - function clientAcceptsGzip() { + + function clientAcceptsGzip() { $m = array(); if( preg_match( '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/', $_SERVER['HTTP_ACCEPT_ENCODING'], $m ) ) { - if( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) - return false; + if( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) + return false; //no gzip support found - return true; - } - return false; + return true; + } + return false; } /* * postProcRequestVars uses globals, configuration and mediaWiki to test wiki-titles and files exist etc. @@ -208,6 +208,15 @@ class jsScriptLoader { $this->urid = $wgStyleVersion; } + //get the language code (if not provided use the "default" language + if ( isset( $_GET['lang'] ) && $_GET['lang'] != '' ) { + //make sure its a valid lang code: + $this->langCode = preg_replace( "/[^A-Za-z]/", '', $_GET['lang']); + }else{ + //set english as default + $this->langCode = 'en'; + } + $reqClassList = false; if ( isset( $_GET['class'] ) && $_GET['class'] != '' ) { $reqClassList = explode( ',', $_GET['class'] ); diff --git a/js2/mwEmbed/php/script-cache/README b/js2/mwEmbed/php/script-cache/README index a42bd3ed47..9704dc4121 100644 --- a/js2/mwEmbed/php/script-cache/README +++ b/js2/mwEmbed/php/script-cache/README @@ -1,11 +1,6 @@ -This folder holds cached versions of grouped script requests (if running mwEmbed in stand-alone-mode. -(otherwise $wgFileCacheDirectory from mediaWiki is used) +This folder holds cached versions of grouped script requests Be sure to enable write access by your web-server to this directory. - -You can specify a different directory by updating the $wgFileCacheDirectory variable in noMediaWikiConfig.php You can empty this directory at any time and should not be a problem. -You may want to update your include call since the script server sends long expire headers since it ment to work in conjunction with mediaWiki dynamic pages that output fresh request ids as scripts update. - diff --git a/js2/mwEmbed/tests/testLang.html b/js2/mwEmbed/tests/testLang.html index 1f10058da5..3c6a7b4c76 100644 --- a/js2/mwEmbed/tests/testLang.html +++ b/js2/mwEmbed/tests/testLang.html @@ -8,11 +8,14 @@ td{ }

Test Javascript plural msg transformations

-
+
diff --git a/js2/mwEmbed/tests/testLang.js b/js2/mwEmbed/tests/testLang.js index 2314304f45..10a346e5b0 100644 --- a/js2/mwEmbed/tests/testLang.js +++ b/js2/mwEmbed/tests/testLang.js @@ -1,12 +1,9 @@ /* a simple language tester replacements */ -loadGM({ - //test msg with English words to see whats going on - 'test_plural_msg' : '{{PLURAL:$1|one|other}}', - //sample real world msgs: - 'undelete_short' : 'Undelete {{PLURAL:$1|one edit|$1 edits}}', - 'category-subcat-count' : "fish {{PLURAL:$2|This {{PLURAL:$1|fistsub|$1 secondsub}} category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}" +loadGM({ + "undelete_short" : "Undelete {{PLURAL:$1|one edit|$1 edits}}", + "category-subcat-count" : "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}" }); $mw.lang.loadRS({ -- 2.20.1