Date field output not localized

Support MB Views Date field output not localizedResolved

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #27972
    info@computer-service-remscheid.de[email protected]
    Participant

    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?

    #27976
    Long NguyenLong Nguyen
    Moderator

    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) }}
    #27983
    info@computer-service-remscheid.de[email protected]
    Participant

    Thanks for the reply. Where does that code go?

    #27995
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You are talking about View so of course, the code is added to View.
    https://share.getcloudapp.com/E0uYB20Z

    #27998
    info@computer-service-remscheid.de[email protected]
    Participant

    I thought so, but that didn't work.

    #28014
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Can you please share some screenshots of your View and post page?

    #28021
    info@computer-service-remscheid.de[email protected]
    Participant

    Screenshots

    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.

    #28033
    Long NguyenLong Nguyen
    Moderator

    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) }}

    #28036
    info@computer-service-remscheid.de[email protected]
    Participant

    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".

    #28037
    info@computer-service-remscheid.de[email protected]
    Participant

    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.

    #28042
    info@computer-service-remscheid.de[email protected]
    Participant

    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.

    #28047
    Long NguyenLong Nguyen
    Moderator

    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.

    #38620
    Vince BalkVince Balk
    Participant

    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.

    #46321
    Bogdan MichiteleBogdan Michitele
    Participant

    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 ?

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.