totoff Posted May 27, 2014 Share Posted May 27, 2014 Hi, I'm using $date = utf8_encode(strftime('%d. %B %Y', $child->getUnformatted('date'))); to render dates from a datefield in German. If the date contains umlauts like "March" which is "März" in German it renders a weird charakter and capitalises the "Ä": <span class="date">14. März 2014</span> The admin is not localised, the entry in the datefield is: 14 March 2014 3:23 pm Any ideas? Thanks. Link to comment Share on other sites More sharing options...
Raymond Geerts Posted May 27, 2014 Share Posted May 27, 2014 I'm not sure if you already are using setlocale somewhere, But you could try setting it like this: setlocale(LC_ALL, "de_DE.UTF-8"); instead of: setlocale(LC_ALL, "de_DE"); Link to comment Share on other sites More sharing options...
totoff Posted May 27, 2014 Author Share Posted May 27, 2014 Many thanks for your reply Raymond, I already have setlocale(LC_ALL, "de_DE.UTF-8"); in my config.php. Sorry for not mentioning it. 1 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted May 27, 2014 Share Posted May 27, 2014 It's a guess here, maybe it's helpfull. Looks like it has something to do with encodings. Did you copy & paste in some codes as that could leave some artefacts. If you're on the mac, use TextWrangler/BBedit and use the command 'Zap Gremlins'. Or what is also worth trying: 1. copy the code to a textarea. 2. create a new document. 3. copy the code from the textarea to the new document. Link to comment Share on other sites More sharing options...
Michael Murphy Posted May 27, 2014 Share Posted May 27, 2014 I and another developer friend have also struggled with this problem on a few sites with different hosting companies. There was a previous post about issues with umlauts and dates but I never found a workable solution. It is either a bug with Processwire or an issue with the hosting company and how they have configured the server (from what I remember, it does not seem to happen in local development). My hack around it was to create a little function that checked for March and assigned it the correct März - something like this : $monthNumber = strftime("%m", $child->getUnformatted("dates")); if($monthNumber == 3){ $monthName = 'März'; } else { $monthName = strftime("%B", $child->getUnformatted("dates")); } Link to comment Share on other sites More sharing options...
totoff Posted May 27, 2014 Author Share Posted May 27, 2014 Did you copy & paste in some codes as that could leave some artefacts. I did import a XML file with the new wordpress importer. As I have > 80 posts I can't correct them by hand. What leaves me clueless is that even if I set the date say to today, save the page, and then set it agin to somewhere in march the problem remains the same. @michael you posted while I was replying to Martijn. I'll give your solution a try. Sounds promising. Thanks. Link to comment Share on other sites More sharing options...
Nico Knoll Posted May 27, 2014 Share Posted May 27, 2014 Why do you use utf8_encode? Should be working without it. Or try htmlentities() Edit: Only for you a special service: The code of this: <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <?php setlocale(LC_ALL, "de_DE.UTF-8"); echo 'Using utf8_encode:<br>'; $date = utf8_encode(strftime('%d. %B %Y', 1395929985)); echo $date; echo '<br><br>Without utf8_encode:<br>'; $date = strftime('%d. %B %Y', 1395929985); echo $date; echo '<br><br>Without utf8_encode and with htmlentities():<br>'; $date = htmlentities(strftime('%d. %B %Y', 1395929985)); echo $date; ?> </body> </html> Edit 2: Here is the resulting source code: <html> <head> <meta charset="utf-8"> <title></title> </head> <body> Using utf8_encode:<br>27. März 2014<br><br>Without utf8_encode:<br>27. März 2014<br><br>Without utf8_encode and with htmlentities():<br>27. März 2014 </body> </html> 5 Link to comment Share on other sites More sharing options...
totoff Posted May 27, 2014 Author Share Posted May 27, 2014 @nico Why do you use utf8_encode? Should be working without it. Thanks, that does the trick! 1 Link to comment Share on other sites More sharing options...
Nico Knoll Posted May 27, 2014 Share Posted May 27, 2014 No problem I hope this answer can help all of the other people having problems with utf8 and umlauts, too 3 Link to comment Share on other sites More sharing options...
tires Posted March 7, 2017 Share Posted March 7, 2017 Very strange. On one site it works using: <? setlocale(LC_ALL, "de_DE.UTF-8"); ?> <?=strftime('%e. %B %Y', $page->getUnformatted('mydate')); ?> on the other site i have to use: <?=utf8_encode(strftime('%e. %B %Y', $page->getUnformatted('mydate'))); ?> Is that an error in processwire? Or a matter of the webserver settings? Link to comment Share on other sites More sharing options...
matjazp Posted March 7, 2017 Share Posted March 7, 2017 Is de_DE.UTF-8 locale installed on the other site? Link to comment Share on other sites More sharing options...
tires Posted March 7, 2017 Share Posted March 7, 2017 2 hours ago, matjazp said: Is de_DE.UTF-8 locale installed on the other site? What do you mean by "installed" ... where can i check this? Link to comment Share on other sites More sharing options...
adrian Posted March 7, 2017 Share Posted March 7, 2017 42 minutes ago, tires said: What do you mean by "installed" ... where can i check this? On the command line, type: locale -a Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 7, 2017 Share Posted March 7, 2017 PHP can only use the languages installed on the host environment, e.g. the server. Otherwise setlocale() won't work. 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