The i18n Cookbook - recipies for a global society

  • java cookbook
  • about the author
Home

Java Cookbook

  • Java Internationalization Cookbook

messageformat

Spell out the numeric value in a concatenated string

 Problem:

You want to spell out a dynamic numeric value being combined with a static resource.

Solution:

Java MessageFormat provides a number of options for formatting the values passed in.  ICU4J provides even more options.

One of the more interesting formatting options is the spellout format.  Spell out will actually write out a numeric value, such as thirty-five vs. 35.

ICU4J's MessageFormat is used similar to the code Java class.

To format a pattern using a spellout pattern:

  • icu4j
  • messageformat
  • spellout
  • Add new comment
  • Read more

How to combine dynamic and static data

Problem:

You want to combine dynamic values with your static resource files.

Solution:

There are many situations where part of a sentence comes from a dynamic source, or is provided by the user.  Obviously translatng a sentence for every possible scenario is not an option.  Thankfully Java provides a solution for this situation.  It is called MessageFormat.

A message format is a way of replacing variables in a sentence in a locale sensitive manner.

A simple message format:

  • messageformat
  • resourcebundle
  • Add new comment
  • Read more

If you are testing any of these recipes in Eclipse and the characters are not displaying correctly in your console visit http://i18ncookbook.com/eclipse_settings.

This site is ad supported.  I hope you find something among our sponsors worth clicking. ;)

i18n search

Google
Custom Search
Syndicate content

Search

Tags in Tags

calendar date icu4j Java Locale number format numberformat parse spellout timezone transliteration transliterator
more tags

User login

  • Create new account
  • Request new password
  • java cookbook
  • about the author