-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TRUNK-6216: LocaleUtility#fromSpecification should be updated to support BCP-47 language tags. #4523
Conversation
0418fd4
to
aadb2da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mherman22 I missed this PR! Looks good. The only thing I'll say is that the reason the ticket was written as "return null if an IllegalArgumentException
is thrown" is because LocaleUtility.toLocale()
should already handle everything we do and more.
Unless was a test failing or something?
@ibacher, yes, using Apache common-Lang’s LocaleUtil#toLocale() and throwing a null for an IllegalArgumentException, we are going to fail this test: openmrs-core/api/src/test/java/org/openmrs/util/LocaleUtilityTest.java Lines 111 to 123 in 4fa07b8
openmrs-core/api/src/main/java/org/openmrs/api/impl/AdministrationServiceImpl.java Lines 365 to 370 in 4fa07b8
|
…t BCP-47 language tags
aadb2da
to
0f9ada2
Compare
thanks @ibacher i think it is now good. I decided to add an if-else check after the IllegalArgumentException has been caught that returns null if it is an invalidBCP-47 format like en-USA or en_USA and return the old implementation if it is something like |
0f9ada2
to
de4fb8e
Compare
…ort BCP-47 language tags. (#4523)
…ort BCP-47 language tags. (openmrs#4523)
…ort BCP-47 language tags. (openmrs#4523)
Description of what I changed
LocaleUtility#fromSpecification parses language tags in the format en_USinto Java locales. This is the format used for Locales in versions of Java up to Java 6. With Java 7, Java began supporting standard BCP-47 language tags (en-US) as well as the underscore variant.
Issue I worked on
see https://openmrs.atlassian.net/browse/TRUNK-6216
Checklist: I completed these to help reviewers :)
My IDE is configured to follow the code style of this project.
No? Unsure? -> configure your IDE, format the code and add the changes with
git add . && git commit --amend
I have added tests to cover my changes. (If you refactored
existing code that was well tested you do not have to add tests)
No? -> write tests and add them to this commit
git add . && git commit --amend
I ran
mvn clean package
right before creating this pull request andadded all formatting changes to my commit.
No? -> execute above command
All new and existing tests passed.
No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.
My pull request is based on the latest changes of the master branch.
No? Unsure? -> execute command
git pull --rebase upstream master