Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6898

StringResourceModel does not respect getLocale for messages

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 9.3.0, 8.12.0
    • None
    • wicket-core
    • None

    Description

      WICKET-5668 states that StringResourceModel has a method getLocale that can be overwritten to provide a custom locale when the messages should be differently localized than the context (Component, Session, default) states.

      The method getString only uses the custom locale when parsing the message with MessageFormat but not to retrieve the message from the Localizer. The locale parameter is null there (Lines 439, 445 / wicket9)

      In my usecase I use the StringResourceModel without a component but want't to provide a custom locale. Instead the Locale.defaultLocale is used to resolve the ressource.

      Solution: use the custom Locale getLocal() as parameter for localizer.getString. (The resolving of the locale is implemented the same way in StringResourceModel.getLocale and Localizer.getStringIgnoreSettings anyway.)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tobiashaupt Tobias Haupt
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: