Skip to content

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

Merged
garydgregory merged 3 commits into
apache:masterfrom
c-w:LANG-1172-LocaleUtilsDashDelimiter
Mar 6, 2022
Merged

LANG-1172: Support dash as a delimiter in locales#766
garydgregory merged 3 commits into
apache:masterfrom
c-w:LANG-1172-LocaleUtilsDashDelimiter

Conversation

@c-w

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

Copy link
Copy Markdown
Member

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
Copy Markdown

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
Copy Markdown
Member

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

@c-w

c-w commented Oct 8, 2021

Copy link
Copy Markdown
Member Author

@garydgregory Done.

@c-w

c-w commented Oct 15, 2021

Copy link
Copy Markdown
Member Author

@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
Copy Markdown
Member

I will look this weekend.

@c-w

c-w commented Nov 8, 2021

Copy link
Copy Markdown
Member Author

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

Comment thread src/main/java/org/apache/commons/lang3/LocaleUtils.java Outdated
Comment thread src/main/java/org/apache/commons/lang3/LocaleUtils.java Outdated
@garydgregory

Copy link
Copy Markdown
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.

@kinow kinow left a comment

Copy link
Copy Markdown
Member

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

c-w commented Dec 6, 2021

Copy link
Copy Markdown
Member Author

@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?


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

Copy link
Copy Markdown
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
Copy Markdown
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.

@c-w c-w Dec 6, 2021

Copy link
Copy Markdown
Member Author

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

c-w commented Jan 13, 2022

Copy link
Copy Markdown
Member Author

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

c-w commented Mar 6, 2022

Copy link
Copy Markdown
Member Author

Thanks for the merge! 🎉

@garydgregory

Copy link
Copy Markdown
Member

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

@seadbrane

Copy link
Copy Markdown

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
Copy Markdown

Any update?

@garydgregory

Copy link
Copy Markdown
Member

Hi @seadbrane
Feel free to provide a PR.

@seadbrane

seadbrane commented Feb 7, 2024 via email

Copy link
Copy Markdown

@seadbrane

Copy link
Copy Markdown

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