org/un/bungeni/translators/localization/Messages_x.java

0 views
Skip to first unread message

Ashok Hariharan

unread,
Apr 20, 2009, 9:02:45 AM4/20/09
to akomantoso-dev
HI Luca:

The translator loads some resource bundles which are actually java
source files with mesages in hashmaps ...

e.g. --- see [1] ..

I don't understand why a java class is required for these messages ...
is there any reason you have not used standard i18n message bundles
which are essentially text property files ?

With those you can use standard tools to translate the error messges
for multiple languages and there is a default safe fallback behaviour
in case there is no message bundle for the current systme locale /
language ... and also it means we don't mix error messages into source
code as is currently there ...


Ashok

[1] ---

package org.un.bungeni.translators.localization;

import java.util.ListResourceBundle;

/**
* This class is used to set all the messages in English for Kenya
*/
public class Messages_it_IT extends ListResourceBundle {

//The List that contains the messages for kenya
static Object[][] contents =
{
{ "MISSING_ATTRIBUTE_LEFT_TEXT",
"L'informazione addizionale '" },
{ "MISSING_ATTRIBUTE_CENTER_TEXT",
"' è obbligatoria per la sezione '" },
{ "MISSING_ATTRIBUTE_RIGHT_TEXT",
"'" },
};


/**
* Return the list of the messages
* @Override
*/
protected Object[][] getContents()
{
//return the list of the messages
return contents;
}

}

Luca Cervone

unread,
Apr 20, 2009, 9:22:58 AM4/20/09
to akomant...@googlegroups.com
Dear Ashok, 
I choose to do not use the property files instead of the hash map to store message, because of the fact that the translator is already plenty of properties files and XML files to specify the location of the other properties file. 
So I used an hash map into the class to avoid the creation of other files. 
However, When I did it i read overall the web that essentially there are no many difference if you choose to use a method or another. 

Ciao
Luca
Luca Cervone
Web and XML solutions designer

e-mail:     cervo...@gmail.com

mobile phone:    0039 348 26 27 545
home   phone:  0039 051 199 82 854

skype:   cervoneluca



Ashok Hariharan

unread,
Apr 20, 2009, 9:43:10 AM4/20/09
to akomant...@googlegroups.com
On Mon, Apr 20, 2009 at 4:22 PM, Luca Cervone <cervo...@gmail.com> wrote:
> I choose to do not use the property files instead of the hash map to store
> message, because of the fact that the translator is already plenty of
> properties files and XML files to specify the location of the other
> properties file.
> So I used an hash map into the class to avoid the creation of other files.
> However, When I did it i read overall the web that essentially there are no
> many difference if you choose to use a method or another.

Alright ...my point was more about default behaviour ... for instance,
my computer's locale is set to "en_US" ...
the translator has 2 locales (en_KE, and it_IT) ... and no default
locales ... i realized the translator was crashing because there was
no Messages_en_US.java file ... so if you try to run the translator on
a computer where the 2 existing locales dont exist it crashes... May i
suggest a default locale ?

for instance with translation message bundles ... :

I usually have "Messages.properties" as the default language message bundle
Depending on the current locale the system looks for
"Messages_fr_FR.properties" ... "Messages_it_IT.properties" as the
case maybe ... if those message locales are not available it falls
back to use Messages.properties ...

Luca Cervone

unread,
Apr 20, 2009, 10:07:54 AM4/20/09
to akomant...@googlegroups.com
Hi Ashok, 
Yes you are right .. I forgot the default ResourceBoundle. 
Now I have added a new default boundle (in english).

Please let me know if it works fine.

Ciao
Luca
Reply all
Reply to author
Forward
0 new messages