I am trying to make a multilingual Drupal 6. My site is hosted on windows IIS 7.5 server.
I have my Po files are uploaded and everything works great now I try to go through the piece on site where I piece through the piece and avoid any thing that was when I first translated my site Is going for
The problem I'm trying to display in the date is in the locale format.
I have a PHP code that uses to display a local date:
$ format = "% a,% b% # d,% Y:% H:% M% p "if ($ language-> language == 'zh-hans') {$ loc = setlocale (LC_TIME, 'chs'); } And {$ loc = setlocale (LC_TIME, 'D'); } $ Mytime = strftime ($ format, $ time); $ Mytime = iconv (mb_detect_encoding ($ mytime), 'utf-8', $ mytime); Echo $ mytime; The above code should display in the local language of the current language (German's German)
German displays as expected:
Freetag, June 21, 2013: 16:48
But the sugar output looks like this:
???, ?? 21, 2013: 16:48 ??
Any ideas about how to fix this?
The first problem is that setting the LC_TIME range is enough by itself The striptime function will attempt to format time in the appropriate language, but it tries to use the 1252 codepace by default, so it is necessary to create the necessary letters for something like sugar Will be unable. I expected that the setting would be LC_TIME and possibly LC_CTYPE , but I would like to make it the only way LC_ALL . Then your setlocale calls should look like this: if ($ language-> language == 'zh-hans') {$ loc = setlocale (LC_ALL, Chs'); } And {$ loc = setlocale (LC_ALL, 'D'); } The next problem is that mb_detect_encoding will not always detect the correct encoding. What works for me for Windows, to get the current code page < Use the code> setlocale (LC_CTYPE, 0) . $ codepage = explode ('.', Setlocale (LC_ctcpe, 0)); $ Codepage = 'cp' $ Codepage [1]; The value returned from setlocale (LC_CTYPE, 0) by call is a combination of language name and codepace number separated by dot. We split the two parts with the explosion and then prefix with the number to get the code page in a form that can understand iconv . We can simply convert the string to UTF-8:
$ mytime = iconv ($ codepage, 'utf-8', $ mytime);
No comments:
Post a Comment