Closed Bug 1029944 Opened 10 years ago Closed 10 years ago

Switch ModalDialog and AppModalDialog from using strings to using l10nIds

Categories

(Firefox OS Graveyard :: Gaia::System, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: zbraniecki, Assigned: yifan, Mentored)

References

Details

(Whiteboard: [good first bug])

Attachments

(1 file)

46 bytes, text/x-github-pull-request
zbraniecki
: review+
Details | Review
Currently both ModalDialog and AppModalDialog API's rely on passing strings that are injected into DOM.

This is overly complicated and limits the localizability of the dialogs.

Currently the code calls mozL10n.get(l10nId) and passes the value to ModalDialog's config yesText, noText and title which uses textContent or innerHTML to inject it.

Instead, the code should pass the l10nId and ModalDialog should just set node.setAttribute('data-l10n-id', l10nId).

This bug is part of an ongoing effort to increase the localizability of Firefox OS UI by moving as much l10n as possible to go through declarative l10nId/l10nArgs (bug 1020138).
Blocks: 1020138
I confirmed that no use cases rely on escapeHTML so it's mostly about this function: https://github.com/mozilla-b2g/gaia/blob/669bb17a487e53b2c62d628d0e1d1e94968da919/apps/system/js/modal_dialog.js#L156-L227

and all its use cases. We need to switch the title and message to be l10nId's or null and yesText and noText to be l10nId's as well.

It's fairly easy and I'll be happy to mentor if anyone wants to give it a try.
Mentor: gandalf
Whiteboard: [good first bug]
Assignee: nobody → yliao
Attached file pull request
Replaced mozL10n.get(l10nId) calls with node.setAttribute('data-l10n-id', l10nId) in ModalDialog and its use cases.
Attachment #8465993 - Flags: review?(gandalf)
Comment on attachment 8465993 [details] [review]
pull request

That looks good! Thanks a lot :)
Attachment #8465993 - Flags: review?(gandalf) → review+
It also reduces the amount of innerHTML's!
Blocks: 1027117
Comment on attachment 8465993 [details] [review]
pull request

Thank you! I later found out the test failed.

Test code of ModalDialog is updated. Changed comparisons of innerHtml and textContent to 'data-l10-id' attribute. Please see if the change conflicts anything.
Attachment #8465993 - Flags: review+ → review?(gandalf)
Comment on attachment 8465993 [details] [review]
pull request

r+!
Attachment #8465993 - Flags: review?(gandalf) → review+
Can we close this bug now?
Yes, forgot that, sorry about it.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Blocks: 1068860
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: