Closed Bug 940772 Opened 11 years ago Closed 10 years ago

Dehardcode plural on Gaia branch

Categories

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

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: zbraniecki, Assigned: stas)

References

Details

Attachments

(1 file, 1 obsolete file)

We currently do several things that hardcode plural macro on Gaia branch. I'd like to add formFactor support so I need to fix that. There are two elements: 1) parser hardcodes plural 2) compiler hardcode single arg macro calls Both should be relatively easy to fix.
Attached patch POC (obsolete) — Splinter Review
This is a POC of the compiler work. Stas: Can you take a look at this POC and review it for me? Thanks!
Attachment #8334972 - Flags: feedback?(stas)
Blocks: 936532
Comment on attachment 8334972 [details] [diff] [review] POC Review of attachment 8334972 [details] [diff] [review]: ----------------------------------------------------------------- It looks good, although I didn't have time to test in myself yet. AIUI, the main goal here is to allow for call expressions to not have any arguments, and the approach seems fine. ::: lib/l20n/compiler.js @@ +402,5 @@ > var callee = Expression(node.callee, entry); > // support only one argument per callExpr for now > + var arg = null; > + if (node.arguments.length) { > + arg = Expression(node.arguments[0], entry); I think you shouldn't need to do this here, because the Expression constructor will return null if node.arguments[0] is falsy. @@ +419,2 @@ > > + // special cases for zero, one, two if they are defined on the hash Should we leave those special cases here untouched, or should we make them plural-specific? I'm fine with leaving them as they are.
Attachment #8334972 - Flags: feedback?(stas) → feedback+
Component: General → Gaia Bindings
Component: Gaia Bindings → Gaia::L10n
Product: L20n → Firefox OS
Assignee: gandalf → stas
Priority: -- → P3
Priority: P3 → P2
Status: NEW → ASSIGNED
The old POC was based on the old branch of l10n.js. This patch makes it possible to use any kind of expression in the index: - a macro call with an argument: {[ plural(n) ]} - a macro call without arguments: {[ macro() ]} - a string or variable identifier: {[ brandName ]} I probably need more tests, but the logic in the patch is good to review at this point.
Attachment #8334972 - Attachment is obsolete: true
Attachment #8446114 - Flags: review?(gandalf)
Priority: P2 → P4
Comment on attachment 8446114 [details] [diff] [review] Make indexes accept various expressions Review of attachment 8446114 [details] [diff] [review]: ----------------------------------------------------------------- Sorry it took me so long Stas! The patch looks good, although I'm not sure how much this will change when we add l20n parser.
Attachment #8446114 - Flags: review?(gandalf) → review+
These changes will make it easier to add a subset of the l20n syntax, so this should be a change into the right direction. I submitted a pull request, waiting for TBPL before merging: https://github.com/mozilla-b2g/gaia/pull/23806 https://tbpl.mozilla.org/?rev=70462fa574e5&tree=Gaia-Try
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: