-
-
Notifications
You must be signed in to change notification settings - Fork 919
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
feat: locale aware sorting #2906
feat: locale aware sorting #2906
Conversation
✅ Deploy Preview for fakerjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #2906 +/- ##
==========================================
+ Coverage 99.95% 99.96% +0.01%
==========================================
Files 2987 2987
Lines 216037 216038 +1
Branches 951 604 -347
==========================================
+ Hits 215943 215966 +23
+ Misses 94 72 -22
|
i want to see if the team think this approach is desirable before getting too nitpicky with this PR? |
I dont see any drawbacks. |
Possible drawbacks
|
Thanks for listing all the potential drawbacks.
True, but that is even the case without locale aware sorting as they treat upper and lowercase differently sometimes, words with suffixes are even worse due to the I consider this a low barrier or entry as we require node for building anyway and node should always come with Intl included AFAIK. |
Team Decision
|
CI doesnt seem to pass. Please run |
I did run When I switched my node version to 22 the script emitted changes, which I find very interesting TBH. Diffdiff --git a/src/locales/lv/commerce/department.ts b/src/locales/lv/commerce/department.ts
index 605dd1c1..22af106b 100644
--- a/src/locales/lv/commerce/department.ts
+++ b/src/locales/lv/commerce/department.ts
@@ -4,9 +4,9 @@ export default [
'Auto',
'Bakaleja',
'Bērnu',
+ 'Datoru',
'Dārglietu',
'Dārzkopības',
- 'Datoru',
'Elektronikas',
'Filmu',
'Grāmatu', |
i guess node 22 has a slightly different ICU version to node 20 causing a different sort order in |
i'm flagging this do not merge yet. i think its quite bad if different users on different node versions end up with different generated locale files. Although there's only one example currently, it may well be there are more examples if you run normalization on node 20+22 across all files, not just the current modules with normalization enabled (i only have node 20 installed locally at the moment, my node 22 is borked, so i cant easily test this, perhaps @xDivisionByZerox you could try?) |
Note that Node will update ICU versions even within a major Node version https://github.com/nodejs/node/blob/v20.0.0/tools/icu/current_ver.dep - 72.1 |
|
So do you think, we should generally not sort it in a locale aware manner or do you think about alternative solutions e.g. explicitly importing a specific ICU version that we do not update during major versions? |
I would like to still vote for locale aware sorting |
Is there a way to download the icu stuff as a dependency? |
That wouldn't be sufficient as sort order can change even within different minor versions of the same major node release. |
the more i read about it the more i feel that the ICU data is too unstable to be implicitly used in snapshot tests, and is likely to cause irritating issues for new contributors in future. See for example nodejs/node#51090 for a similar issue where changes in ICU data in a semver-minor version caused breaking tests for many projects. A naive Unicode sort, while nonsensical for some languages, is at least stable. |
I checked the icu code and it is |
I'll let you discuss in next meeting. My vote would be to abandon this. |
After reviewing the discussions in this PR, I would suggest to drop this feature.
I believe this is an excellent summary to the problem we face. |
Should we add a comment to the relevant code section to raise awareness of this? |
Down the rabbit-hole, I traversed the internet of a way how we could implement a stable sorting:
However I ran out of time and maybe proceed later, or someone else can pickup the work |
Draft implementation for #2905
Uses the locale key to customize the sort order.
Requires Intl
The actual changes are in
scripts/generate-locales.ts