1

In a Dutch site, when I output {{ entry.postDate.diff(now)|duration }}, the result is something like 5 dagen, 3 uren, 43 minuten, and 42 seconden. Why is the English "and" not localized? My understanding (I don't speak Dutch) is that "and" should be "en" in Dutch...

Am I missing some crucial step here? Thanks!

0

Because neither Craft (nor Yii) provides a default Dutch translation for the word "and".

https://github.com/craftcms/cms/tree/develop/src/translations

https://github.com/yiisoft/yii2/tree/master/framework/messages

You can provide your own translations using Craft's static translations feature, though: https://docs.craftcms.com/v3/static-translations.html

| improve this answer | |
  • Oh, really? I didn't know static translations work for substrings of the passed variable/string. Last I used them was in Craft 2, and I don't remember them applying to substrings then, but perhaps I just missed that ability. Thanks! – Sandwich Jul 17 '19 at 8:03
  • Ok, I just tested this, and it's not working on the 'and' substring. In the template I have {{ entry.postDate.diff(now)|duration(false)|t }}, and my translations/nl/site.php file has <?php return [ 'and' => 'en', ]; But the output still has 'and', not 'en'. – Sandwich Jul 17 '19 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.