Details
Description
The current program logic for getting parent language strings is:
1) check location for existence of parent language
2) check parent language for string in that parent language location
The problem is that if the site has a parent language defined one would expect that parent language to be checked for the block; however, if the block does not have the parent language defined there is no langconfig.php for that location and a parent language for that location never gets checked. To re-create the issue with a fresh install:
1) Install the de_utf8 language pack
2) Install the de_du_utf8 language pack
3) Install a 3rd party block (for this example mrbs which has a lang folder for de_utf8 but not de_du_utf8)
4) Set your language to de_utf8
5) You should notice that all the regular blocks get translated to German; however, the mrbs block does not and is shown in English because the one location that defines the parent language /lang/de_du_utf8/langconfig.php then looks in that location for the string /lang/de_utf8/block_mrbs.php but the file is not there. Instead it is in /blocks/mrbs/lang/de_utf8/block_mrbs.php. But when the location /blocks/mrbs/lang/de_du_utf8 is checked there is no folder and thus no langconfig.php and thus no parent language is detected. However, I would still want and I think most users would expect that /blocks/mrbs/lang/de_utf8/block_mrbs.php would be checked.
I wonder if having a separate function for parent_lang would help defined along the lines of:
parent_lang($lang, $locations)
$lang is the current language (say de_du_utf8)
$locations are the various locations defined by get_string
if there is a parent language defined it will return it as a string (i.e. de_utf8)
if not it will return false
That way we can simply check
if ($parentlanguage=parent_lang($lang, $locations)) {
then if the $location/$module file does not exist ($CFG->dirroot/blocks/mrbs/lang/de_du_utf8/block_mrbs.php)
and there is a $parentlanguage defined we can check for $CFG->dirroot/blocks/mrbs/lang/de_utf8/block_mrbs.php
One problem is that if different langconfig.php files point to different parent languages. I cannot think of a case when this would practically happen but theoretically that could confuse things but for the sake of this issue I think it can be presumed that each child language has one and only one parent language.
CONTRIB-957 has more information about what brought about this issue. Let me know if there are any questions. I will try to work on a patch.
Peace - Anthony
Attachments
Issue Links
| This issue will help resolve: | ||||
| CONTRIB-957 | Incorrect language handling in MRBS |
|
|
|
| This issue is duplicated by: | ||||
| CONTRIB-1127 | Incorrect language handling in some modules with the dependent language packs |
|
|
|
| This issue has been marked as being related by: | ||||
| MDL-18669 | get_string needs to be refactored |
|
|
|
Hi Anthony,
why did you open this new
MDL-17763with the priority "minor"? If you own language is english then it should be no problem that the language falls back to english. But if your language by example is german de_du_utf8 and you only get english strings from en_utf8 then you will have a problem.One problem could be that every user can change his own language in profile. If an admin and all teachers would use the language parent package de_utf8 then nobody of them will see the problem why their participants get the module in english language.
I think that the priority should higher than "minor"
Best regards, Ralf
MDL-17763with the priority "minor"? If you own language is english then it should be no problem that the language falls back to english. But if your language by example is german de_du_utf8 and you only get english strings from en_utf8 then you will have a problem. One problem could be that every user can change his own language in profile. If an admin and all teachers would use the language parent package de_utf8 then nobody of them will see the problem why their participants get the module in english language. I think that the priority should higher than "minor" Best regards, Ralf