Implement Intl.RelativeTimeFormat.prototype.formatToParts
Categories
(Core :: JavaScript: Internationalization API, enhancement)
Tracking
()
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
Updated•5 years ago
|
Comment 1•5 years ago
|
||
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
Assignee | ||
Comment 2•5 years ago
|
||
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.
Assignee | ||
Comment 3•4 years ago
|
||
- 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.
Assignee | ||
Comment 4•4 years ago
|
||
Add js::intl::NumberFormatFields containing the two methods:
append
: To append a number format fieldtoArray
: To construct the result Array object
The unitType
argument for NumberFormatFields::toArray will be used in part 3.
Depends on D26717
Assignee | ||
Comment 5•4 years ago
|
||
- 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 | ||
Updated•4 years ago
|
Comment 7•4 years ago
|
||
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.
Assignee | ||
Comment 8•4 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=d713ed65cd595c382a08381b9af068bd7e139a5d
Comment 9•4 years ago
|
||
Could not land due to uncommitted changes, please rebase.
Assignee | ||
Comment 10•4 years ago
|
||
All commits are now rebased to apply cleanly on inbound.
Comment 11•4 years ago
|
||
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
Comment 12•4 years ago
|
||
Backed out 3 changesets for causing bustages in ICUStubs.h
Backout link: https://hg.mozilla.org/integration/autoland/rev/505173c26e1af4afcb7ee13a567a5ae4d8149dc7
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
...
Assignee | ||
Comment 13•4 years ago
|
||
Updated to add the missing UConstrainedFieldPosition
declaration.
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=e3281317677a0370478c5b23fd75aa7f1f6523cd
Comment 14•4 years ago
|
||
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
Comment 15•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/bf94fe26b0e3
https://hg.mozilla.org/mozilla-central/rev/e65dd4b9b049
https://hg.mozilla.org/mozilla-central/rev/66cbc40a0aac
Comment 16•4 years ago
|
||
Doc updates:
- Fx 70 release notes: https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/70
- Reference page: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat/formatToParts (originally authored by Romulo Cintra)
- Compat data: https://github.com/mdn/browser-compat-data/pull/4717
- Interactive exmaple: https://github.com/mdn/interactive-examples/pull/1300
I think this has been reviewed sufficiently. Let me know if you have additional feedback.
Updated•4 years ago
|
Description
•