projectfluent / fluent

Fluent — planning, spec and documentation
https://projectfluent.org
Apache License 2.0
1.37k stars 43 forks source link

Documentation improvement suggestion regarding selectors and multiple variables #326

Closed arggh closed 3 years ago

arggh commented 3 years ago

In the guide regarding selectors, there's multiple examples like this:

emails =
    { $unreadEmails ->
        [one] You have one unread email.
       *[other] You have { $unreadEmails } unread emails.
    }

Which made me wonder how the syntax works when there's multiple variables used together with a selector.

My first instinct was something like this:

emails =
    { $unreadEmails ->
        [one] You have one unread email.
       *[other] You have { $unreadEmails } unread emails with { $importantEmails } marked as important.
    }

...which doesn't work.

By trial and error I figured out that this works (ignore that it doesn't really work with case 'one' message-wise):

emails =
    { $unreadEmails ->
        [one] You have one unread email.
       *[other] You have { $unreadEmails } unread emails
    } with { $importantEmails } marked as important.

Maybe it's a good idea to include one example to the guide where this scenario gets covered?

spookylukey commented 3 years ago

@arggh Could you explain what doesn't work about your first attempt? I've tried with fluent.runtime and fluent_compiler and it seems to work fine.

arggh commented 3 years ago

Interesting. I'll need to do some more tests, maybe it's due to the fact that I'm using the fluent-compiler by @eemeli which seems largely abandoned.

Sorry for the noise.

p.s. is a similar project (as @eemeli 's fluent-compiler) being considered officially by the Fluent project members? I do like the minimal runtime-approach.

Pike commented 3 years ago

Stas and I considered it a while ago, and decided to not do it at the time. The lack of a runtime spec with tests was one of the reasons, but also an unclear problem definition. In particular, what'd be the actual required and/or acceptable runtime. Topics there are language fallback, on-demand language switching, Intl support, aggregating resources into contexts, transpilation, polyfills. That's probably an incomplete list, just things off the top of my head.

Context was IE compat, something that eemeli's work also didn't come with out of the box.