Closed Bug 1208369 Opened 9 years ago Closed 9 years ago

Add mock_l20n.js

Categories

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

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: stas, Unassigned)

References

Details

Attachments

(1 file)

As we port more and more apps to l20n.js, a corresponding mock would be helpful.
Blocks: 1203509, 1203108
I changed the way the stringify function works compared to mock_l10n.  I wanted to make it consistent between formatValue and formatValues.  The new behavior stringifies to a simple string if only an identifier was passed, and to a serialized array otherwise.  A few examples should illustrate this nicely (the output is what the returned promise resolves to):

> MockL10n.formatValue('hello')
'hello'

> MockL10n.formatValue('hello', {name: 'Mary'})
'["hello",{"name":"Mary"}]'

> MockL10n.formatValues('hello')
['hello']

> MockL10n.formatValues(['hello', {name: 'Mary'}])
['["hello",{"name":"Mary"}]']

> MockL10n.formatValue(['hello', {name: 'Mary'}], 'welcome')
['["hello",{"name":"Mary"}]', 'welcome']
Comment on attachment 8665843 [details] [review]
[gaia] stasm:1208369-mock_l20n > mozilla-b2g:master

Zibi, what do you think?
Attachment #8665843 - Flags: review?(gandalf)
Comment on attachment 8665843 [details] [review]
[gaia] stasm:1208369-mock_l20n > mozilla-b2g:master

sweet.

You may also want to put l10nAssert in it for parity.
Attachment #8665843 - Flags: review?(gandalf) → review+
Added l10nAssert and landed https://github.com/mozilla-b2g/gaia/commit/3b42b4977273587fa86bc95afda471087eeeb545.  Thanks!
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: