Stefanowitsch Posted October 4, 2019 Share Posted October 4, 2019 Hello! I am trying to set up a contact form using the API. Everything is working fine. I have just one problem with the InputfieldDatetime. I want to use a Datepicker in different languages. My languages are: default - Deutsch english - Englisch My Problem is: When switching between the contact form in both languages the Datepicker only shows english translations for days, etc. Here's how I set it up via API: $f = $modules->get('InputfieldDatetime'); $f->label = $field->form_label; $f->attr('id+name',$field->form_name); $f->addClass('form-control'); $f->required = $field->form_required; $f->wrapClass = 'form-goup row'; $f->dateInputFormat = 'd.m.Y'; $f->datepicker = 1; $f->timeInputSelect = 0; $form->append($f); // append the field to the form Notice: I found this thread here but the solution there does not work for me: I included these files to make the Datepicker work in Frontend: '../../wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.js', '../../wire/modules/Inputfield/InputfieldDatetime/timepicker/jquery-ui-timepicker-addon.js' When I add the following translation file in my header it WORKS in german. But it does not translate back to english when switching languages... ../../wire/modules/Jquery/JqueryUI/i18n/jquery.ui.datepicker-deutsch.js' So how does the language configuration for the Datepicker work? Is there an attribute for the API configuration? I found nothing in the documentation: https://processwire.com/api/ref/inputfield-datetime/ Link to comment Share on other sites More sharing options...
LostKobrakai Posted October 7, 2019 Share Posted October 7, 2019 This is less a question for how processwire works and more about how jquery datepicker works: https://jqueryui.com/datepicker/#localization Link to comment Share on other sites More sharing options...
Stefanowitsch Posted October 7, 2019 Author Share Posted October 7, 2019 I am setting up the datepicker via the processwire API. So i think it is a PW related question. The InputfieldDatetime module is looking for different languages in Line 58. So I was wondering if those languages can be set up via a configuration variable. https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.module Link to comment Share on other sites More sharing options...
LostKobrakai Posted October 7, 2019 Share Posted October 7, 2019 This sets the format for the input of dates/times (dateformat in the datepicker API), but it does not change the language of the datepicker UI, because this happens by including or not including those translation scripts you mentioned above. They basically set the datepicker to be in a certain language and don't just "make the translations available". Technically you can make jquery datepicker switch language at runtime, but I guess not including translations when not needed is the simpler solution. Edit: As to why the core itself doesn't handle including the correct files: ProcessWire doesn't have means of identifying languages. You can name your languages however you want. So it cannot map languages created by the user to something like the path for the datepicker translation, because it doesn't know a certain language is supposed to be e.g. german in the first place. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now