#58 Tests fail with locale de_DE

release_2.4
closed
Oliver Burn
Tests (17)
5
2012-10-10
2002-08-13
Tilman Giese
No

The following tests fail when using de_DE as locale:
LocalizedMessageTest and CheckerTest
I included the test reports. Tilman

Discussion

  • Oliver Burn
    Oliver Burn
    2002-08-14

    Logged In: YES
    user_id=218824

    thanks - I have fixed the problem by forcing the Locale to be
    english. Please confirm that the tests now run.

     
  • Tilman Giese
    Tilman Giese
    2002-08-15

    Logged In: YES
    user_id=330781

    Unfortunately, it does not work. But I do not understand
    why. I used some System.out.println to show what happens is
    LocalizedMessage.java. The locale is en as we set it in
    LocalizedMessageTest.setUp(). But the pattern is in German
    (yes, you read correctly). I can't believe it, but I don't
    know where the problem could be. Tilman

     
  • Oliver Burn
    Oliver Burn
    2002-08-15

    Logged In: YES
    user_id=218824

    re-opened as the bug as not been fixed.

    Is the sentence "The locale is en as we set it in
    LocalizedMessageTest.setUp()." correct??

    This implies that the change of Locale did not take effect??

     
  • Tilman Giese
    Tilman Giese
    2002-08-15

    Logged In: YES
    user_id=330781

    I used the following code in LocalizedMessage.getMessage():

    System.out.println("Current locale: " + sLocale);
    final ResourceBundle bundle =
    ResourceBundle.getBundle(MESSAGE_BUNDLE, sLocale);
    final String pattern = bundle.getString(mKey);
    System.out.println("Message: " + pattern);

    And I get:

    Current locale: en
    Message: Prfung beendet.

    So, the locale is set correctly, but the wrong resource
    bundle is returned.

     
  • Tilman Giese
    Tilman Giese
    2002-08-15

    Logged In: YES
    user_id=330781

    Perhaps you can reproduce this problem by setting the German
    locale:

    export LANG="de_DE"

    ant run.tests

     
  • Lars Kühne
    Lars Kühne
    2002-08-18

    Logged In: YES
    user_id=401384

    Yes, that helps, I'll have a look at it

     
  • Tilman Giese
    Tilman Giese
    2002-08-19

    Logged In: YES
    user_id=330781

    I copied messages.properties to messages_en.properties and
    now the tests succeed. But is this the solution we are
    searching for?

     
  • Lars Kühne
    Lars Kühne
    2002-08-28

    Logged In: YES
    user_id=401384

    Fixed.

    The problem is the search algorithm in
    ResourceBundle.getBundle(). If the default locale is german
    and we request english messages, then getBundle will try to
    load messages_en.properties, that fails, and getBundle tries
    the default locale (messages_de.properties). That succeeds
    and our tests fail.

    I added code to the compile.checkstyle target in build.xml
    file that copies messages.properties to
    messages_en.properties. This fixes the bug and users in
    unsupported locales still see english error messages because
    messages.properties is still available.

    Another option I considered was to call
    Locale.setDefault(Locale.ENGLISH) somewhere, but I suspect
    that this will not behave well when checkstyle is embedded
    in localized IDEs.

    Maybe some Ant expert can copy the file in less than 4 lines
    of XML code :-(

     
  • Oliver Burn
    Oliver Burn
    2002-08-28

    Logged In: YES
    user_id=218824

    nice one.

     
  • Keita Kita
    Keita Kita
    2012-03-14

    This bug returns at release5_5.

    You can reproduce this problem in the following.

    mvn -DargLine="-Duser.language=de -Duser.country=DE" test

     
  • Oliver Burn
    Oliver Burn
    2012-04-16

    Fixed in changeset: 2675:ae13053031c7