Skip to content
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

LANG-1172: Support dash as a delimiter in locales #766

Merged
merged 3 commits into from
Mar 6, 2022
Merged

LANG-1172: Support dash as a delimiter in locales #766

merged 3 commits into from
Mar 6, 2022

Conversation

c-w
Copy link
Member

@c-w c-w commented May 29, 2021

This pull request is a partial fix for LANG-1172 adding support for dashes as delimiters for locales as per BCP47 thus enabling parsing of locales such as en-GB in addition to the previously supported (but not to spec) en_GB.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0006%) to 94.977% when pulling fb3497e on c-w:LANG-1172-LocaleUtilsDashDelimiter into bbc690f on apache:master.

@garydgregory
Copy link
Member

@c-w
May you please rebase on master?
TY!

@c-w
Copy link
Member Author

c-w commented Oct 8, 2021

@garydgregory Done.

@c-w
Copy link
Member Author

c-w commented Oct 15, 2021

@garydgregory Just following up on this. Is there anything further I can do to speed up getting this reviewed? Thanks in advance for your time!

@garydgregory
Copy link
Member

I will look this weekend.

@c-w
Copy link
Member Author

c-w commented Nov 8, 2021

@garydgregory Do you have feedback on this pull request? Anything holding this back from getting merged?

@garydgregory
Copy link
Member

@garydgregory Do you have feedback on this pull request? Anything holding this back from getting merged?

I need to take the time to review, hopefully sometime this week.

Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure whether we should modify the current methods to support this locale, or have separate methods. But the code looks really good 👍 Maybe someone else can chime in and share their thoughts on supporting both here. Thanks for the PR @c-w !

@c-w
Copy link
Member Author

c-w commented Dec 6, 2021

@kinow Given that the change is backwards compatible I'd say introducing a new method would be more confusing as the developer would have to know/remember to pick the correct function.

@garydgregory Any thoughts or other comments on the PR?

@@ -248,7 +250,9 @@ private static Locale parseLocale(final String str) {
return new Locale(str);
}

final String[] segments = str.split("_", -1);
final String[] segments = str.indexOf(DASH) != -1
? str.split(String.valueOf(DASH), -1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter that dash is tested before underscore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a while since I wrote this code, but I don't think so. Should be possible to switch them around without issues.

Copy link
Member Author

@c-w c-w Dec 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the unit tests still pass with the comparison swapped. I made the change in 0319d84. It's probably the right thing to optimize for the previous delimiter as that'll be the vast majority of use-cases.

@c-w
Copy link
Member Author

c-w commented Jan 13, 2022

Another friendly ping @garydgregory @kinow @sgoeschl. Could you take another look and let me know if you have any concerns about this change? Thanks in advance!

@garydgregory garydgregory merged commit 35fb9fc into apache:master Mar 6, 2022
@c-w c-w deleted the LANG-1172-LocaleUtilsDashDelimiter branch March 6, 2022 03:15
@c-w
Copy link
Member Author

c-w commented Mar 6, 2022

Thanks for the merge! 🎉

@garydgregory
Copy link
Member

You should build git master locally to make sure you can use the jar in your app.

@seadbrane
Copy link

This change has resulted in some broken expectations in the differences between locale and language tags. While there is probably value in having a method that is open to taking either in order to produce a Locale object, it is not clear that should be this method. In fact, the original and current comments for the method say "This method takes the string format of a locale and creates the locale object from it". In addition, the rationale for why this specific change was made appears to based on some inaccurate understanding - BCP 47 is the spec for language tags, not locales and BCP47 does not support 'underscore', which was this method only supported before this change.

@seadbrane
Copy link

Any update?

@garydgregory
Copy link
Member

Hi @seadbrane
Feel free to provide a PR.

@seadbrane
Copy link

seadbrane commented Feb 7, 2024 via email

@seadbrane
Copy link

pr to mostly revert this change.

#1271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants