Closed intco closed 6 years ago
How do I reproduce the initial problem?
Create two website root with the following languages: it and en (i.e. the first root page with language it and the second root page with language en)
Then upload a file and set meta data. The first language metaWizard shows is "english" I think it should be "italian".
Which back end language did you set?
The backend language it's not relevant.
I think it's due to the asort call at
because of the asort call the languages will be shown in alfabetically order so "Inglese" (italian word for english) will be ever shows before "Italiano" (italian word for italian)
I think this: https://github.com/contao/core/blob/c7f0310ebd3f4e8b32a82f10f9ffa6827ab4b2a3/system/modules/core/widgets/MetaWizard.php#L109
should also be:
$objRootLangs = $this->Database->query("SELECT REPLACE(language, '-', '_') AS language FROM tl_page WHERE type='root' ORDER BY sorting");
so these lines: https://github.com/contao/core/blob/c7f0310ebd3f4e8b32a82f10f9ffa6827ab4b2a3/system/modules/core/widgets/MetaWizard.php#L109-L110
should be replaced (i've changed variables names for readability) with:
$objRootLangs = $this->Database->query("SELECT REPLACE(language, '-', '_') AS language FROM tl_page WHERE type='root' ORDER BY sorting");
$siteLanguages = array();
foreach ($objRootLangs->fetchEach('language') as $rootLang) {
if (!empty($languages[$rootLang]))
{
$siteLanguages[$rootLang] = $languages[$rootLang];
}
}
$languages = $siteLanguages;
Maybe a more correct approach will be to first shows the "fallback language" root and then show others in the order they appear in the "site structure"
The backend language it's not relevant.
It is relevant, so which language did you use?
The backend language is set to "Italian"
The languages being ordered alphabetically is correct. However, we have recently made a change in contao/core-bundle@94181f7ca21361576c5511f461d18957cf5c28cf so that languages matching the back end user's language are shown first. Maybe we should backport this?
https://github.com/contao/core/blob/c7f0310ebd3f4e8b32a82f10f9ffa6827ab4b2a3/system/modules/core/widgets/MetaWizard.php#L110
The "array_intersect_key" call nullifies the array_flip one.
just replace the highlighted line:
with the following:
The above code honors the array_flip call.