hofff / contao-calendarfield

GNU Lesser General Public License v3.0
18 stars 3 forks source link

Extended locales (eg. de-CH) don't load language files #42

Closed t-muir closed 3 years ago

t-muir commented 6 years ago

The module is works ok with simple language settings like "de" or "en".

If the language of the page has been set to an extended locale, such es de-DE and de-CH, the module passes a language setting and creates a path to a language file that does not exist:

$lang = $objPage->language;

$GLOBALS['TL_JAVASCRIPT'][] = 'assets/hofff/calendarfield/jquery-ui.datepicker/js/i18n/datepicker-' . $lang . '.js';

Maybe something like:

$lang = substr($objPage->language, 0, 2);
cliffparnitzky commented 6 years ago

That is not as simple, as it seems. There are a lot of language files, shipped with calendarfield (see https://github.com/hofff/contao-calendarfield/tree/master/CT_ROOT/assets/hofff/calendarfield/jquery-ui.datepicker/js/i18n). Some only with short language identifier (e.g. de) and some with complete locale (e.g. en-GB).

If the page language is en, we need a mapping to en-GB (see here: https://github.com/hofff/contao-calendarfield/blob/master/CT_ROOT/system/modules/hofff_calendarfield/forms/FormCalendarField.php#L80). But if the page language is de-CH, the mapping shall be de.

I think this part should be configurable. In the easiest way via TL_CONFIG. That is also good for overwriting.

@frontendschlampe What's your opinion?

cliffparnitzky commented 3 years ago

Will be changed with version 4.0.0

cliffparnitzky commented 3 years ago

Changed to flatpickr since 15d352d94476df58e04f9d7d6d70b4db5757ca7b