#Build Error Translation Service (Classes)

13 messages · Page 1 of 1 (latest)

oblique goblet
#

Hi guys, I'm new to JAVA and I want to build a service (classes) to translate error message before sending to Client. But unlike js, I can define an error file as JSON. Anyone know how to do it in JAVA or the way to save translation data (EX: EN, MALAY) and use it to find the correct error code to return the translated message? (I don't want to use I18n). Thanks in advance

heavy nexusBOT
#

This post has been reserved for your question.

Hey @oblique goblet! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

misty parcel
#

i mean do know how to read and write to files?

oblique goblet
#

I don't know what to do. For EX:

In JS I can have this JSON:
{
'INVALID_USER': {
'en': 'Invalid user',
'xx': ' xx xxx xx'
}
}

then when throwing new error like: throw new BadRequestionException("INVALID_USER")
In behind the scene, I will map the actual message from the json file and then send it to Client

#

but for JAVA, I don't know how can save data like JSON and get translation easily based on the INVALID_USER and (Accept-langague: xx)

misty parcel
oblique goblet
#

can you help me to give EX for map

#

I still don't know what should I do

spare fossil
oblique goblet
spare fossil