Date and frequency translation

fileeefileee Member
in Help edited August 2016
Let me start by asking how far you are with your major translation refactoring? :)

Then i have 2 questions regarding this code that belongs to the cart template (more specifically it displays a subscription see here):

{% if item.sub_frequency != '' %}
<li class="fc-cart__item__option--subscription-details">
{{ config.lang.cart_subscription_details|raw }}
<li class="fc-cart__item__option--subscription-frequency">
<span class="fc-cart__item__option__name">{{ config.lang.cart_frequency|raw }}</span>:
<span class="fc-cart__item__option__value">{{ item.sub_frequency }}</span>
<li class="fc-cart__item__option--subscription-startdate">
<span class="fc-cart__item__option__name">{{ config.lang.cart_start_date|raw }}</span>:
<span class="fc-cart__item__option__value">{{ item.sub_startdate }}</span>

1) How can i change the date format. In german it is DD.MM.YYYY instead of YYYY-MM-DD in english. I'm thinking about writing an IF condition that checks for the custom Lang parameter and then uses some twig magic to format the date. Any better idea?

2) item.sub_frequency shows "Every month" or "Every year" in our case. I guess this is dynamically constructed somehow(based on what was given for the subscription frequency). Any idea how we could translate that? My only idea is to actually check for these 2 cases and also write some nasty IF condition and then provide a hardcoded string for that. ugly, but then at least those cases are translated.
  • fc_adamfc_adam FoxyCart Team

    We are getting closer with our multi-lingual native support. It's currently being tested and finalised. We don't have an ETA yet, but it's definitely getting close.

    1) The date format isn't necessarily an english format, but more an international format - to get around any local issues for the order of the day and month. You can certainly change it as you see fit though using Twig's date filter. Information on that here:

    2) The strings for the frequency do come from the language file - but as that specific string is generated server-side, it's missed in the custom lang snippet. Unfortunately for now you'll need to take the twig logic approach to do some checking for if the lang is not the default store language and get the new values accordingly.
  • ok thx for answering. then i will do this and just hope that the multi-lingular refactoring will be there in the future to make my life easier ;)
Sign In or Register to comment.