Throwing Exception (s) in a multilingual (e.g. English and French) application

In my applications, I use Exception to control the flow.

I am using something like this:

throw new Exception("Unable to add new user, user already exist");

This method is perfect in a single language application. However, when I intend to make a multilingual application, I do not know what to do.

The previous line of code should display a message in the default language that the user is using.

What are the possible solutions?

+3
source share
3 answers

, , , . ( , - , - , ) -, , , :

userExists.English = "Unable to add new user, user already exist"
userExists.Spanish = "<my Spanish isn't good enough to even try>"
userExists.ClassicalMongolian = ...

, , -

//currentLanguage indicates what the language of the current session is.
//the function lookupExceptionString must be able to look up the
//correct string based on the value of currentLanguage
exceptionString = lookupExceptionString(currentLanguage);
throw new Exception(exceptionString );

... , , , . "PHP-" "php i18n". :

http://php-flp.sourceforge.net/getting_started_english.htm

+1

, , , . - . , SQL , , . , Microsoft Windows ( # ++-), Mac OSX, Linux , , , , .

- UserAlreadyExists - , . , , . , , .

+5

All Articles