Skip to content

8306031: Update IANA Language Subtag Registry to Version 2023-04-13 #13501

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

Closed

Conversation

justin-curtis-lu
Copy link
Member

@justin-curtis-lu justin-curtis-lu commented Apr 17, 2023

Update the registry and accompanying tests with the IANA 4/13/2022 update.

This update introduces the case where an IANA entry can have a preferred value, but that preferred value has a preferred value as well.

This causes unexpected failures in JDK tests because of how locale equivalencies are created.

eg: ar-ajp has a preferred value of ajp but ajp has a preferred value of apc

Normally, when the JDK is built, LocaleEquivlalentMaps.java generates the following

...
singleEquivMap.put("ar-ajp", "ajp");
singleEquivMap.put("ajp", "ar-ajp");
...
multiEquivsMap.put("ajp", new String[] {"apc", "ar-apc"});
multiEquivsMap.put("apc", new String[] {"ajp", "ar-apc"});
multiEquivsMap.put("ar-apc", new String[] {"apc", "ajp"});
...

When LocaleMatcher.parse(ACCEPT_LANGUAGE) is called with ACCEPT_LANGUAGE containing apc and ajp in that order, the following occurs:

apc is found, apc is added, all of apc's equivalencies are added: ajp and ar-apc

When parse iterates to ajp, it finds that it is already added to the list, and does not add it's equivalency ar-ajp.

To address this, the build process must be adjusted so that the equivalencies are built as

...
multiEquivsMap.put("ajp", new String[] {"apc", "ar-ajp", "ar-apc"});
multiEquivsMap.put("apc", new String[] {"ajp", "ar-ajp", "ar-apc"});
multiEquivsMap.put("ar-ajp", new String[] {"apc", "ajp", "ar-apc"});
multiEquivsMap.put("ar-apc", new String[] {"apc", "ajp", "ar-ajp"});
...

As, if ar-ajp has a preferred value of ajp, and ajp has a preferred value of apc, this technically means that ar-ajp is equivalent to apc and its equivalencies as well. This way, when LocaleMatcher.parse(ACCEPT_LANGUAGE) iterates to apc, it will add all of it's equivalencies including ar-ajp.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8306031: Update IANA Language Subtag Registry to Version 2023-04-13

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13501/head:pull/13501
$ git checkout pull/13501

Update a local copy of the PR:
$ git checkout pull/13501
$ git pull https://git.openjdk.org/jdk.git pull/13501/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13501

View PR using the GUI difftool:
$ git pr show -t 13501

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13501.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 17, 2023

👋 Welcome back jlu! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 17, 2023

@justin-curtis-lu The following labels will be automatically applied to this pull request:

  • core-libs
  • i18n

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org labels Apr 17, 2023
@justin-curtis-lu justin-curtis-lu marked this pull request as ready for review April 19, 2023 19:53
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 19, 2023
@mlbridge
Copy link

mlbridge bot commented Apr 19, 2023

Webrevs

Comment on lines 143 to 144
final String finalPref = ","+preferred;
final String inbtwnPref = ","+preferred+",";
Copy link
Member

Choose a reason for hiding this comment

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

This could utilize regex?

Copy link
Member Author

Choose a reason for hiding this comment

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

Much better that way, fixed

final String finalPref = ","+preferred;
final String inbtwnPref = ","+preferred+",";
// Check if current pref exists inside a value for another pref
List<StringBuilder> doublePrefs = initialLanguageMap.entrySet()
Copy link
Member

Choose a reason for hiding this comment

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

values() fits here

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

.stream().filter(e -> (e.getValue().toString().endsWith(finalPref) ||
e.getValue().toString().contains(inbtwnPref)))
.map(Map.Entry::getValue)
.collect(Collectors.toList());
Copy link
Member

Choose a reason for hiding this comment

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

Can replace collect() with toList()

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed this, as well as the other existing occurrence

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Cannot comment on unmodified lines, but instead of calculating the initial load itself, HashMap.newHashMap() can be used for initializing maps.

Copy link
Member Author

@justin-curtis-lu justin-curtis-lu Apr 20, 2023

Choose a reason for hiding this comment

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

Fixed, so they are created with numMappings and not initialLoad

Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

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

Much better. Some comments follow.

@@ -37,9 +37,9 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: sort the imports

// can have a preferred value itself.
// eg: ar-ajp has pref ajp which has pref apc
boolean foundInOther = false;
Pattern pattern = Pattern.compile("\\b"+preferred+"\\b");
Copy link
Member

Choose a reason for hiding this comment

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

I think we should explicitly find a pattern with , instead of the word boundary. Otherwise, it could match - in a tag.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, changed it to match starting with , and ending with , or end of string boundary

Comment on lines +285 to +289
+ sortedLanguageMap1.size() + ");\n"
+ " multiEquivsMap = HashMap.newHashMap("
+ sortedLanguageMap2.size() + ");\n"
+ " regionVariantEquivMap = HashMap.newHashMap("
+ sortedRegionVariantMap.size() + ");\n\n"
Copy link
Member

Choose a reason for hiding this comment

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

It'd be nice if these messy concatenated strings be converted to a text block, but that would be for another day.

Copy link
Member Author

@justin-curtis-lu justin-curtis-lu Apr 20, 2023

Choose a reason for hiding this comment

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

Filed a separate JBS issue for this here

Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

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

LGTM

@openjdk
Copy link

openjdk bot commented Apr 21, 2023

@justin-curtis-lu This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8306031: Update IANA Language Subtag Registry to Version 2023-04-13

Reviewed-by: naoto

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 150 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@naotoj) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 21, 2023
@justin-curtis-lu
Copy link
Member Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Apr 25, 2023
@openjdk
Copy link

openjdk bot commented Apr 25, 2023

@justin-curtis-lu
Your change (at version b03a51c) is now ready to be sponsored by a Committer.

@naotoj
Copy link
Member

naotoj commented Apr 25, 2023

/sponsor

@openjdk
Copy link

openjdk bot commented Apr 25, 2023

Going to push as commit 00b1eac.
Since your change was applied there have been 150 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 25, 2023
@openjdk openjdk bot closed this Apr 25, 2023
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Apr 25, 2023
@openjdk openjdk bot removed rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Apr 25, 2023
@openjdk
Copy link

openjdk bot commented Apr 25, 2023

@naotoj @justin-curtis-lu Pushed as commit 00b1eac.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

2 participants