Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Problem with Event calendar and localizated dates


Reply

16 Posts   3413 Views

Avatar
UncleCheese

8 September 2009 at 11:35am 4085 Posts

Run an update and let me know if that fixes the problem for you.

Avatar
UncleCheese

8 September 2009 at 11:39am 4085 Posts

Whoops. Missed the last two posts.

Banal, I don't think we need to worry about users who already use UTF-8 because Silverstripe throws an HTTP header for the UTF-8 charset on all responses, right?

Avatar
banal

8 September 2009 at 6:56pm (Last edited: 8 September 2009 6:57pm), Community Member, 901 Posts

Hey UncleCheese
Sadly not, if you run an UTF-8 encoded string through utf8_encode, you'll end up with garbled umlauts. And that's exactly what will happen if you use a UTF-8 locale and run the strftime output through utf8_encode. I suggest you revert back to the previous version and tell the users to use the setlocale fix, where the user has to switch to an UTF-8 locale.

Avatar
joninjas

6 November 2009 at 11:10pm Community Member, 32 Posts

Hi all,

I had the same problem in german, that März was written with ? instead of ä.

I activated the following line in event_calendar/code/CalendarUtil.php (line: 85):

// Need to figure out how we're handling non- UTF-8 users.
return utf8_encode(strftime($char, $ts));
//return strftime($char,$ts);

With the return strftime($char,$ts); it didn't bring back the right value, it was ISO-8859-1 encoded and the website showed, to whatever encoding changed in the browser, mixed content with ä and ?.

Now I can run the whole site under UTF-8. Cool

Cheers
Jonas

Avatar
Beutlin

27 February 2010 at 2:15pm (Last edited: 27 February 2010 2:17pm), Community Member, 2 Posts

Hello,

is guess, this is still an unsolved problem. On my PC (de_DE.utf8) only

return strftime($char,$ts);

works. On my server (de_DE) only

utf8_encode(strftime($char, $ts));

works.

I attached a patch for CalendarUtil.php at revision 89 to this post, that solves this Problem. It is based on [url]http://www.php.net/manual/en/function.utf8-encode.php#89789[/url].

Attached Files
Avatar
UncleCheese

27 February 2010 at 3:20pm 4085 Posts

Wow.. this is excellent. Huge thanks, Beutlin.

Avatar
Beutlin

28 February 2010 at 2:22am Community Member, 2 Posts

You're welcome. But one more comment: the patch expects, that the target's character set is UTF-8, which is - I suppose - default in Silverstripe. But maybe you can test this using:

ContentNegotiator::get_encoding()

See: [url]http://api.silverstripe.org/sapphire/control/ContentNegotiator.html#get_encoding[/url]

Maybe:

$string = strftime($char, $ts);
if (ContentNegotiator::get_encoding() == 'utf-8' && !mb_check_encoding($string, 'utf-8'))
   return utf8_encode($string);
else
   return $string;

Avatar
Juanitou

28 February 2010 at 3:39am Community Member, 323 Posts

Thanks Beutlin!