Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Locale question

Reply
Thread Tools

Locale question

 
 
hilz
Guest
Posts: n/a
 
      12-17-2004
Hi all

I have couple of files:
file_en.txt
file_fr.txt
file_es.txt
file_de.txt

they contain the same simple text in their corresponding languages.
and i want to be able to load these files according to the locale.

I know that:
ResourceBundle.getBundle("file", Locale Locale)
should be used if those files were ".properties" files and contained
key=value pairs. But my files contain just simple text. Is there an
equivalent way of getting the text from those files in a single call similar
to ResourceBundle.getBundle(String baseName, Locale locale)

thanks
hilz


 
Reply With Quote
 
 
 
 
timtheis@yahoo.com
Guest
Posts: n/a
 
      12-17-2004
So you have no keys in the text files to identify each message?

 
Reply With Quote
 
 
 
 
hilz
Guest
Posts: n/a
 
      12-18-2004

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> So you have no keys in the text files to identify each message?
>


No, I don't have a key.
Each of those files contain a long paragraph, and there is no key since it
is just a paragraph of text.

anyway, i just figured out that i can get the two letters of the language by
calling Locale.getLanguage()
so i append it to the file name before reading it, and it worked.
thank you for trying though.

thanks
hilz


 
Reply With Quote
 
Stephen Riehm
Guest
Posts: n/a
 
      12-18-2004
hilz wrote:
> Hi all
>
> I have couple of files:
> file_en.txt
> file_fr.txt
> file_es.txt
> file_de.txt
>
> they contain the same simple text in their corresponding languages.
> and i want to be able to load these files according to the locale.
>
> I know that:
> ResourceBundle.getBundle("file", Locale Locale)
> should be used if those files were ".properties" files and contained
> key=value pairs. But my files contain just simple text. Is there an
> equivalent way of getting the text from those files in a single call similar
> to ResourceBundle.getBundle(String baseName, Locale locale)


..properties files are also just text files, with minimal formatting.
If you know what's right, why don't you make your locale files 'right'
and then use the normsl, right way. The person who has to maintain your
code will thank you

I normally have a locale/ directory in my jar file, and then put the
translations in files like messages_en.properties,
messages_de.properties, etc. Just like they tell you in the books It
works great.

PS: a simple one-line perl or sed command can be used to convert many
simple text formats into other formats... ie: if your texts are tab
seperated, you could use the following to turn them into key = values pairs.

perl -pe 's/\t/=/' file_en.txt > messages_en.properties

cheers,

Steve
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
the relation between C++ locale and C locale zade C++ 1 03-05-2010 06:04 PM
Re: List of locale values for locale.setlocale() under Windows Gabriel Genellina Python 0 02-18-2009 12:00 AM
Create C++ std::locale without changing C locale dertopper@web.de C++ 4 08-26-2008 01:15 PM
i18n problem, involving Locale.getDisplayLanguage and Locale.getDisplayCountry Maurice Hulsman Java 1 07-25-2004 06:11 PM
locale.nl_langinfo(RADIXCHAR) vs locale.localeconv()['decimal_point'] Jeff Epler Python 2 08-31-2003 02:18 PM



Advertisments