On Tuesday 11 May 2004 07:48, Brion Vibber wrote:
Nikola Smolenski wrote:
Yes. One can use all languages in same encoding
(all Latin-1, all
Latin-2, all UTF-8...) but can not mix encodings. It is trivial to
convert any language to UTF-8, except for the linktrail which is not used
anyway. Wikisource, Wikibooks and Wiktionary are in UTF-8 already, so I
don't think it will be a problem for them.
All the remaining latin-1 language files will have to be upgraded to do
that, or appropriate run-time upconversion added.
I don't think that runtime conversion is a good idea.
1) Create Language*Utf.php files which would be used aside current ones.
2) Write a small guide on how to convert existing language files to UTF-8.
I don't
think that language-specific sorting will be a
problem when introduced; an user will simply see text sorted in his
language.
The sorting will have to be hard-coded into the index fields in the
tables, so it must be uniform for all saved data. Everything displayed
will use the same uniform sorting method, as it's impractical to add
dozens of sort indexes for every conceivable language to a table with
hundreds of thousands of pages.
Oh, if there will be indexes, then yes, it probably could not be done. As
other things, it will have to fall back to English/default language.
But good luck
to one who is going to implement it in UTF-8 for all
languages! As for Chinese and Japanese, you were referring to
stripForSearch? I don't think that it is a problem, Chinese and Japanese
users will be able to search properly, other users will not, but they are
not now anyway.
Yes, that's one of the problem functions. It's about saving the index
data consistently, and reading it back properly. The data must always be
stored and interpreted in a consistent way.
I thought only when searching, but now I see that it is used when generating
data. Fallback to English for now, though perhaps later something could be
done.
I have got the CVS and made the first set of changes. They are unnoticeable if
the feature is not enabled and don't do anything even if it is, so they could
be safely introduced to the source. I will probably be able to submit rest of
the changes soon.
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).
Do you think that documentation for this is needed (if yes, can I use parts of
your e-mails to write it)?
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 16 May 2004 06:25:42 -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.109
diff -u -3 -p -r1.109 DefaultSettings.php
--- includes/DefaultSettings.php 15 May 2004 10:36:58 -0000 1.109
+++ includes/DefaultSettings.php 16 May 2004 06:25:45 -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.85
diff -u -3 -p -r1.85 GlobalFunctions.php
--- includes/GlobalFunctions.php 15 May 2004 14:03:00 -0000 1.85
+++ includes/GlobalFunctions.php 16 May 2004 06:25:48 -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 ) );
+ ( get_class( $object ) == 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/SpecialPreferences.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/SpecialPreferences.php,v
retrieving revision 1.42
diff -u -3 -p -r1.42 SpecialPreferences.php
--- includes/SpecialPreferences.php 13 May 2004 14:17:44 -0000 1.42
+++ includes/SpecialPreferences.php 16 May 2004 06:25:50 -0000
@@ -12,7 +12,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;
@@ -40,6 +40,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();
@@ -159,6 +160,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 ) {
@@ -202,6 +204,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 ) {
@@ -265,7 +268,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 );
@@ -321,6 +324,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.
#