Closed
Bug 1113969
Opened 11 years ago
Closed 11 years ago
The WAP Push app should be overhauled to properly use the l10n API
Categories
(Firefox OS Graveyard :: Gaia::Wappush, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: gsvelto, Assigned: gsvelto)
Details
Attachments
(1 file)
Localization code in the WAP Push is all over the place. We should properly move it to using l10n-ids as well as adjusting non-obvious places where we might need localization such as notifications. See here for more information:
https://developer.mozilla.org/en-US/Firefox_OS/Developing_Gaia/localization_code_best_practices#Writing_APIs_that_operate_on_L10nIDs
Comment 1•11 years ago
|
||
| Assignee | ||
Comment 2•11 years ago
|
||
Comment on attachment 8599280 [details] [review]
[gaia] gabrielesvelto:bug-1113969-wappush-l10n > mozilla-b2g:master
I've prepared a WIP that removes all uses of mozL10n.get() from the WAP Push app but run into a couple of problems:
- The first issue I've encountered is localizing the message title / notification. I'm using this as the l10n-id for the element
message-title-with-sim = ({{sim}}) {{title}}
And
sim = SIM {{id}}
Using this as the id/args couple doesn't seem to work though, the sim field is not expanded, instead I get the literal string {{sim}}
https://github.com/mozilla-b2g/gaia/pull/29795/files#diff-a63302e177cb67eee9c8356fe4f3fcaeR38
- The second issue I'm having is when using non-localized text. One way to do it is to removeAttribute(<node>, 'data-l10n-id') on the relevant element and then clear textContent but what about using a placeholder string instead with the text as an arg? I.e. something like this:
https://github.com/mozilla-b2g/gaia/pull/29795/files#diff-eee5c3abd3dc2488b100e49272a15cbfR13
The 'title' argument will always contain non-translated text (it's a phone number in this case) but using this id saves me from having a different code-path.
Attachment #8599280 -
Flags: feedback?(gandalf)
Comment 3•11 years ago
|
||
Great work!
(In reply to Gabriele Svelto [:gsvelto] from comment #2)
> - The first issue I've encountered is localizing the message title /
> notification. I'm using this as the l10n-id for the element
>
> message-title-with-sim = ({{sim}}) {{title}}
>
> And
>
> sim = SIM {{id}}
>
> Using this as the id/args couple doesn't seem to work though, the sim field
> is not expanded, instead I get the literal string {{sim}}
>
> https://github.com/mozilla-b2g/gaia/pull/29795/files#diff-
> a63302e177cb67eee9c8356fe4f3fcaeR38
As I commented in the PR - just pass "id" and "title" as args and it will work.
> - The second issue I'm having is when using non-localized text. One way to
> do it is to removeAttribute(<node>, 'data-l10n-id') on the relevant element
> and then clear textContent but what about using a placeholder string instead
> with the text as an arg? I.e. something like this:
>
> https://github.com/mozilla-b2g/gaia/pull/29795/files#diff-
> eee5c3abd3dc2488b100e49272a15cbfR13
>
> The 'title' argument will always contain non-translated text (it's a phone
> number in this case) but using this id saves me from having a different
> code-path.
Yup, that's exactly pattern 1 here: https://developer.mozilla.org/en-US/Firefox_OS/Developing_Gaia/localization_code_best_practices#Pattern_1.3A
Pattern 2 is the one with removal of data-l10n-id and resetting textContent.
Both are viable solutions, so feel free to use the one you like more :)
Comment 4•11 years ago
|
||
Comment on attachment 8599280 [details] [review]
[gaia] gabrielesvelto:bug-1113969-wappush-l10n > mozilla-b2g:master
That looks awesome! Everything is clean and good to go! :)
Attachment #8599280 -
Flags: feedback?(gandalf) → feedback+
| Assignee | ||
Comment 5•11 years ago
|
||
Thanks, it's working like a charm now. I'll update the unit-tests and put it up for review.
| Assignee | ||
Comment 6•11 years ago
|
||
Comment on attachment 8599280 [details] [review]
[gaia] gabrielesvelto:bug-1113969-wappush-l10n > mozilla-b2g:master
Here's the complete patch with all the l10n-related changes plus fixes to all the unit-tests. One of the niceties of these changes is that all l10n IDs used for dynamic elements are now part of the unit-tests.
Attachment #8599280 -
Flags: review?(gandalf)
Attachment #8599280 -
Flags: review?(felash)
Updated•11 years ago
|
Attachment #8599280 -
Flags: review?(gandalf) → review+
Updated•11 years ago
|
Assignee: nobody → gsvelto
Comment 7•11 years ago
|
||
Comment on attachment 8599280 [details] [review]
[gaia] gabrielesvelto:bug-1113969-wappush-l10n > mozilla-b2g:master
looks mostly good, but I left too many nits to give r+ yet :)
Attachment #8599280 -
Flags: review?(felash) → review-
| Assignee | ||
Comment 8•11 years ago
|
||
Comment on attachment 8599280 [details] [review]
[gaia] gabrielesvelto:bug-1113969-wappush-l10n > mozilla-b2g:master
I've addressed your review comments and pushed them in a separate patch on top of the previous one for ease of review.
Attachment #8599280 -
Flags: review- → review?(felash)
Comment 9•11 years ago
|
||
Comment on attachment 8599280 [details] [review]
[gaia] gabrielesvelto:bug-1113969-wappush-l10n > mozilla-b2g:master
Some more nits, sorry about this !
(and especially sorry if I wasn't clear enough in my previous review)
Attachment #8599280 -
Flags: review?(felash) → review-
| Assignee | ||
Comment 10•11 years ago
|
||
(In reply to Julien Wajsberg [:julienw] (PTO May 8th -> May 17th) from comment #9)
> Some more nits, sorry about this !
> (and especially sorry if I wasn't clear enough in my previous review)
np, the longer the review process the better the code :)
| Assignee | ||
Updated•11 years ago
|
Status: NEW → ASSIGNED
| Assignee | ||
Comment 11•11 years ago
|
||
Comment on attachment 8599280 [details] [review]
[gaia] gabrielesvelto:bug-1113969-wappush-l10n > mozilla-b2g:master
Here's the fix for the notification helper, pushed on top of the other patches. I've left comments on GitHub about the other bits.
Attachment #8599280 -
Flags: review- → review?(felash)
Comment 12•11 years ago
|
||
Comment on attachment 8599280 [details] [review]
[gaia] gabrielesvelto:bug-1113969-wappush-l10n > mozilla-b2g:master
let's land this :) r=me
Attachment #8599280 -
Flags: review?(felash) → review+
| Assignee | ||
Comment 13•11 years ago
|
||
Thanks, commits squashed and ready to land.
Keywords: checkin-needed
Updated•11 years ago
|
Keywords: checkin-needed
Comment 14•11 years ago
|
||
Pull request has landed in master: https://github.com/mozilla-b2g/gaia/commit/ac3a614d8ef17e964f70142aec5e5aac90bf989a
Updated•11 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Comment 15•11 years ago
|
||
This is great!
I just published the latest stats on mozL10n.get deprecation (bug 1020138 comment 12) and Wappush is off the hook! Thanks a lot for help :gsvelto!
| Assignee | ||
Comment 16•11 years ago
|
||
You're welcome! callscreen, dialer and the emergency-call app are next on my chopping block.
You need to log in
before you can comment on or make changes to this bug.
Description
•