6.2
The Cassiopeia layout collapse-metismenu is shown as "Dropdown einklappbar"
(TPL_CASSIOPEIA_MOD_MENU_LAYOUT_COLLAPSE-METISMENU in language/de-DE/tpl_cassiopeia.sys.ini).
It is shown as "Collapsible Dropdown", the en-GB string. The same happens for every
layout name that a template translates in its .sys.ini.
Joomla 6.2.0, PHP 8.4. The code involved is unchanged in 6.2-dev, 6.3-dev and
7.0-dev; 5.4-dev has the same logic (without the language fallback chain added in 6.x).
Two calls load tpl_<template>.sys.ini in the same request:
The position field translates the position names via
ModulesHelper::getTranslatedModulePosition()
(administrator/components/com_modules/src/Helper/ModulesHelper.php). It loads
the file in the current language with $default = false, so the en-GB file is
not loaded:
$lang->load('tpl_' . $template . '.sys', $path, null, false, false)Later, ModulelayoutField (libraries/src/Form/Field/ModulelayoutField.php)
loads the same file with $default = true:
$lang->load('tpl_' . $template->element . '.sys', $client->path)Language::load() first loads the en-GB file, which has not been loaded yet;
array_replace() in loadLanguage() overwrites the German strings. The de-DE
file is then skipped because it is already in $this->paths, so the English
strings remain.
Minimal reproduction without the backend (run from the Joomla root):
<?php
define('_JEXEC', 1);
define('JPATH_BASE', __DIR__ . '/administrator');
require JPATH_BASE . '/includes/defines.php';
require JPATH_BASE . '/includes/framework.php';
use Joomla\CMS\Language\Language;
$key = 'TPL_CASSIOPEIA_MOD_MENU_LAYOUT_COLLAPSE-METISMENU';
$lang = new Language('de-DE');
$lang->load('tpl_cassiopeia.sys', JPATH_SITE, null, false, false); // ModulesHelper
echo $lang->_($key), "\n"; // Dropdown einklappbar
$lang->load('tpl_cassiopeia.sys', JPATH_SITE); // ModulelayoutField
echo $lang->_($key), "\n"; // Collapsible DropdownPossible fixes: load the file with $default = true in ModulesHelper (as the
other callers do), or make Language::load() re-apply the requested language
after it has loaded the default language for an already loaded file.
| Labels |
Added:
bug
|
||
| Labels |
Added:
No Code Attached Yet
|
||
Thanks, but I think #36954 addresses a different problem: it is about module titles stored in English in #__modules at installation (#35587). This issue is about the option names in the Layout field, which come from the template's .sys.ini and are translated correctly on the first load, but overwritten with en-GB at runtime when ModulelayoutField loads the file a second time (see the analysis and the reproduction script above). #36954 does not touch Language, ModulesHelper or ModulelayoutField, so the layout names would still be shown in English with that PR applied.
yes sorry I misunderstood your report as being for something completely different
See #36984