Enable default-language preload in com_modules to prevent overwrite on subsequent loads#47666
Open
iteidrm wants to merge 4 commits intojoomla:5.4-devfrom
Open
Enable default-language preload in com_modules to prevent overwrite on subsequent loads#47666iteidrm wants to merge 4 commits intojoomla:5.4-devfrom
iteidrm wants to merge 4 commits intojoomla:5.4-devfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request resolves # .
Summary of Changes
There is a bug in the "order" languages are loaded and cached in com_modules in combination with certain field layouts that are rendered in the backend when creating or editing a module. Here, different methods to load the respective language are used where one overrides the other.
Debug Language set to "On" masks the bug because it skips the preload.
When selecting an alternative layout provided by a site template (override) for a module, the layout dropdown renders labels in en-GB instead of the admin's current language. If no translation exists, of course the filename would be displayed.
A practical / real life scenario would be, if you created a custom site template and ship that with an override for, let's say: mod_articles. This override introduces a new layout called: fancy-with-sugar-on-top.php
The corresponding language string for that layout would then be:
TPL_YOURTEMPLATE_MOD_ARTICLES_LAYOUT_FANCY-WITH-SUGAR-ON-TOP="Fancy article layout with sugar on top"Testing Instructions
Download and install the demo template tpl_acme.zip. It has got a custom layout for mod_articles called: translateme.php. The template / style does not have to be activated.
I've included language files for en, es and de to test this with. Now, set the backend language either to Spanish or German, given you installed one of these first.
Create a new module instance of mod_articles and switch over to the Advanced Tab -> Layout. The dropdown should list all available overrides / layouts grouped by template + the default option.
Thanks to @joomdonation for proposing a better solution than my previous attempt.
Actual result BEFORE applying this Pull Request
Regardless of the selected backend language, the en-GB version of the translation is used.
Expected result AFTER applying this Pull Request
The drowdown shows the translation currently selected as the default.
Link to documentations
Please select:
Documentation link for guide.joomla.org: n/a
No documentation changes for guide.joomla.org needed
Pull Request link for manual.joomla.org: n/a
No documentation changes for manual.joomla.org needed