Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-884

Wrong handling of ResourceBundles in ValidationStrings, when running in non-en environment

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.0.2, 4.0.1, 4.0, 4.1
    • 4.0.1, 4.1
    • Framework
    • None
    • All (tested in Windows / Tomcat)

    Description

      Tapestry uses ValidationStrings class to handle translations for error messages.
      This class should return a message from the ValidationStrings.properties, which correspond to the current locale in Tapestry.

      When Tapestry is used in the non-en environment (System properties user.language/user.country set i.e. to DE), the messages are displayed in the default locale instead of the current locale of tapestry. This happens even when accepted-locale are set in Tapestry to en only.

      The buggy function is ValidationStrings.getMessagePattern, which looks like:

      public static String getMessagePattern(String key, Locale locale)

      { return ResourceBundle.getBundle(RESOURCE_BUNDLE, locale).getString(key); }

      It tries to get a localized message from the resource bundle. When you read JavaDoc for getBundle, it says, how the resolving works. And the strategy is:

      bundle_[locale-from-parameter]
      bundle_[default-locale]
      bundle

      So in my case, it was trying:
      ValidationStrings_en
      ValidationStrings_de
      ValidationStrings

      ValidationStrings_en doesn't exists so the german translation was taken.

      To fix this, you should create a translation bundle also for english (ValidationStrings_en).

      Attachments

        Activity

          People

            Unassigned Unassigned
            yossa Jarek Woloszyn
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: