i know we are not supposed to report bugs.
however, i wanted to add a small contribution to the development cycle.
as you know, the associative array $lang is built in several files now, using the construct
$lang += array(
'KEY' => 'VALUE',
...
);
it is very possible to have the same KEY used, unwittingly, in several files.
i tried to detect it, and, lo and behold, there are quite a few (well, 12, as of now) duplicates.
as a service to the community, i am posting here both the little script that detects the duplicates, and the results:
the script:
Code: Select all
<?php
$modules = array('help_faq', 'mcp', 'search', 'ucp', 'common', 'groups', 'memberlist', 'viewforum', 'help_bbcode', 'posting', 'viewtopic');
$kkeys = array();
$keys = array();
$langdir = dirname(__FILE__);
foreach($modules as $module) {
require("$langdir/$module.php");
if (isset($lang)) {
$kkeys[$module] = $lang;
$keys[] = $module;
unset($lang);
}
}
$duplicates = array();
while ($module = array_shift($keys)) {
$keys_1 = array_keys($kkeys[$module]);
reset($keys);
foreach ($keys as $other_module) {
$keys_2 = array_keys($kkeys[$other_module]);
foreach(array_intersect($keys_1, $keys_2) as $dup)
$duplicates[] = "$dup, $module.php, $other_module.php";
}
}
print_r($duplicates);
?>
Code: Select all
Array
(
[0] => POST_DETAILS, mcp.php, common.php
[1] => DELETE_POST_CONFIRM, mcp.php, posting.php
[2] => FORK_TOPIC, mcp.php, viewtopic.php
[3] => UNLOCK_TOPIC, mcp.php, viewtopic.php
[4] => DELETE_ALL, ucp.php, common.php
[5] => UNREAD_MESSAGES, ucp.php, common.php
[6] => RECIPIENT, ucp.php, memberlist.php
[7] => GROUP_LEADER, ucp.php, memberlist.php
[8] => DELETE_MESSAGE, ucp.php, posting.php
[9] => DELETE_MESSAGE_CONFIRM, ucp.php, posting.php
[10] => MESSAGE_DELETED, ucp.php, posting.php
[11] => DAYS, common.php, posting.php
)
- in order for this script to work "as is", it have to be placed in the language directory (eg, pbpBB2/language/en)
- it is possible to compute the modules list programatically. i didnt do it, for simplicity
- in addition, there are some minor problems with the $lang['datetime'] array:
- 'TODAY' and 'YESTERDAY' are set twice
- there is a 'short month names' and 'long month names' parts. unfortunately, the month of May has the same key for both. right now the developers removed may from the short month-names part, but, in languages where the name of the fifth month contains more than 3 letters, there will be a slight problem. i would suggest to use two 0..11 arrays, namely short_month_name and long_month_names, rather than the associative way index on the english names, as it is done now.
- in the future, a similar script should be written, to help authors of language-paks to detect missing translations
- unfortunately, i couldnt think of a script to detect multiple uses of the same KEY in the same file