terminal42 / contao-changelanguage

ChangeLanguage is an extension for the Contao CMS which allows visitors to switch between different languages of your website.
43 stars 35 forks source link

Fix PHP 8 warnings and regional locales in `nav_dropdown` #213

Closed fritzmg closed 1 year ago

fritzmg commented 1 year ago

Fixes PHP 8 warnings like

ErrorException:
Warning: Undefined array key "en_at"

  at C:\Users\fmg\www\hps-new\vendor\terminal42\contao-changelanguage\contao\templates\nav_dropdown.html5:25

in case you use languages or language + region combinations not known to Contao/ICU.

fritzmg commented 1 year ago

Also, if you use a regional locale like de_AT in your website root, the translation from $arrLanguages would have never been accessed, as $item['link'] would be DE-AT and the access would have gone to de-at - but it's actually under de_AT. This PR fixes that by using $item['item']->getLocaleId() instead of strtolower($item['link']).

aschempp commented 1 year ago

Thank you @fritzmg