On Sunday 16 May 2004 09:16, Brion Vibber wrote:
Nikola Smolenski wrote:
About GlobalFunctions.php: strcasecmp is probably
an error, and get_class
accepts only one argument. It works this way for me (PHP 4.1.0).
No, strcasecmp is correct: get_class always returns a lowercase value,
so the comparison needs to be case insensitive. There is however a
misnested parenthesis.
I see now. OK, here it is, all changes required for the multilingual
interface. Now different languages all have different default settings, and
everything which needs to fallbacks on English except for Chinese and
Japanese. I hope that this could make it to the new release...
Index: LocalSettings.sample
===================================================================
RCS file: /cvsroot/wikipedia/phase3/LocalSettings.sample,v
retrieving revision 1.34
diff -u -3 -p -r1.34 LocalSettings.sample
--- LocalSettings.sample 8 May 2004 02:15:49 -0000 1.34
+++ LocalSettings.sample 22 May 2004 12:25:03 -0000
@@ -141,6 +141,8 @@ $wgLocalInterwiki = $wgSitename;
## If you want a non-English wiki, add a line like this
# $wgLanguageCode = "de";
+## If you want your wiki to have several languages, add their codes into an
array like this
+# $wgLanguageArray = array("en","de","sr");
## Character encoding: normally auto-selected by the language.
## English, German, Danish, Dutch, French, Spanish, and Swedish
Index: includes/DefaultSettings.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/DefaultSettings.php,v
retrieving revision 1.110
diff -u -3 -p -r1.110 DefaultSettings.php
--- includes/DefaultSettings.php 21 May 2004 19:04:52 -0000 1.110
+++ includes/DefaultSettings.php 22 May 2004 12:25:06 -0000
@@ -94,6 +94,7 @@ $wgLinkCacheMemcached = false; # Not ful
#
$wgLanguageCode = "en";
$wgLanguageFile = false; # Filename of a language file generated by
dumpMessages.php
+$wgLanguageArray = false; # Monolingual by default
$wgInterwikiMagic = true; # Treat language links as magic connectors,
not inline links
$wgInputEncoding = "ISO-8859-1";
$wgOutputEncoding = "ISO-8859-1";
Index: includes/GlobalFunctions.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/GlobalFunctions.php,v
retrieving revision 1.86
diff -u -3 -p -r1.86 GlobalFunctions.php
--- includes/GlobalFunctions.php 17 May 2004 20:04:50 -0000 1.86
+++ includes/GlobalFunctions.php 22 May 2004 12:25:09 -0000
@@ -40,8 +40,8 @@ if( !function_exists('is_a') ) {
# Exists in PHP 4.2.0+
function is_a( $object, $class_name ) {
return
- (strcasecmp( get_class( $object, $class_name ) == 0)
||
- is_subclass_of( $object, $class_name ) );
+ (strcasecmp( get_class( $object ), $class_name ) == 0)
||
+ is_subclass_of( $object, $class_name ) ;
}
}
@@ -261,7 +261,7 @@ function wfReadOnly()
global $wgReadOnlyFile;
if ( "" == $wgReadOnlyFile ) { return false; }
- return is_file( $wgReadOnlyFile );
+ return @is_file( $wgReadOnlyFile );
}
$wgReplacementKeys = array( "$1", "$2", "$3",
"$4", "$5", "$6", "$7", "$8",
"$9" );
Index: includes/Setup.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/Setup.php,v
retrieving revision 1.47
diff -u -3 -p -r1.47 Setup.php
--- includes/Setup.php 15 May 2004 03:36:38 -0000 1.47
+++ includes/Setup.php 22 May 2004 12:25:10 -0000
@@ -144,7 +144,47 @@ if( $wgUseMemCached ) {
wfProfileOut( "$fname-memcached" );
wfProfileIn( "$fname-misc" );
-require_once( "languages/Language.php" );
+if( !$wgLanguageArray ) {
+ require_once( "languages/Language.php" );
+}
+
+if( !$wgCommandLineMode && ( isset( $_COOKIE[ini_get("session.name")] )
||
isset
+( $_COOKIE["{$wgDBname}Password"] ) ) ) {
+ User::SetupSession();
+}
+
+$wgBlockCache = new BlockCache( true );
+if( $wgCommandLineMode ) {
+ # Used for some maintenance scripts; user session cookies can screw
things up
+ # when the database is in an in-between state.
+ $wgUser = new User();
+} else {
+ $wgUser = User::loadFromSession();
+}
+
+if( $wgLanguageArray ) {
+
if($_GET['language']&&in_array($_GET['language'],$wgLanguageArray))
{
+ $wgLanguageCode=$_GET['language'];
+ } else
if($_POST['wpLanguage']&&in_array($_POST['wpLanguage'],$wgLanguageArray))
{
+ $wgLanguageCode=$_POST['wpLanguage'];
+ } else {
+ $wgLanguageCode = $wgUser->getOption("language");
+ }
+}
+
+ require_once( "languages/Language.php" );
+
+if( $wgLanguageArray ) {
+ $UCFLC=ucfirst( $wgLanguageCode );
+ eval("
+ \$wgNamespaceNames$UCFLC=\$wgNamespaceNamesEn;
+ \$wgMagicWords$UCFLC=\$wgMagicWordsEn;
+ \$wgAllMessages$UCFLC ['linktrail']=\$wgAllMessagesEn
['linktrail'];
+ \$wgAllMessages$UCFLC ['uploadlog']=\$wgAllMessagesEn
['uploadlog'];
+ \$wgAllMessages$UCFLC ['uploadlogpage']=\$wgAllMessagesEn
['uploadlogpage'];
+ \$wgAllMessages$UCFLC ['deletionlog']=\$wgAllMessagesEn
['deletionlog'];
+ ");
+}
$wgMessageCache = new MessageCache;
@@ -158,6 +198,11 @@ $wgLang = new $wgLangClass();
if ( !is_object($wgLang) ) {
print "No language class ($wgLang)\N";
}
+
+if(!$this->mId) {
+ $wgUser->setDefaultOptions($wgLang->getDefaultUserOptions());
+}
+
$wgMessageCache->initialise( $messageMemc, $wgUseDatabaseMessages,
$wgMsgCacheExpiry, $wgDBname );
$wgOut = new OutputPage();
@@ -169,7 +214,7 @@ if ( $wgUseDynamicDates ) {
$wgDateFormatter = new DateFormatter;
}
-if( !$wgCommandLineMode && ( isset( $_COOKIE[ini_get("session.name")] )
||
isset( $_COOKIE["{$wgDBname}Password"] ) ) ) {
+/*if( !$wgCommandLineMode && ( isset( $_COOKIE[ini_get("session.name")]
) ||
isset( $_COOKIE["{$wgDBname}Password"] ) ) ) {
User::SetupSession();
}
@@ -180,7 +225,7 @@ if( $wgCommandLineMode ) {
$wgUser = new User();
} else {
$wgUser = User::loadFromSession();
-}
+}*/
$wgDeferredUpdateList = array();
$wgLinkCache = new LinkCache();
$wgMagicWords = array();
Index: includes/SpecialPreferences.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/SpecialPreferences.php,v
retrieving revision 1.46
diff -u -3 -p -r1.46 SpecialPreferences.php
--- includes/SpecialPreferences.php 20 May 2004 11:26:32 -0000 1.46
+++ includes/SpecialPreferences.php 22 May 2004 12:25:11 -0000
@@ -11,7 +11,7 @@ class PreferencesForm {
var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag,
$mNick;
var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars,
$mAction;
- var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName;
+ var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mLanguage;
function PreferencesForm( &$request ) {
global $wgLang;
@@ -39,6 +39,7 @@ class PreferencesForm {
$this->mReset = $request->getCheck( 'wpReset' );
$this->mPosted = $request->wasPosted();
$this->mSaveprefs = $request->getCheck( 'wpSaveprefs' )
&&
$this->mPosted;
+ $this->mLanguage = $request->getVal( 'wpLanguage' );
# User toggles (the big ugly unsorted list of checkboxes)
$this->mToggles = array();
@@ -158,6 +159,7 @@ class PreferencesForm {
$wgUser->setOption( "cols", $this->validateInt(
$this->mCols,
4, 1000 ) );
$wgUser->setOption( "stubthreshold",
$this->validateIntOrNull(
$this->mStubs ) );
$wgUser->setOption( "timecorrection",
$this->validateTimeZone(
$this->mHourDiff, -12, 14 ) );
+ $wgUser->setOption( "language", $this->mLanguage );
# Set search namespace options
foreach( $this->mSearchNs as $i => $value ) {
@@ -201,6 +203,7 @@ class PreferencesForm {
$this->mSearchLines = $wgUser->getOption( "contextlines"
);
$this->mSearchChars = $wgUser->getOption( "contextchars"
);
$this->mRecent = $wgUser->getOption( "rclimit" );
+ $this->mLanguage = $wgUser->getOption( "language" );
$togs = $wgLang->getUserToggles();
foreach ( $togs as $tname => $ttext ) {
@@ -264,7 +267,7 @@ class PreferencesForm {
/* private */ function mainPrefsForm( $err )
{
- global $wgUser, $wgOut, $wgLang, $wgUseDynamicDates,
$wgValidSkinNames;
+ global $wgUser, $wgOut, $wgLang, $wgUseDynamicDates,
$wgValidSkinNames,$wgLanguageArray;
$wgOut->setPageTitle( wfMsg( "preferences" ) );
$wgOut->setArticleRelated( false );
@@ -320,6 +323,20 @@ class PreferencesForm {
$wgOut->addHTML( "<form id=\"preferences\"
name=\"preferences\" action=\"$action\"
method=\"post\">" );
+ # Zeroth section: language
+ #
+ if($wgLanguageArray) {
+ $wgOut->addHTML( "<fieldset>
+ <legend>Language</legend>
+ <div><select name=\"wpLanguage\">" );
+ foreach( $wgLanguageArray as $v)
+ $wgOut->addHTML( "<option
value=\"$v\" ".
+
(($v==$this->mLanguage)?"selected":"").
+ ">".$wgLang->getLanguageName( $v ).
+ "</option>" );
+ $wgOut->addHTML(
"</select></div></fieldset>" );
+ }
+
# First section: identity
# Email, etc.
#
Index: includes/User.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/User.php,v
retrieving revision 1.52
diff -u -3 -p -r1.52 User.php
--- includes/User.php 22 May 2004 04:53:02 -0000 1.52
+++ includes/User.php 22 May 2004 12:25:13 -0000
@@ -82,7 +82,7 @@ class User {
function loadDefaults()
{
- global $wgLang, $wgIP;
+ global $wgLang, $wgIP, $wgLanguageArray;
global $wgNamespacesToBeSearchedDefault;
$this->mId = $this->mNewtalk = 0;
@@ -90,10 +90,17 @@ class User {
$this->mEmail = "";
$this->mPassword = $this->mNewpassword = "";
$this->mRights = array();
- $defOpt = $wgLang->getDefaultUserOptions() ;
- foreach ( $defOpt as $oname => $val ) {
- $this->mOptions[$oname] = $val;
- }
+ $this->setDefaultOptions(array(
+ "quickbar" => 1, "underline" => 1,
"hover" => 1,
+ "cols" => 80, "rows" => 25,
"searchlimit" => 20,
+ "contextlines" => 5, "contextchars" =>
50,
+ "skin" => 0, "math" => 1,
"rcdays" => 7, "rclimit" =>
50,
+ "highlightbroken" => 1, "stubthreshold"
=> 0,
+ "previewontop" => 1,
+
"editsection"=>1,"editsectiononrightclick"=>0,
"showtoc"=>1,
+ "showtoolbar" =>1,
+ "date" => 0, "language" =>
"en"
+ ));
foreach ($wgNamespacesToBeSearchedDefault as $nsnum => $val) {
$this->mOptions["searchNs".$nsnum] = $val;
}
@@ -279,6 +286,13 @@ class User {
$this->mDataLoaded = true;
}
+ function setDefaultOptions($defOpt)
+ {
+ foreach ( $defOpt as $oname => $val ) {
+ $this->mOptions[$oname] = $val;
+ }
+ }
+
function getID() { return $this->mId; }
function setID( $v ) {
$this->mId = $v;