I decided to start a fresh thread because a lot of the issues there were resolved along the way. This is about bug MDL-12433.
Basically I have now implemented a patch which adds support for conditional expressions in language files. It works like this:
- You have an existing language string like '$a bottles'.
- But if $a is 1, you want it to say '1 bottle', not '1 bottles'.
- In the translation editor, you find the language string and click 'Add except' beside it. This brings up a little table with 'Except when' and 'Value' columns.
- Under 'Except when' you enter $a==1 (a PHP expression that is true when $a is 1)
- Under 'Value' you enter $a bottle (or '1 bottle' if you like, since you know it's 1; or even 'one bottle' if you prefer).
If you want to comment on this feature here please do. Basically the question is, should this patch be incorporated into Moodle 2.0? (And possibly even in a 1.9 release such as 1.9.1, 1.9.2, etc. It won't be in the initial 1.9 version.)
If you are a translator you might have an opinion on whether this feature would be useful to you. Is it too confusing, does it need more explanation, is it not worth doing for the small benefit, etc.
If you're an advanced developer you could even try applying the patch to a 1.9 or HEAD install to see how (or if!) it works. There are probably lots of bugs as it hasn't been tested. Maybe it doesn't even work at all You can let me know.
It is important to note that this patch is not intended to solve all grammar issues in the translation file. However it does offer a simple and
quite flexible way to solve a reasonable proportion of grammar issues in some languages. Basically I know there are some problems that can't really be solved by this technique but it does offer an improvement.
Finally just to note, after this Friday I am away for 2 weeks but I'll see all comments on the bug (and here, assuming I remember) when I get back.