Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.1
    • Component/s: None
    • Labels:
      None
    • Patch Submitted:
      Yes
    • Number of attachments :
      3

      Description

      The lookup strategy performed by ResourceBundle.getBundle() to find a bundle for a requested locale will prefer the bundle for the JVM's default locale over the base bundle of a family. For this reason, one MUST always provide an empty bundle for the language that is provided by the base bundle. See Sun Bug 6606475 for a prominent example of this bug.

        Issue Links

          Activity

          Hide
          Dennis Lundberg added a comment -

          Here's a very small project that borrows the resource files from MPIR.

          It sets the default locale to the first command line parameter. Then it retrieves a resouce bundle for the English locale. Finally it gets a string from the resouce bundle and prints it.

          Run it using these commands:

          mvn package
          java -jar target\MPIR-79-1.0-SNAPSHOT.jar <defaultLocale>
          

          I have not been able to get it to output anything else that the English text "About", no matter what I throw at it as the default locale. There must be something that I simply do not understand.

          Show
          Dennis Lundberg added a comment - Here's a very small project that borrows the resource files from MPIR. It sets the default locale to the first command line parameter. Then it retrieves a resouce bundle for the English locale. Finally it gets a string from the resouce bundle and prints it. Run it using these commands: mvn package java -jar target\MPIR-79-1.0-SNAPSHOT.jar <defaultLocale> I have not been able to get it to output anything else that the English text "About", no matter what I throw at it as the default locale. There must be something that I simply do not understand.
          Hide
          Benjamin Bentmann added a comment -

          It sets the default locale to the first command line parameter.

          No, it doesn't You simply assign a variable called "defaultLocale" but the default locale is maintained by the java.util.Locale class. One needs to call setDefault() in order to effectively change it.

          I attached a slightly modified version of your test project. The modified code also prints out the effective locale of the bundle that has been retrieved (bundleLocale). Here's my log output:

          M:\MPIR-79>java -jar target\MPIR-79-1.0-SNAPSHOT.jar de
          defaultLocale=de
          locale=en
          bundleLocale=de
          Willkommen bei
          

          Can I convice you this way?

          Show
          Benjamin Bentmann added a comment - It sets the default locale to the first command line parameter. No, it doesn't You simply assign a variable called "defaultLocale" but the default locale is maintained by the java.util.Locale class. One needs to call setDefault() in order to effectively change it. I attached a slightly modified version of your test project. The modified code also prints out the effective locale of the bundle that has been retrieved (bundleLocale). Here's my log output: M:\MPIR-79>java -jar target\MPIR-79-1.0-SNAPSHOT.jar de defaultLocale=de locale=en bundleLocale=de Willkommen bei Can I convice you this way?
          Hide
          Dennis Lundberg added a comment -

          DOH!

          Thanks for being patient with me. I'll start applying patches now...

          Show
          Dennis Lundberg added a comment - DOH! Thanks for being patient with me. I'll start applying patches now...
          Hide
          Benjamin Bentmann added a comment -

          Never mind, I always appreciate a good discussion as it might provide insights for other readers as well.

          Show
          Benjamin Bentmann added a comment - Never mind, I always appreciate a good discussion as it might provide insights for other readers as well.
          Hide
          Dennis Lundberg added a comment -

          Patch applied in r612253 and a new SNAPSHOT has been deployed.
          Thank you!

          Show
          Dennis Lundberg added a comment - Patch applied in r612253 and a new SNAPSHOT has been deployed. Thank you!

            People

            • Assignee:
              Dennis Lundberg
              Reporter:
              Benjamin Bentmann
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: