Subject: | Question about Locale |
---|---|
Date: | Tue, 03 Apr 2012 13:28:52 +0200 |
From: | Łukasz Lewczyński <llewc...@soldevelo.com> |
To: | rlar...@grameenfoundation.org |
CC: | jslaw...@soldevelo.com |
Hi, I currently work on motech project and I have problem with tests when I change locale to non-english locale. I fixed the tests by adding information about english locale, but I think that isn't good solution. My question is how motech should gets information about user locale ? Thanks Lukasz
I think the question was not clear enough. The problem is that MOTECH is
not using locales in the consistent way, which looks like a bug. You can
see this after changing your system locale to something different than
English. When you do this, then you will see the similar test failure:
shouldReturnNextApplicableDayForTheGivenDate(org.motechproject.server.messagecampaign.domain.message.RepeatingCampaignMessageTest)
Time elapsed: 0.023 sec <<< FAILURE!
java.lang.AssertionError:
Expected: is "Wednesday"
got: "środa"
at org.junit.Assert.assertThat(Assert.java:778)
at org.junit.Assert.assertThat(Assert.java:736)
at
org.motechproject.server.messagecampaign.domain.message.RepeatingCampaignMessageTest.shouldReturnNextApplicableDayForTheGivenDate(RepeatingCampaignMessageTest.java:58)
After looking at the code you will see, that you must use English week
day names when specifying for example weekDaysApplicable, but the method
applicableWeekDayInNext24Hours() returns week day names in the system
locale.
There is a couple of solutions available:
* MOTECH should have English locale hard-coded in all the places
(currently English is hard-coded in part of the code only)
* MOTECH should work with the system locale (which is currently true
when the system locale is English)
* MOTECH should have the possibility to set locale via configuration
properties
So, which of the solutions is the best one? Or maybe you would like to
fix the problem in a different way?
Regards,
Jakub.
--
You received this message because you are subscribed to the Google Groups "MoTeCH Developer" group.
To post to this group, send email to motec...@googlegroups.com.
To unsubscribe from this group, send email to motech-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/motech-dev?hl=en.
what about returning DayOfWeek enum directly? This should be a more
consistent solution, because we will be operating only with DayOfWeek
enum across the framework and we will not need any converting.
Regards,
Jakub.
On 04/11/2012 09:53 AM, Vivek Singh wrote:
> Since this is internal to the module it can return DateTime.Property
> instead of the text.
>
> Instead of:
> applicableDateTime.dayOfWeek().getAsText()
> Return:
> applicableDateTime.dayOfWeek()
>
> and in
> the org.motechproject.server.messagecampaign.scheduler.RepeatingProgramScheduleHandler#handleEvent
> convert it to org.motechproject.model.DayOfWeek enum, as this is where this
> module would interact with other modules.
>
> On 11 April 2012 03:50, Rob LaRubbio <rlar...@grameenfoundation.org>wrote:
>
>> I do think locale should be set via a configuration.
>>
>> For this specific example, should the API be accepting and returning
>> strings or instead using enums with helper APIs that convert them to
>> strings using the locale?
>>
>> -Rob
>>
>>
>> On 4/9/12 1:16 AM, Vivek Singh wrote:
>>
>> *>> MOTECH should have the possibility to set locale via
>> configuration properties*
>> This is my personal preference. I like this because I can choose to run
>> application in any locale irrespective of machine. This can be useful when
>> running multiple application for two different customers on same machine.
>> But we didn't go with that when we faced a similar question related
>> timezone because we didn't have a use case of that yet.
>>
>> *>> MOTECH should work with the system locale (which is currently true **when
>> the system locale is English)*
>> If not above then this would be my preference, as long as the tests don't
>> use it. In other words the tests should not have hardcoded "Wednesday" in
>> it. I like that fact that we have you guys working on the project,
>> otherwise some of us (in India & US) would never notice them.
>>
>> 2012/4/7 Jakub S�awi�ski <jslaw...@soldevelo.com>
>>
>>>
>>> Hi,
>>>
>>> I think the question was not clear enough. The problem is that MOTECH is
>>> not using locales in the consistent way, which looks like a bug. You can
>>> see this after changing your system locale to something different than
>>> English. When you do this, then you will see the similar test failure:
>>>
>>>
>>> shouldReturnNextApplicableDayForTheGivenDate(org.motechproject.server.messagecampaign.domain.message.RepeatingCampaignMessageTest)
>>> Time elapsed: 0.023 sec <<< FAILURE!
>>> java.lang.AssertionError:
>>> Expected: is "Wednesday"
>>> got: "�roda"
>> 2012/4/7 Jakub Sławiński <jslaw...@soldevelo.com>
>>
>>>
>>> Hi,
>>>
>>> I think the question was not clear enough. The problem is that MOTECH is
>>> not using locales in the consistent way, which looks like a bug. You can
>>> see this after changing your system locale to something different than
>>> English. When you do this, then you will see the similar test failure:
>>>
>>>
>>> shouldReturnNextApplicableDayForTheGivenDate(org.motechproject.server.messagecampaign.domain.message.RepeatingCampaignMessageTest)
>>> Time elapsed: 0.023 sec <<< FAILURE!
>>> java.lang.AssertionError:
>>> Expected: is "Wednesday"
>>> got: "środa"
I decided to use DayOfWeek, but this of course can be changed very
easily. I also fixed some other problems related to locales and now the
core platform can be built without any test failures on the machines
with a different locale than English.
Regarding locale setting via configuration - should we look at this now,
or we can leave it as-is (i.e. MOTECH has English locale hard-coded in
some places) for the near future?
Regards,
Jakub.
-Rob
>>>>> otherwise some of us (in India& US) would never notice them.