Hello All
Is it possible to use <?php setlocale (LC_ALL, "fa_IR.UTF-8"); ?> on Windows? (More specifically, in template.php)

Kind Regards
Ali Majdzadeh Kohbanani

Comments

iimitk’s picture

Windows does not support UTF-8 in setlocale(). You may want to use the iconv library to convert strings back & forth between different character encodings.

And of course, it's always better not to use Windows in the first place. If you're developing locally with it but your site will definitely be on a *nix box, then I guess it's fine to use setlocale() after deployment. Just make sure to test things thoroughly.
________________________
"Creativity is knowing how to hide your resources" - Albert Einstein.

Ali Majdzadeh Kohbanani’s picture

Mr. T
Hello
Thanks for your reply. My case is exactly as what you described, I am examining my site locally on Windows and I am going to deploy it on Linux. My requirement is to have a locale-aware (Persian) site with numbers, date format, currency format, ... being localized properly.

Kind Regards
Ali Majdzadeh Kohbanani

Ziggizag’s picture

>> And of course, it's always better not to use Windows in the first place

I do not like such a biased opinions at all !!!

In the first place you should try to provide problem resolution and not to promote given hardware/software platform as one may have some specific constrains forcing her/him to use specific system configuration. Telling her/him "better switch your system to 'nix" is nothing else but annoying.

Ziggi

iimitk’s picture

If you have the iconv library enabled (or can be) then the following code should work fine. I'm not pretty sure what the encodings for Farsi are though:

setlocale('LC_ALL', 'fa');
$date = strftime('%A، %d %B %Y', time());
print iconv('cp1256', 'utf-8', $date)

________________________
"Creativity is knowing how to hide your resources" - Albert Einstein.

Ali Majdzadeh Kohbanani’s picture

Mr. T
Thank you so much. I will definitely check it out. Thanks again.

Kind Regards
Ali Majdzadeh Kohbanani

Ali Majdzadeh Kohbanani’s picture

Mr. T
Hello again,
I tested the code you suggested. It works. Well, the output is the date (Gregorian format) but the day and the month are localized (I mean, they are translated into Persian), however the main requirement in Persian sites is to have date in Jalali (Shamsi) format. The same issue exists for the numeric system.
So there is no way to have localized date in Windows? Right? And if one wants to have it, he should write his own conversion function? Is this true for numeric system, currency and ... ?
You know, currently I am working on Windows to test everything, and I have written some of these conversion functions (date and numeric system) but the site is going to be served on Linux. If it would be possible to have all these features natively localized on Linux, it would be very nice.
Any ideas?

Kind Regards
Ali Majdzadeh Kohbanani

Ali Majdzadeh Kohbanani’s picture

I tested the issue on Linux (CentOS 5.1) but locale properties didn't show up. I mean, localized numbers, currency symbol, ... .
Any ideas?

Kind Regards
Ali Majdzadeh Kohbanani

iimitk’s picture

So there is no way to have localized date in Windows? Right? And if one wants to have it, he should write his own conversion function? Is this true for numeric system, currency and ... ?
You know, currently I am working on Windows to test everything, and I have written some of these conversion functions (date and numeric system) but the site is going to be served on Linux. If it would be possible to have all these features natively localized on Linux, it would be very nice.
Any ideas?

I guess by localized you mean dates like in the Hijri calendar? If so, unfortunately no, PHP does not have functions for these calenders and you have to write your own functions or adopt others.

Localization depends largely on the server & operating system software & settings. I cannot tell what functions or settings are configured by simply knowing it's on Linux. I suggest that you consult your Linux & server manuals or documentation for further information about what locale functions & settings are available for your system.
________________________
"Creativity is knowing how to hide your resources" - Albert Einstein.

Ali Majdzadeh Kohbanani’s picture

Mr. T
Thanks a lot. I will investigate more on the issue.

Kind Regards
Ali Majdzadeh Kohbanani