Announcement Announcement Module
Collapse
No announcement yet.
Support for ChoiceFormat? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Support for ChoiceFormat?

    Hi,

    I am trying to figure out what is the best way to use a ChoiceFormat from Spring.

    It seems that all the i18n support is based on a MessageFormat that can't be "parameterized" (the one returned from the createMessageFormat() method of the AbstractMessageSource class).

    This means that if I need to use a ChoiceFormat, I do have to write a subclass of AbstractMessageSource, but then loose the "flexibility" of the ResourceBundleMessageSource and the reloadable equivalent. Wouldn't it be nicer if the "strategy" of message formats was somehow externalized from the AbstractMessageSource?

    Any idea on how to elegantly solve this issue?

  • #2
    Re: Support for ChoiceFormat?

    After digging intensively in the JDK doco, I found the following way of using a choice format:

    pattern=There {0,choice,0#are no files|1#is one file|1<are {2} files} on {1}

    Quite tricky, but hey it works :-)

    Comment

    Working...
    X