Closed Bug 1473229 Opened 2 years ago Closed 1 year ago

Implement Intl.RelativeTimeFormat.prototype.formatToParts

Categories

(Core :: JavaScript: Internationalization API, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox63 --- wontfix
firefox70 --- fixed

People

(Reporter: anba, Assigned: anba)

References

()

Details

(Keywords: dev-doc-complete)

Attachments

(3 files)

Implement Intl.RelativeTimeFormat.prototype.formatToParts as specified in <http://tc39.github.io/proposal-intl-relative-time/#sec-Intl.RelativeTimeFormat.prototype.formatToParts>.

ICU feature request needed for implementing formatToParts: https://ssl.icu-project.org/trac/ticket/13256
Andre - do you think this should block us from exposing the current `Intl.RelativeTimeFormat` to the web? Seems like V8 exposed it recently - https://developers.google.com/web/updates/2018/10/intl-relativetimeformat
Being unable to provide `formatToParts` is probably not a hard blocker - but before exposing RelativeTimeFormat we still need to fix some open issues, for example bug 1473588, which is blocked by bug 1499026. And while bug 1499026 has some patches to workaround ICU 63 build issues, it seems preferable to fix the build issues upstream (https://unicode-org.atlassian.net/browse/ICU-20209) instead of relying on local patches.
  • Part 3 uses functions added in ICU 64, so we need to bump the version requirement.
  • Also remove a version check which is now true be default.

Add js::intl::NumberFormatFields containing the two methods:

  • append: To append a number format field
  • toArray: To construct the result Array object

The unitType argument for NumberFormatFields::toArray will be used in part 3.

Depends on D26717

  • The new formatted-value API is still draft-only, so extra U_HIDE_DRAFT_API guards
    are currently needed.
  • Also moves steps 4-5 of PartitionRelativeTimePattern to native code to reduce code
    duplication.

Depends on D26718

Assignee: nobody → andrebargull
Status: NEW → ASSIGNED

Can we land this?

Flags: needinfo?(andrebargull)

There are some r+ patches which didn't land and no activity in this bug for 2 weeks.
:anba, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(andrebargull)

Could not land due to uncommitted changes, please rebase.

Flags: needinfo?(andrebargull)
Keywords: checkin-needed

All commits are now rebased to apply cleanly on inbound.

Flags: needinfo?(andrebargull)
Keywords: checkin-needed

Pushed by ncsoregi@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5109ce5a4b44
Part 1: Bump minimum required ICU version to 64.1. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/f3a2031bde94
Part 2: Make it possible to reuse the number-formatter parts generator code. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/953a2bd4220b
Part 3: Add support for "formatToParts" to Intl.RelativeTimeFormat. r=jwalden

Keywords: checkin-needed

Backed out 3 changesets for causing bustages in ICUStubs.h

Backout link: https://hg.mozilla.org/integration/autoland/rev/505173c26e1af4afcb7ee13a567a5ae4d8149dc7

Push with failures: https://treeherder.mozilla.org/#/jobs?repo=autoland&resultStatus=testfailed%2Cbusted%2Cexception&tochange=505173c26e1af4afcb7ee13a567a5ae4d8149dc7&fromchange=953a2bd4220bec9ea10512536aa06cf55288a972&selectedJob=255439570

Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=255439570&repo=autoland&lineNumber=2816

[task 2019-07-09T08:56:37.845Z] Running CARGO_PKG_DESCRIPTION='Rust bindings for libclang.' CARGO_PKG_VERSION_PRE= CARGO_PKG_VERSION_MINOR=28 CARGO_PKG_REPOSITORY='https://github.com/KyleMayes/clang-sys' LD_LIBRARY_PATH='/builds/worker/workspace/obj-haz-shell/release/deps:/builds/worker/workspace/rustc/lib:/builds/worker/workspace/gcc/lib64' CARGO_MANIFEST_DIR=/builds/worker/checkouts/gecko/third_party/rust/clang-sys CARGO_PKG_NAME=clang-sys CARGO=/builds/worker/workspace/rustc/bin/cargo CARGO_PKG_HOMEPAGE= CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION=0.28.0 CARGO_PKG_AUTHORS='Kyle Mayes <kyle@mayeses.com>' CARGO_PKG_VERSION_MAJOR=0 /builds/worker/workspace/rustc/bin/rustc --crate-name build_script_build /builds/worker/checkouts/gecko/third_party/rust/clang-sys/build.rs --color never --crate-type bin --emit=dep-info,link -C opt-level=2 -C codegen-units=1 --cfg 'feature="clang_6_0"' --cfg 'feature="gte_clang_3_6"' --cfg 'feature="gte_clang_3_7"' --cfg 'feature="gte_clang_3_8"' --cfg 'feature="gte_clang_3_9"' --cfg 'feature="gte_clang_4_0"' --cfg 'feature="gte_clang_5_0"' --cfg 'feature="gte_clang_6_0"' --cfg 'feature="libloading"' --cfg 'feature="runtime"' -C metadata=9d393b86f2778e0b -C extra-filename=-9d393b86f2778e0b --out-dir /builds/worker/workspace/obj-haz-shell/release/build/clang-sys-9d393b86f2778e0b -C linker=/builds/worker/checkouts/gecko/build/cargo-linker -L dependency=/builds/worker/workspace/obj-haz-shell/release/deps --extern glob=/builds/worker/workspace/obj-haz-shell/release/deps/libglob-ad84f23146e28cf1.rlib --cap-lints warn
[task 2019-07-09T08:56:38.090Z] In file included from /builds/worker/checkouts/gecko/js/src/builtin/intl/CommonFunctions.h:17:0,
[task 2019-07-09T08:56:38.090Z] from /builds/worker/checkouts/gecko/js/src/builtin/intl/DateTimeFormat.h:12,
[task 2019-07-09T08:56:38.090Z] from /builds/worker/checkouts/gecko/js/src/vm/SelfHosting.cpp:25,
[task 2019-07-09T08:56:38.090Z] from /builds/worker/workspace/obj-haz-shell/js/src/Unified_cpp_js_src19.cpp:47:
[task 2019-07-09T08:56:38.090Z] /builds/worker/checkouts/gecko/js/src/builtin/intl/ICUStubs.h:712:8: error: 'UConstrainedFieldPosition' does not name a type
[task 2019-07-09T08:56:38.090Z] inline UConstrainedFieldPosition* ucfpos_open(UErrorCode* status) {
[task 2019-07-09T08:56:38.090Z] ^~~~~~~~~~~~~~~~~~~~~~~~~
[task 2019-07-09T08:56:38.090Z] /builds/worker/checkouts/gecko/js/src/builtin/intl/ICUStubs.h:716:26: error: variable or field 'ucfpos_close' declared void
[task 2019-07-09T08:56:38.090Z] inline void ucfpos_close(UConstrainedFieldPosition* ucfpos) {
[task 2019-07-09T08:56:38.091Z] ^~~~~~~~~~~~~~~~~~~~~~~~~
[task 2019-07-09T08:56:38.091Z] /builds/worker/checkouts/gecko/js/src/builtin/intl/ICUStubs.h:716:26: error: 'UConstrainedFieldPosition' was not declared in this scope
[task 2019-07-09T08:56:38.091Z] /builds/worker/checkouts/gecko/js/src/builtin/intl/ICUStubs.h:716:53: error: 'ucfpos' was not declared in this scope
[task 2019-07-09T08:56:38.091Z] inline void ucfpos_close(UConstrainedFieldPosition* ucfpos) {
[task 2019-07-09T08:56:38.091Z] ^~~~~~
[task 2019-07-09T08:56:38.091Z] In file included from /builds/worker/checkouts/gecko/js/src/builtin/intl/NumberFormat.h:12:0,
[task 2019-07-09T08:56:38.091Z] from /builds/worker/checkouts/gecko/js/src/vm/SelfHosting.cpp:27,
[task 2019-07-09T08:56:38.092Z] from /builds/worker/workspace/obj-haz-shell/js/src/Unified_cpp_js_src19.cpp:47:
[task 2019-07-09T08:56:38.092Z] /builds/worker/workspace/obj-haz-shell/dist/system_wrappers/stdint.h:2:37: error: expected declaration before end of line
...

Flags: needinfo?(andrebargull)

Updated to add the missing UConstrainedFieldPosition declaration.

Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=e3281317677a0370478c5b23fd75aa7f1f6523cd

Flags: needinfo?(andrebargull)
Keywords: checkin-needed

Pushed by archaeopteryx@coole-files.de:
https://hg.mozilla.org/integration/autoland/rev/bf94fe26b0e3
Part 1: Bump minimum required ICU version to 64.1. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/e65dd4b9b049
Part 2: Make it possible to reuse the number-formatter parts generator code. r=jwalden
https://hg.mozilla.org/integration/autoland/rev/66cbc40a0aac
Part 3: Add support for "formatToParts" to Intl.RelativeTimeFormat. r=jwalden

Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70

Doc updates:

I think this has been reviewed sufficiently. Let me know if you have additional feedback.

You need to log in before you can comment on or make changes to this bug.