Berto Tuwondila
Berto Tuwondila

Reputation: 91

Translate exception messages in Java

I tried a program that can translate exception messages into another language. Most exceptions or fault messages from Java are displayed in English, but I want to change at least for the exception class that they are translated into the Indonesian language, because I'm from Indonesia. I have been trying to use lexer and parser concepts to do the lexical analysis of some program code to match with a grammar that there is but the result is not perfect. For example in my question before, I made that rule with ANTLR.

Is there another solution to translate a message fault or exception of the English language into another language?

Upvotes: 3

Views: 2232

Answers (1)

belgther
belgther

Reputation: 2534

You can use the getLocalizedMessage() method to get an internationalized message. For a usage example, see http://refactormycode.com/codes/339-internationalize-exceptions

Upvotes: 2

Related Questions