Intl: Implement `supportedLocalesOf` for services
- [x]
Intl.Collator.supportedLocalesOf(#2478) - [ ]
Intl.DateTimeFormat.supportedLocalesOf(builtin not implemented yet) - [ ]
Intl.DisplayNames.supportedLocalesOf(builtin not implemented yet) - [x]
Intl.ListFormat.supportedLocalesOf(#2478) - [x]
Intl.NumberFormat.supportedLocalesOf(#2478) - [x]
Intl.PluralRules.supportedLocalesOf(#2478) - [ ]
Intl.RelativeTimeFormat.supportedLocalesOf(builtin not implemented yet) - [x]
Intl.Segmenter.supportedLocalesOf(#2478)
can i work on this?
@radudiaconu0 Thank you! Let me assign this to you
@jedel1043 i dint study well the source cod. can you guide me to the file where i need to make the changes?
@radudiaconu0 Of course!
https://github.com/boa-dev/boa/tree/main/core/engine/src/builtins/intl is the main directory where all the Intl builtins live. Specifically for Intl.Collator, you'd have to go to its impl:
https://github.com/boa-dev/boa/blob/c57f2310bff126b20aed146d24dae98018494076/core/engine/src/builtins/intl/collator/mod.rs#L379
then add a supported_locales_of method that does precisely what the specification does. The spec is fairly flexible so you can differ a bit from it if required. Please also add a comment per line of specification above the Rust code that implements that line, and a doc comment for the method with the "spec function" and a link to the corresponding specification. You can check the other methods if you have questions about the correct format.
After that, you just need to add your new method to the builtin in:
https://github.com/boa-dev/boa/blob/c57f2310bff126b20aed146d24dae98018494076/core/engine/src/builtins/intl/collator/mod.rs#L152
and that should be it for Intl.Collator. You can follow the same process for the rest of the Intl builtins.
For testing how many test262 tests are fixed by the new changes, you can either open a PR which will run this process automatically and give a comparative table on the results of the test262 CI job, or you can run the suite locally (cargo run --release --bin boa_tester -- run -o <path to directory>), both in the main branch and in you new feature branch, and then compare the results with
cargo run --release --bin boa_tester -- compare \
<path to main results>/latest.json \
<path to feature results>/latest.json -m
Oh right, we already added it for those. I remember that we left this issue open to remember to add this to builtins that aren't properly implemented yet like DateTimeFormat. I'll add a list with all our current implementations and our missing ones to clarify.
@radudiaconu0 I'm very sorry for the confusion! I'll unassign you from this issue and mark it as blocked.
@JavedNissar no problem
what can i do then to help ?
i woudl liek to contribute here
@radudiaconu0 Those are mostly blocked from the icu4x side, so if you want to contribute to the implementation of those, it would be with the icu4x project.
The only things that aren't blocked right now are a prototype of DateTimeFormat without skeletons (only allow dateStyle and timeStyle options), and moving Intl into a separate crate, which requires a bit of decoupling work that could be interesting for you.
If you're interested in the internationalization side, I'd recommend you to check icu4x's good first issues for some contributions you can do.
If you just want to learn about JS engines, you could pick up some issues from our list of good first issues.
However, if you want to learn both, I think the DateTimeFormat is a nice introduction around how to translate 402 spec to Rust code, how to implement builtins and how to use icu4x's components.