Jump to content

Date strings characters with accents in French getting mangled


tinacious
 Share

Recommended Posts

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!

post-466-0-85370800-1416707891_thumb.png

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...