Affects Version/s: 2.9.7, 3.0.5, 3.1, 3.1.2
Fix Version/s: None
If your site uses a child language pack, then the first span tag must be the parent language. Otherwise, when a user using the child language views the text, it will not be in the correct language for them. For example, if your site uses en_us then the en span tag (as parent language) must be first i.e.
Note that this workaround only works if your site uses only one child language pack.If your site uses a child language pack, then the first span tag must be the parent language. Otherwise, when a user using the child language views the text, it will not be in the correct language for them. For example, if your site uses en_us then the en span tag (as parent language) must be first i.e. < span lang = "en" class = "multilang" >your_content_in English</ span > < span lang = "de" class = "multilang" >your_content_in_German</ span > Note that this workaround only works if your site uses only one child language pack.
Affected Branches:MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
Steps to reproduce:
- Ensure that the language packs en, en_us and de are installed on the site.
- Create a page resource in a course and enter the text
(disabling the HTMl editor)
- Save the page resource and then try viewing it with en_us selected as preferred user language.
Expected result: 'your_content_in English' is displayed.
Actual result: 'your_content_in_German' is displayed.
The problem: if a field has span block for several languages but not for en_us, the multilang filter picks the first span block from the field, ignoring the fact that en_us has en set as its parent language.
To quote David: The English (en) is implicit parent of all language packs in Moodle (so if a string is not translated, the English original is used). In most places in the code, if the parent language is reported to be English (en), it is actually interpreted as if there was no parent language. And I believe this is what is happening here.
Comment: The issue is built-in so to speak for en_us but I think it will also appear when, for example, I use a locally defined language de_de which has de as the parent.
Workaround: set the first span bloc for en (in case of en_us) or whatever the parent language is. Easy to do but requires documentation. Problematic if I have more than one language with different parents is used (like using en_us and de_de on my site).
Solution: The code should distinguish when a given language has parent language set explicitly from when the en is used when no other language is available.
Note: this problem does not exist in Moodle 1.9 (not that this really helps)