tinacious Posted November 23, 2014 Share Posted November 23, 2014 Hello all. Thank you in advance for your help. I am making a bilingual website in French and English using ProcessWire. It's my first time doing a multi-language site. I am storing a date object with ProcessWire in the database using the date field and retrieving it in PHP. I am detecting the language that the user is viewing the site in and then setting the PHP locale like this in a PHP object called $strings: setlocale(LC_ALL, ($is_english ? 'en_US' : 'fr_FR')); Then when I am getting the date, I am doing this: $formatted_date = strftime($strings['date_format'], $page->date); The characters with accents (like décembre) are getting mangled. Am I doing something wrong? I haven't been able to figure it out. When the client adds French characters in the TinyMCE or other fields, they are not mangled, which leads me to believe I may be doing something incorrectly with the above code. Is there an optimal way of retrieving dates in different languages for multi-lingual ProcessWire sites? Thanks! Link to comment Share on other sites More sharing options...
netcarver Posted November 23, 2014 Share Posted November 23, 2014 Hi tinacious, Does wrapping your call to strftime() in utf8_encode() fix this for you? Like this... $formatted_date = utf8_encode(strftime($strings['date_format'], $page->date)); 1 Link to comment Share on other sites More sharing options...
tinacious Posted November 25, 2014 Author Share Posted November 25, 2014 Hi tinacious, Does wrapping your call to strftime() in utf8_encode() fix this for you? Like this... $formatted_date = utf8_encode(strftime($strings['date_format'], $page->date)); Thanks for the reply but that just mangles it further, adding 2 additional mangled characters. Link to comment Share on other sites More sharing options...
horst Posted November 25, 2014 Share Posted November 25, 2014 @tinacious: what do you get when you try: setlocale(LC_ALL, ($is_english ? 'en_US' : 'fr_FR.UTF-8')); 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now