Important bug in lang.php fixed

Important bug in lang.php fixed

by David Mudrák -
Number of replies: 6
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
I have just patched lang.php to fix MDL-8409. So called "orphaned strings" are now kept in language pack files. The orphans are strings that do not have their referential English version in en_utf8. How may this happen? For example, you have translated the file "admin.php" from 1.8-dev English version. For some reason you edit and save this file at 1.7.1 site. The strings that were added after 1.7.1 are now kept in saved version with the "// ORPHANED" comment at the end of line. Until this patch, such strings would have been silently removed.
This patch should prevent accidental removals of already translated strings.
Average of ratings: -
In reply to David Mudrák

Re: Important bug in lang.php fixed

by Nicolas Martignoni -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
À propos, what about MDL-6688? Is there any chance to have it resolved for 1.8 (or 1.9)?
In reply to David Mudrák

Re: Important bug in lang.php fixed

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
I have just realized that this new "orphans" feature allows quite a new thing. A friend of mine sent me some of his old 1.6 translated string files (*.php). How to merge them into the current pack? So easy!
  1. I updated my language pack from CVS
  2. I made a backup of current version of the sent string files into the /tmp/backup
  3. I copied sent files and overwrote the current ones
  4. I copied the the current files back from /tmp/backup into the language pack directory - BUT I did not overwrite them. I chose append when asked by file manager. Thus those sent files looked like:

    <?PHP // $Id created with old 1.6 month ago$
    $string['blahblah'] = 'My friend's version';
    $string['wasmissing'] = 'This was missing in the HEAD';

    $string['only16string'] = 'This is not in HEAD 1.8 any more';
    ?>
    <?PHP // $Id created with HEAD 1.8 week ago$
    $string['blahblah'] = 'My own version';
    ?>

  5. When re-saved in lang.php, the file gets merged as wanted (because the $string is an array, the later defined strings win):

    <?PHP // $Id created with HEAD 1.8 today$
    $string['blahblah'] = 'My own version';
    $string['wasmissing'] = 'This was missing in the HEAD';
    $string['only16string'] = 'This is not in HEAD 1.8 any more'; // ORPHANED
    ?>

Thus me as a language pack coordinator can easily merge translated pieces of strings sent by volunteers - even these pieces were translated using older version. No strings should get lost smile