I'm working on a application which supports several languages and has a functionality in place which tries to use the language requested by the browser and also allows manual override of this function. This part works fine and picks the correct templates, labels, etc. User have to enter sometimes text on their own and that's where I run into issues because the application has to accept even "complicated" languages like Chinese and Russian. So far I've taken care of the things mentioned in other posting, i.e.:
It seems that even explicit language selection doesn't make Hence the question is: how should I check for alphabetic characters in all languages? The only idea I had at the moment is to check manually with arrays of "valid" characters - but this seems ugly especially for Chinese. How would you solve this issue?
BenMorel 32.7k48 gold badges170 silver badges302 bronze badges asked Jun 7, 2009 at 9:35
0 If you'd like to check only for valid unicode letters regardless of the used language I'd propose to use a regular expression (if your pcre-regex extension is built with unicode support):
answered Jun 7, 2009 at 11:16
Stefan GehrigStefan Gehrig 81.5k24 gold badges155 silver badges185 bronze badges 1 I wouldn't use an array of characters. That would get impossible to manage. What I'd suggest is working out a 'default' language from the IP address and using that as the locale for a request. You could also get it from the browser-agent string in some cases. You could provide the user a way to override so that if your default isn't correct they aren't stuck with a strange site. (E.g. provide on the form 'language set to english. If this isn't correct, please change: '. This isn't the nicest thing to provide but you won't get any working validation otherwise as you NEED a language/locale set in order to have a sensible alpha validation (An A isn't a letter in chinese). answered Jun 7, 2009 at 9:49
workmad3workmad3 24.7k4 gold badges35 silver badges56 bronze badges 0 You can use the languages from
It contains something like
so you need to parse this string. Then you can use the preferred language in the setLocale function. answered Jun 7, 2009 at 10:40
slosdslosd 3,0142 gold badges20 silver badges17 bronze badges This is rather an encoding issue than a language detection issue. Because UTF-8 can encode any Unicode character. The best approach is to use UTF-8 throughout your project: in your database, in your output and as expected encoding for the input.
answered Jun 7, 2009 at 13:05
GumboGumbo 628k106 gold badges767 silver badges838 bronze badges |