I can’t find the answer anywhere in the documentation. How can I translate the date formats?
If the user chooses French, i’d want to display it as “15 septembre 2021” (notice september is spelled the french way with no capital on the “s” and also with no comma between “september” and “2021”)
If they choose English, id’ want it displayed as “September 15, 2021” (notice there is a comma after “15”)
This is how I have it at the moment:
<?= $articlesToShow->first()->date()->toDate('j F Y') ?>
That happens automatically depending on the locale settings. If you additionally want to change the format string, you can do that in your language translation strings.
Thanks for your help. We’re almost there. So as fort he format, I got it working for both languages. The only issue is that “September” is written the same way in both languages. From what I gathered, for it to be translated in French, I need to set locale. How can I achieve this (i’m not much of a coder so any code example will help me a lot)?
You can also use more detailed locale settings, like explained here: locale | Kirby CMS (but for your multi-language site, you do this in the language files, not in the config)
Also make sure that you are using the right locale settings that are actually installed on your system. You can check this in on the command line with
You do not have to change your system’s language. You just have to make sure that the locale aou want to use is installed. Is fr_CA.utf8 installed on your system?