locale

Simplest way to detect client locale in PHP

I would like to be able to detect what country a visitor is from on my website, using PHP. Please note that I'm not trying to use this as a security measure or for anything important, just changing the spelling of some words (Americans seems to believe that the word "enrolment" has 2 Ls.... crazy yanks), and perhaps to give a default o...

How do I automatically set a user's locale in PHP?

Is there an easy way to parse the user's HTTP_ACCEPT_LANGUAGE and set the locale in PHP? I know the Zend framework has a method to do this, but I'd rather not install the whole framework just to use that one bit of functionality. The PEAR I18Nv2 package is in beta and hasn't been changed for almost three years, so I'd rather not use th...

python curses.ascii depending on locale?

The curses.ascii module has some nice functions defined, that allow for example to recognize which characters are printable (curses.ascii.isprint(ch)). But, diffrent character codes can be printable depending on which locale setting is being used. For example, there are certain polish characters: >>> ord('a') 97 >>> ord('ą') 177 >>> ...

How do I access Locale from a JSP?

I want to include a js file depending on the value of the current Locale. I have tried to access it from JSP as follows: <%@ page import="java.util.Locale" %> <% if( ((Locale) pageContext.getAttribute("org.apache.struts.action.LOCALE",PageContext.REQUEST_SCOPE)).getLanguage().equals("de")) { %> <script src="../themes/administrati...

Struts 1.3: How to set a default Locale in a web app ?

I have two or three i18n files in my struts application. I am able to switch between these by setting the Global.LOCALE_KEY variable in the session. Is there a way to set a default locale for the application (probably in the struts-config.xml file, I guess) ? Is the session the only place to set the locale ? Sure, I could intercept the...

How do I set LC_ALL and LANG under IIS?

I am trying to run some Perl CGI scripts under IIS. I get the following message : CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_ALL = (unset), LAN...

What is the best way to determine the correct Charset for a given LCID at runtime in VB6?

I am displaying Japanese characters in a VB6 application with the system locale set to Japan and the language for non Unicode programs as Japanese. A call to GetACP() correctly returns 932 for Japanese. When I insert the Japanese strings into my controls they display as “ƒAƒtƒŠƒJ‚̏—‰¤” rather than “アフリカの女王”. If I manually set the Fon...

How can I determine what the alphabet for a locale is in java ?

I would like to determine what the alphabet for a given locale is, preferably based on the browser Accept-Language header values. Anyone know how to do this, using a library if necessary ? ...

Change locale for a single invocation?

I know under Linux it's pretty easy to just change e.g. LC_NUMERIC for a single invocation: LC_NUMERIC=de_DE ./app Is there a similar way for doing that under Windows for a single application? I don't want change the locale for my whole system. For details, it's about Songbird which has locale bug when displaying numbers. Until there...

multi locale validation of input

Hi all, When validating user inputs in an application that is to be run across multiple locales, what is the most appropriate way of doing this? I encountered this in a project I was on a few years ago, and I am interested now in looking back at how else we could have tackled this problem. Ideas I have had are to either write an input ...

How to convert a float to a string regardless of regional settings?

My product is targeted to a Portuguese audience where the comma is the decimal symbol. I usually use CString::Format to input numbers into strings, and it takes into account the computer's regional settings. While in general this is a good approach, I'm having problems in formatting SQL queries, for instance: CString szInsert; szInsert....

C programming: How to program for Unicode?

What prerequisites are needed to do strict Unicode programming? Does this imply that my code should not use char types anywhere and that functions need to be used that can deal with wint_t and wchar_t? And what is the role played by multibyte character sequences in this scenario? ...

Linux & C-Programming: How can I write utf-8 encoded text to a file?

I am interested in writing utf-8 encoded strings to a file. I did this with low level functions open() and write(). In the first place I set the locale to a utf-8 aware character set with setlocale("LC_ALL", "de_DE.utf8"). But the resulting file does not contain utf-8 characters, only iso8859 encoded umlauts. What am I doing wrong? Add...

Browser language: autodetect vs user select?

Hi, I am designing a localized web app. I am leaning on auto-detect browser language setting. But I notice a number of respectable sites asking the user to select a language. Is there any usability issue you know of (from actual experiences out there) with just auto-detecting user language? Thanks. ...

how do I set the proper initial locale for a C++ program on Windows?

I'm fairly new to localized programming, and I'm trying to figure out how to set the proper initial locale for a newly-launched unmanaged C++ application (from within the app). As far as I can tell, new applications start with the C locale, rather than the proper regional locale (English, German, etc). So what I need to do is call setlo...

How to sort text in sqlite3 with specified locale?

Sqlite3 by default sorts only by ascii letters. I tried to look in google, but the only thing I found were informations about collations. Sqlite3 has only NOCASE, RTRIM and BIARY collations. How to add support for a specific locale? (I'm using it in Rails application) ...

Design considerations for internationalization

I've read Joel's article on Unicode and I feel that I have at least a basic grasp of internationalization from a character set perspective. In addition to reading this question, I've also done some of my own research on internationalization in regards to design considerations, but I can't help but suspect that there is a lot more out the...

How to detect current locale in Mac OS X from the shell

I need to detect the current locale in OS X from the command line. On Linux/Unix I can rely on LANG, but it is not always set: http://henrik.nyh.se/2007/10/displaying-utf-8-correctly-in-leopard-terminal I am looking for command line utilities or AppleScript code that allows me to find that information. Ideally they would work from 10.2...

Is there an elegant way to convert ISO 639-2 (3 letter) language codes to Java Locales?

E.g. eng, spa, ita, ger I could iterate all locales and compare the codes, but I wonder whether there is a more elegant & performant way to achieve this.... Thanks a lot for any hints :) ...

Weird error with Locale.getISOCountries()

I'm using this code: for (final String code : Locale.getISOCountries()) { //stuff here } But on compile I get this error: [ERROR] Line 21: No source code is available for type java.util.Locale; did you forget to inherit a required module? And then a stack trace of compiler errors. I'm doing both of these import...