Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Grant Young   on Apr 09 In Java Category.

  
Question Answered By: Al Allen   on Apr 09

You could create a single table of strings with multiple languages,
looked up using id's.

Say we have a table accomodating US English, french, spanish, dutch,
German, and Japanese.

The table would contain:
id int
en_us varchar(255)
fr varchar(255)
es varchar(255)
nl varchar(255)
de varchar(255)
ja varchar(255)

A utility class would lookup the text  using an id, which looks at the
currently selected Locale. It could default a String to the English
version if it hasn't been translated into the wanted language  yet.

"select * from stories where date<=today"
for each row:
int id = row.storyId;

StringLibrary stringLib = StringLibrary.getInstance(); // singleton
String text = stringLib.lookup(id);

display text.

StringLibrary would do the lookups.

Share: