Last modified: 2011-03-13 18:06:14 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T8382, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 6382 - Add a global array for custom messages
Add a global array for custom messages
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
Internationalization (Other open bugs)
1.7.x
All All
: Lowest enhancement with 2 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
http://mail.wikipedia.org/pipermail/m...
: patch
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-06-20 12:29 UTC by Rotem Liss
Modified: 2011-03-13 18:06 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch (trunk) (31.86 KB, patch)
2006-06-20 12:30 UTC, Rotem Liss
Details
Example for a code using the current "addMessages" (777 bytes, text/plain)
2006-06-20 12:31 UTC, Rotem Liss
Details
Example for a code using the hooks (725 bytes, text/plain)
2006-06-20 12:32 UTC, Rotem Liss
Details
Example for a code using the global array (582 bytes, text/plain)
2006-06-25 17:19 UTC, Rotem Liss
Details
Patch (trunk) (34.46 KB, patch)
2006-06-25 18:08 UTC, Rotem Liss
Details

Description Rotem Liss 2006-06-20 12:29:45 UTC
Currently, all the extensions use $wgMessageCache->addMessages to add system
messages, and usually don't translate them into other languages.

Actually, translating the extensions into other languages is something hard
using the current tools. We can check $wgLanguageCode to get the current
language, use "if" structure and add the localized messages, but some messages
are interface messages and should be retrieved from the user-chosen language
($wgLanguageCode), while others are content messages and should retrieved from
the site content language ($wgContLanguageCode). We can build two "if"
statements, but the code is getting longer and more complicated. Finally, there
is a special type of messages – log entry messages. These messages should be
used as content messages when executing the action and getting the log entry
into the recent changes comment, and as interface messages in Special:Log. This
usage is completely not possible to implement with extension system messages,
and is not possible to implement using $wgMessageCache->addMessages.

Even without taking notice to the log entry messages, something like that should
be used to add a new user group:

# Allow only privilleged users to import pages
$wgGroupPermissions["sysop"]["import"] = false;
$wgGroupPermissions["import"]["import"] = true;

# Add the interface messages
if ($wgLanguageCode == 'en') {
	$wgMessagesCache->addMessages( array(
		"group-import" => "Importers",
		"group-import-member" => "Importer",
	) );
} elseif ($wgLanguageCode == 'he') {
	$wgMessagesCache->addMessages( array(
		"group-import" => "מייבאים",
		"group-import-member" => "מייבא",
	) );
}

# Add the content messages
if ($wgContLanguageCode == 'en') {
	$wgMessagesCache->addMessages( array(
		"grouppage-import" => "{{ns:help}}:Import",
	) );
} elseif ($wgContLanguageCode == 'he') {
	$wgMessagesCache->addMessages( array(
		"grouppage-import" => "{{ns:help}}:ייבוא",
	) );
}

This code is complicated, not organized and not understandable. It breaks the
array $wgForceUIMsgAsContentMsg or a change in its use, bypasses wfMsg vs.
wfMsgForContent, and as I've already said, we cannot bypass the problem in such
way for log entries.

Therefore, I've suggested here:
http://mail.wikipedia.org/pipermail/mediawiki-i18n/2006-May/000063.html new
hooks, which pass the messages as an argument, and messages can be added to
them. I've published the code and checks here:
http://mail.wikipedia.org/pipermail/mediawiki-i18n/2006-June/000076.html and you
can see that the following code is much cleaner:

# Allow only privilleged users to import pages
$wgGroupPermissions["sysop"]["import"] = false;
$wgGroupPermissions["import"]["import"] = true;

# Translation hooks
$wgHooks['AddMessagesEn'][] = 'wfImportMessagesEn';
$wgHooks['AddMessagesHe'][] = 'wfImportMessagesHe';

# English messages
function wfImportMessagesEn( &$messages ) {
	$messages += array(
		"group-import" => "Importers",
		"group-import-member" => "Importer",
		"grouppage-import" => "{{ns:help}}:Import",
	);
	return true;
}

# Hebrew messages
function wfImportMessagesHe( &$messages ) {
	$messages += array(
		"group-import" => "מייבאים",
		"group-import-member" => "מייבא",
		"grouppage-import" => "{{ns:help}}:ייבוא",
	);
	return true;
}

I'm posting the most updated patch here, and it would be nice if you make some
comments about it, or suggest a better way.

Thanks.
Comment 1 Rotem Liss 2006-06-20 12:30:24 UTC
Created attachment 1991 [details]
Patch (trunk)

The hooks I've described above.
Comment 2 Rotem Liss 2006-06-20 12:31:50 UTC
Created attachment 1992 [details]
Example for a code using the current "addMessages"
Comment 3 Rotem Liss 2006-06-20 12:32:09 UTC
Created attachment 1993 [details]
Example for a code using the hooks
Comment 4 Rotem Liss 2006-06-25 17:14:24 UTC
Thinking again, a global messages array will be even better: the code for adding
the messages is much shorter than in any other way, and no hooks should be used.
I'm going to try implementing this.
Comment 5 Rotem Liss 2006-06-25 17:19:09 UTC
Created attachment 2010 [details]
Example for a code using the global array

The code is now even shorter.
Comment 6 Rotem Liss 2006-06-25 18:08:53 UTC
Created attachment 2011 [details]
Patch (trunk)

This is the code suggestion. The example code is working on it. What do you
think about it? Do you have other suggestions?
Comment 7 Rotem Liss 2006-07-05 19:01:42 UTC
Added additional parameter to MessageCache::addMessages instead.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links