wordpress - Create a multilingual calendar in php - 'translating' with setlocale
I am creating an hourly calendar (a booking form), and I have my calendar created
{-code-1}
I have an array of booked dates in my{-code-2}
variable.
Now since the site I'm working on is build on wordpress and translated with WPML, I can check the language of the site like:
{-code-3}
So for instance for Swedish this will be{-code-4}
, for Germande
etc.
So I googled a bit, and what I found is that I can change the format of my time and dates by usingsetlocale()
. So I tried:
if ($current_lang == '{-code-4}') {
setlocale(LC_ALL, '{-code-4}-SE');
} elseif($current_lang == 'de') {
setlocale(LC_ALL, 'de-DE');
} else{
setlocale(LC_ALL, 'en-US');
}
I also tried with just:
setlocale(LC_TIME, '{-code-4}-SE');
But nothing changed on my frontend.
I tried putting myif-else
loop with$timestamp
inside (and even changed the name to match the translation), I put thefor
loop in, but nothing changed.
How do I handle the translation when building calendar with php?
Answer
Solution:
Ok, so the answer is that I was missing the proper locale. But that just points out the bigger issue - if the server I deploy this won't have it it won't be ok.
So the solution is to install the proper localization on server
or whatever language you need...