The I18N dev team is going to be tackling date, time, number, and currency localization issues in the next couple of quarters. We are looking at existing standards for replacing text inside a message and want to cover as many as possible before making a decision. Some possibilities that we are looking at include ICU <http://www.icu-project.org/> and XSLT. If anyone on this list is familiar with any other good options, please reply to this thread.

As an example of what I mean, currently a string substitution in the Viewer might look like this:

std::string bar(const LLSD& sdargs)
{
LLUIString foo = getString("bar"); // bar = "At [TIME] on [DATE], there was [EVENT] on planet [PLANET]";
   foo.setArg("[TIME]", sdargs["time"].asString());
   foo.setArg("[DATE]", sdargs["date"].asString(0));
   foo.setArg("[EVENT]", sdargs["event"].asString());
   return foo.getString();
}

The equivalent in ICU looks like this:

   UErrorCode err = U_ZERO_ERROR;
   Formattable arguments[] = {
      (int32_t)7,
      Formattable(Calendar.getNow(), Formattable::kIsDate),
      "a disturbance in the Force"
   };

   UnicodeString result;
   result = MessageFormat::format(
      "At {1,time} on {1,date}, there was {2} on planet{0,number,integer}.",
      arguments,
      3,
      result,
      err);

I am not particularly fond of indexed substitutions, I prefer name/value pairs, because it gives the translator a little more context, i.e. it is easier for a translator to look at "At [TIME] on [DATE], there was [EVENT] on planet [PLANET]" then "At {1,time} on {1,date}, there was {2} on planet{0,number,integer}."

Our current compromise proposal would look something like this:
std::string bar(const LLSD& sdargs)
{
LLUIString foo = getString("bar"); // bar = "At [DATE,time] on [DATE,date], there was [EVENT] on planet [PLANET,integer]";
   foo.setLLSDArgs(sdargs);
   return foo.getString();
}

Note, the code writing part of this is easy. There are plenty of time/date/number formatting libraries out there we could use for the time/date/number/currency -> localized string conversion. I just don't want to invent a string substitution standard if there is something useful and widely used out there that won't make the translators' job more difficult.

Thanks,
-Steve Linden


_______________________________________________
Policies and (un)subscribe information available here:
http://wiki.secondlife.com/wiki/SLDev
Please read the policies before posting to keep unmoderated posting privileges

Reply via email to