Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.1
    • Component/s: None
    • Labels:
      None
    • Flags:
      Patch

      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.

      1. i18n-en.patch
        2 kB
        Benjamin Bentmann
      2. MPIR-79.zip
        11 kB
        Benjamin Bentmann
      3. MPIR-79.zip
        12 kB
        dennislundberg

        Activity

        Hide
        Benjamin Bentmann added a comment -

        If you want to exploit this bug, just run

        mvn site -Dlocales=de,en
        

        Note that "de" is placed first to denote the default locale.

        Show
        Benjamin Bentmann added a comment - If you want to exploit this bug, just run mvn site -Dlocales=de,en Note that "de" is placed first to denote the default locale.
        Hide
        Dennis Lundberg added a comment -

        It's not clear to me what you are expecting when you run the command above.

        Setting the default locale to "de" should render the reports in German, right? Or am I missing something?

        I've seen your patches for this in several plugin, and I'm willing to apply them. I just want to understand the problem they are solving

        Show
        Dennis Lundberg added a comment - It's not clear to me what you are expecting when you run the command above. Setting the default locale to "de" should render the reports in German, right? Or am I missing something? I've seen your patches for this in several plugin, and I'm willing to apply them. I just want to understand the problem they are solving
        Hide
        Benjamin Bentmann added a comment -

        The illustrated command should produce the site output in two different locales, namely German and English (see also Site Guide, Internationalization). Now, when a report plugin does not contain a dedicated bundle for English, the second site output will be using German again instead of English. German being the default locale does not mean that I want all sites in German

        I really suggest you go and call Maven as illustrated. Then just browse the two generated sites. German (as being default) should hang around just unter target/site, while the English site lies under target/site/en. Once you see the "English" site yourself, it will all get clear... or not, depending on your knowledge about German

        Show
        Benjamin Bentmann added a comment - The illustrated command should produce the site output in two different locales, namely German and English (see also Site Guide, Internationalization ). Now, when a report plugin does not contain a dedicated bundle for English, the second site output will be using German again instead of English. German being the default locale does not mean that I want all sites in German I really suggest you go and call Maven as illustrated. Then just browse the two generated sites. German (as being default) should hang around just unter target/site, while the English site lies under target/site/en. Once you see the "English" site yourself, it will all get clear... or not, depending on your knowledge about German
        Hide
        Siveton Vincent added a comment -

        Dennis,
        I think also that Benjamin is right. See the related issue.

        Show
        Siveton Vincent added a comment - Dennis, I think also that Benjamin is right. See the related issue.
        Hide
        Lukas Theussl added a comment -

        I also agree. I was about to apply some of Benjamin's patches but got halted by the encoding question, see MPMD-71 and MSITE-287, can someone clarify this?

        Show
        Lukas Theussl added a comment - I also agree. I was about to apply some of Benjamin's patches but got halted by the encoding question, see MPMD-71 and MSITE-287 , can someone clarify this?
        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:

              Development