setlocale

PHP date and setlocale do not always work

耗尽温柔 提交于 2019-12-02 04:26:27
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? It appears that both Apache and Nginx webservers need to be restarted after having locales generated for them to be able to use them without problems. Either use service

Symfony 2 setlocale (LC_ALL, 'de_DE')

人盡茶涼 提交于 2019-12-02 02:25:10
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? 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/DateExtension.php namespace Acme\Bundle\DemoBundle\Twig; class DateExtension extends \Twig_Extension { public

Unicode setlocale and strftime fails at windows

故事扮演 提交于 2019-12-02 01:09:47
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"); For those who is having similar problems on linux (this may work also for windows but not sure). Yes there is 'turkish' but there is also 'tr_TR.utf8' . If you use 'tr_TR.utf8' most probably your problems will be washed away. Same

List of locales in Windows

跟風遠走 提交于 2019-12-01 06:44:25
On *nix systems you can do locale -a to get a list of available locales. What is the equivalent command (or action) in Windows? I've seen lists on the Internet, but most of them are of just locale labels and not actual locale names. Plus, not all systems are guaranteed to have all of them installed, right? Note that my definition of "locale" here is "locale string", i.e. a second parameter to C's setlocale() which will result in a non-NULL return value. Programmatic answers are also fine, I'm just tired of brute force guessing Windows locale names. Eric Pi Initially, I couldn't find a C/Win32

List of locales in Windows

江枫思渺然 提交于 2019-12-01 05:12:00
问题 On *nix systems you can do locale -a to get a list of available locales. What is the equivalent command (or action) in Windows? I've seen lists on the Internet, but most of them are of just locale labels and not actual locale names. Plus, not all systems are guaranteed to have all of them installed, right? Note that my definition of "locale" here is "locale string", i.e. a second parameter to C's setlocale() which will result in a non-NULL return value. Programmatic answers are also fine, I'm

Does std::locale::global make affect to printf() function?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 04:14:05
I'm using Russian locale settings on my PC. If I would set: class numpunct_withpoint: public numpunct<char> { protected: /// Override the function that gives the decimal separator. char do_decimal_point() const { return '.'; } }; ... locale loc(std::locale::classic(), new numpunct_withpoint); std::locale::global(loc); and than printf("%f", 3.14); Output is: 3,14 Decimal separator is "," not like in do_decimal_point function! How can I change C locale settings for decimal separator with C++ locale? Thanks for answer! But, does C setlocale function make affect to C++ cout object? setlocale(LC

Should I free the pointer returned by setlocale?

空扰寡人 提交于 2019-12-01 02:09:00
问题 int main(int argc, char *argv[]) { char *ret = setlocale(LC_ALL, NULL); // should I free 'ret' ??? // free(ret); return 0; } I've tried both on Linux and OS X 10.10, on Linux, I must not call 'free', but on OS X, if I do not call 'free', valgrind complains a memory leak. ==62032== Memcheck, a memory error detector ==62032== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==62032== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info ==62032== Command: ./a.out

Does std::locale::global make affect to printf() function?

对着背影说爱祢 提交于 2019-12-01 01:40:31
问题 I'm using Russian locale settings on my PC. If I would set: class numpunct_withpoint: public numpunct<char> { protected: /// Override the function that gives the decimal separator. char do_decimal_point() const { return '.'; } }; ... locale loc(std::locale::classic(), new numpunct_withpoint); std::locale::global(loc); and than printf("%f", 3.14); Output is: 3,14 Decimal separator is "," not like in do_decimal_point function! How can I change C locale settings for decimal separator with C++

Is it feasible to rely on setlocale, and rely on locales being installed?

一笑奈何 提交于 2019-11-29 10:07:53
I was trying to generate a localized date string with strftime , the placeholder I use is %x . The language/locale is setlocale(LC_ALL, array('jp','japanese')) , however neither locale was available so it generated a string with improper characters. I then installed the ja_JP.utf8 locale and specified that as the first element in the array and the date formatting issue I had was resolved. My question is, should I always rely on locales being installed? I'm aware of how to install them on boxes I have root access to, but what if I don't have access? I believe Zend_Locale and Zend_Translate do

setlocale(LC_ALL, 'en_GB.UTF8') not working on windows

允我心安 提交于 2019-11-29 08:05:30
Why does setlocale(LC_ALL, 'en_GB.UTF8'); return false on Windows Server 2003 R2 - Zend CE PHP 5.3.5 ? Function in question: setlocale . spencercw From the PHP Manual: The return value of setlocale() depends on the system that PHP is running. It returns exactly what the system setlocale function returns. So in your case it returns false because the system returns false. It is likely that the locale you're using is not available on your system. A list of setlocale strings supported by Windows is available here . For British English you want eng , english-uk , or uk . Windows doesn't support