views:

94

answers:

1

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 condition that is valid across multiple locales, or to use a large switch statement (I don't like this one), or to write a locale specific regex that can be stored in an external properties file (or similar). The third option is my preferred method but I am interested in hearing others.

An example of this problem would be for example in the use of accented letters in a more widespread context within Continental European languages, or different character sets entirely.

So if validation is needed on input, and the condition will vary depending on locale, which is the best way to handle this problem.

PS: I am not specifically looking for a solution in a particular language, more for approaches to the problem in general.

+2  A: 

If you're writing software for the global market you better use a framework for the internationalization part. There is a huge amount of differences between countries and languages. There are a lot of traps and pitfalls. You certainly don't want to implement all those differences on your own.

This is where it becomes language (programming language) dependent. If you're lucky to use Java you get internationalization support for free. Java has a lot of tools to support you in writing internationalized software. Other higher level languages have also support for internationalization.

If there is no build-in internationalization support for your language you better start looking for a ready-to-go framework.

Eduard Wirch