Tapestry
  1. Tapestry
  2. TAPESTRY-884

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

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0.2, 4.0.1, 4.0, 4.1
    • Fix Version/s: 4.0.1, 4.1
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      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).

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Jarek Woloszyn
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development