setlocale

Why PHP developers can't provide setlocale function as per thread scope

回眸只為那壹抹淺笑 提交于 2019-12-07 20:14:54
问题 We have setlocale function in PHP. This function has warning message The locale information is maintained per process, not per thread. If you are running PHP on a multithreaded server API like IIS or Apache on Windows, you may experience sudden changes in locale settings while a script is running, though the script itself never called setlocale(). This happens due to other scripts running in different threads of the same process at the same time, changing the process-wide locale using

PHP day of week numeric to day of week text not English

房东的猫 提交于 2019-12-06 14:08:12
问题 I tried to use setlocale() function on windows to convert days name in other language but it didn't work. <?php setlocale(LC_ALL, 'nl_NL'); echo date("l", strtotime($variable); ?> does anybody have an alternative for setlocale() ? I use the Codeigniter framework. 回答1: nl_NL is a typical Unix style locale name. On Windows, locales follow a different format. You want "nld", "holland", or "netherlands". Additionally, date() is not locale-aware. You probably want strftime() . 回答2: You should

Why PHP developers can't provide setlocale function as per thread scope

寵の児 提交于 2019-12-06 10:06:12
We have setlocale function in PHP. This function has warning message The locale information is maintained per process, not per thread. If you are running PHP on a multithreaded server API like IIS or Apache on Windows, you may experience sudden changes in locale settings while a script is running, though the script itself never called setlocale(). This happens due to other scripts running in different threads of the same process at the same time, changing the process-wide locale using setlocale(). For example, apache for windows with miltithread settings. I found these lines of code in PHP

How to format dates based on locale?

安稳与你 提交于 2019-12-05 11:18:02
In a template I display the day and month of a specific date : <div class="jour"><?php echo date('d',strtotime($content->getCreatedAt())) ?></div> <div class="mois"><?php echo date('M',strtotime($content->getCreatedAt())) ?></div> This works fine, problem is the month name is in English. Where do I specify that I want the month names in another locale, French for instance ? Symfony has a format_date helper among the Date helpers that is i18n-aware. The formats are unfortunately badly documented, see this link for a hint on them. default_culture only applies for the symfony internationalisation

PHP day of week numeric to day of week text not English

落爺英雄遲暮 提交于 2019-12-04 19:36:11
I tried to use setlocale() function on windows to convert days name in other language but it didn't work. <?php setlocale(LC_ALL, 'nl_NL'); echo date("l", strtotime($variable); ?> does anybody have an alternative for setlocale() ? I use the Codeigniter framework. nl_NL is a typical Unix style locale name. On Windows, locales follow a different format . You want "nld", "holland", or "netherlands" . Additionally, date() is not locale-aware. You probably want strftime() . You should consider using the extension intl which has IntlDateFormatter . From the documentation : $fmt = new

PHP date and setlocale do not always work

南笙酒味 提交于 2019-12-04 05:16:23
问题 After generating the required locale on our development server and using setlocale to provide PHP with the locale to use the dates formatted with strftime would appear fully translated, as expected. After reloading the page however, the dates were shown in the server's default locale: en_US . Reloading the pages multiple times resulted in almost a 50/50 chance of the dates being translated. Weird. What is happening here? 回答1: It appears that both Apache and Nginx webservers need to be

Symfony 2 setlocale (LC_ALL, 'de_DE')

感情迁移 提交于 2019-12-04 04:51:39
问题 I would like to display a date in TWIG in German. {{ event.beginnAt |date('l d.m.Y')}} But the output is "Friday 28.06.2013". Where should I use the setlocale function that displays the date in German? 回答1: You need to enable twig intl extension (it requires enabled intl functions in php) a then you just use: {{ event.beginAt | localizeddate('full', 'none', locale) }} Edited : If you want to just localized name of day, you can create your own Twig extension: src/Acme/Bundle/DemoBundle/Twig

php - can't get date in german language

微笑、不失礼 提交于 2019-12-04 03:21:31
问题 I try to display a date in German but it doesn't work. I'm using PHP with XAMPP. These are my approaches: function get_Datetime_Now() { setlocale (LC_TIME, "de_DE"); $tz_object = new DateTimeZone('Europe/Zurich'); $datetime = new DateTime(); $datetime->setTimezone($tz_object); return $datetime->format('l, d. F Y '); } echo get_Datetime_Now(); It returns "Sunday, 09. February 2014" but I wan't "Sonntag, 09. Februar 2014" (German language). I also tried this: setlocale(LC_TIME, "de_DE"); echo

How to get application language and device language separately in android?

白昼怎懂夜的黑 提交于 2019-12-03 01:23:35
My device language is in English and my application language is in Italian.So how I get the device language and application language programmatically ? get system language Resources.getSystem().getConfiguration().locale.getLanguage(); get app language String CurrentLang = Locale.getDefault().getLanguage(); This is the correct answer: getResources().getConfiguration().locale To Get System Language Use this: String DeviceLang =Resources.getSystem().getConfiguration().locale.getLanguage(); And For the Application Language Use this: String AppLang = Resources.getConfiguration().locale.getLanguage(

Unicode setlocale and strftime fails at windows

半世苍凉 提交于 2019-12-02 06:00:46
问题 I have one page and it's encoding is UTF-8 and If i try to run that code in unix system everythings looks fine but when i try to run in windows(7) some chracters looks question mark(�). How can run the code fine both of two system(without using iconv). header('Content-Type: text/html; charset=UTF-8'); setlocale(LC_ALL, 'turkish'); echo strftime("%d %B %Y, %H:%M"); 回答1: For those who is having similar problems on linux (this may work also for windows but not sure). Yes there is 'turkish' but