Closed
Bug 1062749
Opened 10 years ago
Closed 10 years ago
[Dialer] Make prettyDuration use l10n attributes instead of setting textContent. Follow up bug 1061120
Categories
(Firefox OS Graveyard :: Gaia::Dialer, defect)
Firefox OS Graveyard
Gaia::Dialer
Tracking
(b2g-v2.2 fixed)
RESOLVED
FIXED
2.1 S4 (12sep)
Tracking | Status | |
---|---|---|
b2g-v2.2 | --- | fixed |
People
(Reporter: davidg, Assigned: davidg)
References
Details
Attachments
(1 file)
Currently prettyDuration (shared/js/dialer/utils.js) is used like this:
someHTMLElement.textContent = Utils.prettyDuration(/* ... */);
So, it doesn't respond to changes in the locales. Change it to something like:
prettyDuration: function(node, duration, l10nIdPrefix) {
var l10nId = l10nIdPrefix + /* do the body of the function */;
node.dataset.l10nId = l10nId;
node.dataset.l10nArgs = JSON.stringify(durationL10n);
}
Assignee | ||
Updated•10 years ago
|
Blocks: dialer-most-wanted
Comment 1•10 years ago
|
||
I talked with Zibi and he says that they're gradually moving away the shared l10n libraries such as l10n_date.js from the |node.textContent = library.function()| pattern and more towards passing a node in as in comment 0. They'll be introducing helpers to do this. They haven't done this yet because there are so many callsites for these functions. Also, when we're calling DateTimeFormat, this isn't an option. We have to use mozL10n.get() in this case.
In our case, prettyDuration only has 2 callsites, both of which are of the form |node.textContent = Utils.prettyDuration()| so this seems like something obvious we can do.
One thing Zibi pointed out is that we can use the setAttributes helper on the mozL10n web API instead of setting each attribute ourselves, like so:
navigator.mozL10n.setAttributes(node, l10nId, JSON.stringify(durationL10n));
Comment 2•10 years ago
|
||
> navigator.mozL10n.setAttributes(node, l10nId, JSON.stringify(durationL10n));
Actually, navigator.mozL10n.setAttributes(node, l10nId, durationL10n); - the helper is there exactly to hide the JSON.parse/stringify (there's also mozL10n.getAttributes for ya all!)
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → david.garciaparedes
Status: NEW → ASSIGNED
Updated•10 years ago
|
Target Milestone: --- → 2.1 S4 (12sep)
Assignee | ||
Comment 3•10 years ago
|
||
Attachment #8486256 -
Flags: review?(drs+bugzilla)
Comment 4•10 years ago
|
||
Comment on attachment 8486256 [details] [review]
patch
There's a few small issues with this so I'd like to see another version. But I think it'll be ready after that. See my comments on the PR.
Attachment #8486256 -
Flags: review?(drs+bugzilla) → review-
Assignee | ||
Comment 5•10 years ago
|
||
Comment on attachment 8486256 [details] [review]
patch
second round :)
Attachment #8486256 -
Flags: review- → review?(drs+bugzilla)
Comment 6•10 years ago
|
||
Comment on attachment 8486256 [details] [review]
patch
One tiny nit and then we're good to go. I still have to talk with Zibi about the mozL10n.once() call, so I'll land this later if he gives the go-ahead.
Attachment #8486256 -
Flags: review?(drs+bugzilla) → review+
Assignee | ||
Comment 7•10 years ago
|
||
Done.
Would you mind landing it Doug? Thanks!
Comment 8•10 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Updated•10 years ago
|
status-b2g-v2.2:
--- → fixed
You need to log in
before you can comment on or make changes to this bug.
Description
•