Support Forum
I have set up a field group for collecting course date information in posts belonging to the catgorty "courses". I have then set up a view for the data with MB Views which is working, it puts the information before the content. So far, so good.
However, the website is in German and uses the DE version of WordPress. But the names of the months from the date picker field remain in English: January, May, July instead of Januar, Mai, Juli for example. What do I have to do to translate these names correctly?
Hi,
Thank you for reaching out.
You can use the WordPress function date_i18n() via the proxy mb
to show the date in localized format, the field date should be saved in timestamp.
Here is the sample code
{% set field_date = mb.rwmb_meta('field_id') %}
Date: {{ mb.date_i18n('j. F Y', field_date) }}
Thanks for the reply. Where does that code go?
Hi,
You are talking about View so of course, the code is added to View.
https://share.getcloudapp.com/E0uYB20Z
I thought so, but that didn't work.
Hi,
Can you please share some screenshots of your View and post page?
These are the View code and its settings and the front end output. I copied your code before the View code and that did not change anything. You can see the word "July" in the front end. "August" is the same in both languages.
Hi,
I do not see the function date_i18n()
in your code. Can you please re-check it?
The code with your field ID is
{% set field_date = mb.rwmb_meta('erster_termin') %}
Date: {{ mb.date_i18n('j. F Y', field_date) }}
or
Date: {{ mb.date_i18n('j. F Y', post.erster_termin) }}
Aaah, I see now that I should have included the field id instead of "field_id". My bad. However, it still isn't working. There is a new fourth screenshot in Screenshots.
This is the currently active code. I also tried your second line. There are actually two date fields, so I used the code twice.
The page displaying the result is here: https://klang-entspannung-ruhe.de/lachyoga-jung-und-gesund-bleiben-durch-lachen/
It is still "July".
Oh my. Now I get where the code is supposed to go. Forget that screenshot. I put your code into the view and replaced {{ post.erster_termin | date( 'd. F Y' ) }} with it.
However, it now displays Mai (May) instead of July. German, but two months off. The content of the field hasn't changed.
As I can't edit the message with the link to the actual page anymore: The code adds today's date instead of the date set with the date picker. As the website is live I reverted everything to simply putting the date in numbers instead of month names.
Hi,
If the code post.erster_termin
show the date as well, please try to use this code
Termine: {{ mb.date_i18n('j. F Y', post.erster_termin) }} bis {{ mb.date_i18n('j. F Y', post.letzter_termin) }}
If it still does not work, please share your site credentials via this contact form https://metabox.io/contact/, I will help you to check it out.
I use Oxygen with a repeater and my date is in English (Oct) and not in Dutch (okt). What can I do to solve this? On an other site same code is correct.
i have same problem like Vince Balk . How can i traduce the date month ? Website is set correct , date input is set correct , in gridBuilder the month is showing in my language but in elementor date month appear in english . Can you help please ?