Questions tagged [setlocale]

The setlocale() is a function that is used to configure and specify certain locale information.

The setlocale() is a function that is used to configure and specify certain locale category information. Such locale categories can be:

  • LC_ALL
  • LC_COLLATE
  • LC_CTYPE
  • LC_MONETARY
  • LC_NUMERIC
  • LC_TIME
  • LC_MESSAGES

Additionally, the locale must be specified. The locale is actually the universal locale code of the currently language.

The possible locale and category values are specified in RFC 1766 and ISO 639.

249 questions
80
votes
14 answers

PHP setlocale has no effect

The setlocale() function doesn't set the desired language (German). The goal is to output month names. This is my test code with trials so far:
toesslab
  • 5,092
  • 8
  • 43
  • 62
44
votes
3 answers

How do I strftime a date object in a different locale?

I have a date object in python and I need to generate a time stamp in the C locale for a legacy system, using the %a (weekday) and %b (month) codes. However I do not wish to change the application's locale, since other parts need to respect the…
MagerValp
  • 2,922
  • 1
  • 24
  • 27
35
votes
4 answers

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

My device language is in English and my application language is in Italian.So how I get the device language and application language programmatically ?
mob_web_dev
  • 2,342
  • 1
  • 20
  • 42
25
votes
5 answers

Linode Lish bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

Following Linode's guide to Copy a Disk Over SSH: ssh root@xx.xx.xxx.xx "dd if=/dev/sdX " | dd of=/PathToLocalLocation/server.img Where xx.xx.xxx.xx is your server's IP, sdX - X stands for your drive's assigned letter, and also you must state the…
Jadeye
  • 3,551
  • 4
  • 47
  • 63
20
votes
7 answers

How to debug gettext not working in PHP?

i am trying to use the php gettext extension in php 5.5 (on win2008 server, using IIS7). I am doing this:
glutz
  • 1,889
  • 7
  • 29
  • 44
18
votes
5 answers

How to set JSTL locale from Java code?

I want to set the JSTL locale which is used by and friends. I know this is possible with , but I need to do it dynamically (depending on user data retrieved from my DB) and would prefer Java code - a filter class,…
Jens Bannmann
  • 4,845
  • 5
  • 49
  • 76
18
votes
2 answers

PHP/Gettext Problems

I remember running some tests a some months ago with gettext and the following code worked perfectly: putenv('LANG=l33t'); putenv('LANGUAGE=l33t'); putenv('LC_MESSAGES=l33t'); if (defined('LC_MESSAGES')) // available if PHP was compiled with…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
15
votes
1 answer

What does set_locale(LC_CTYPE, 'C'); actually do?

When my PHP script is run with UTF-8 encoding, using non-ASCII characters, some PHP functions like strtolower() don't work. I could use mb_strtolower, but this script can be run on all sorts of different platforms and configurations, and the…
Russ
  • 3,768
  • 7
  • 28
  • 37
13
votes
5 answers

Sort an array with special characters in PHP

I have an array that holds the names of languages in spanish: $lang["ko"] = "coreano"; //korean $lang["ar"] = "árabe"; //arabic $lang["es"] = "español"; //spanish $lang["fr"] = "francés"; //french I need to order the array and maintain index…
Andres SK
  • 10,779
  • 25
  • 90
  • 152
11
votes
3 answers

PHP setlocale not working even with locales existing

ISSUE RESOLVED (see below) I have generated the locales on my server, I have confirmed that they exist (my locale -a provided below), but when I use: setlocale(LC_TIME,'fr_FR'); or setlocale(LC_TIME,'fr_FR.utf8'); it doesn't work at…
kambythet
  • 716
  • 2
  • 9
  • 20
9
votes
1 answer

Dynamically change the locale in Angular 7 at runtime without having to reload the app

I am trying to change Locale_Id in my angular app at the runtime but must use window.location.reload() to fire changes at locale. I want to change locale without reloading my app. here is my code: app.module import { LOCALE_ID } from…
El7or
  • 334
  • 1
  • 5
  • 18
9
votes
2 answers

List of locales in Windows

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…
aib
  • 45,516
  • 10
  • 73
  • 79
9
votes
6 answers

Is setlocale thread-safe function?

I need to change locale in the thread to parse a double with strtod() correctly, I'm using setlocale() for this (C++). Is it thread safe? Update: Another problem. When I invoke setlocale() in my main() function it doesn't affect in other routines…
milo
  • 1,220
  • 3
  • 17
  • 33
9
votes
3 answers

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

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…
meder omuraliev
  • 183,342
  • 71
  • 393
  • 434
9
votes
2 answers

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

I'm using Russian locale settings on my PC. If I would set: class numpunct_withpoint: public numpunct { protected: /// Override the function that gives the decimal separator. char do_decimal_point() const { return '.'; …
Oleksandr Shtykhno
  • 766
  • 2
  • 7
  • 12
1
2 3
16 17