Datepicker months translation
-
Is it possible to translate the months displayed in the datepicker? I can’t find the plugin file where the months/days names are specified. Alternatively do you have a custom code to change them?
Thank you.
-
Hello @giordanomorotti,
Hope you’re doing well today! Thank you for reaching out to us.
The months on the Datepicker field should automatically change based on the Site Language selected from the WP Admin >> Settings >> General >> Site Language. Could you please confirm if you already tried that and it didn’t work?
Additionally, in case you have a multilingual site, I made a quick test with the TranslatePress plugin, added a secondary language and toggled to that language on the front end, and the datepicker months & days started showing me in that specific selected language without any issues.
Could you please explain a bit further about the issue you’re facing? Is it not switching the months/days on the frontend or changing the site language is having no effect on the datepicker field?
If your website is publicly accessible, could you please share the site/page URL where the form is present so that we can replicate the issue and check it further? In case you wish to share the site URL privately, please feel free to email us at [email protected]
Subject: ATTN: WPMU DEV support – wp.org
Please send:
– Link to your WordPress site
– Link back to this thread for reference (https://ww.wp.xz.cn/support/topic/topic-title/)
– Any other relevant URLs/infoTo ensure we don’t miss your email, please let us know here once you’ve submitted the form and make sure you use “ATTN: WPMU DEV support – wp.org” as the email subject.
Kind Regards,
SaurabhThank you for your reply,
My website is both in english (original language) and greek (translated with Weglot).
This means that my site language settings are set to english. Weglot does not translate the datepicker apparently.
I managed to show the week days in greek when you are on the greek version of the site using css, but I can’t do that with the months because it’s a ‘select’ element.
I also sent you a link of the form page so you can replicate.
Thank you very much
Hello @giordanomorotti,
I hope things are going well for you.
I appreciate you sharing the site URL I’ve reviewed and the form date picker showing the month in Greek. Here is the screenshot for reference: https://monosnap.ai/file/Ja1vlFptsfnu3euK6pi587sIpQeyk1.
In case you’re referring to another forum field, please let us know so we can review it for you. Also, if you’ve managed to resolve the issue, you can share that here too.
–
Kind regards,
Imran KhanHello,
Thanks for you reply. I managed to resolve the issue by adding a custom code to footer.php that I share here in case anyone has my same setup (Bilingual website + Weglot):
jQuery(document).ready(function($){
const monthsShort = ['Ιαν','Φεβ','Μαρ','Απρ','Μαι','Ιουν','Ιουλ','Αυγ','Σεπ','Οκτ','Νοε','Δεκ'];
$(document).on('focus', '.forminator-datepicker', function(){
// Only apply if page language is Greek
if(document.documentElement.lang !== 'el') return;
setTimeout(function(){
const dp = $('#ui-datepicker-div');
if(!dp.length) return;
dp.find(".ui-datepicker-month option").each(function(){
const monthIndex = parseInt($(this).val(), 10);
if(!isNaN(monthIndex)){
$(this).text(monthsShort[monthIndex]);
}
});
}, 15); // wait for datepicker to render
});
});This translates only when the site language is greek and puts the months in the right order (0=january, 1=february,…)
I’m glad this issue is resolved and thank you for sharing the code here. If you have a moment, I would greatly appreciate it if you could quickly rate our plugin. This will help us to keep improving the plugin and adding new features.
https://ww.wp.xz.cn/support/plugin/forminator/reviews/#new-post
Best Regards
Amin
The topic ‘Datepicker months translation’ is closed to new replies.