projectfluent / fluent

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

reusing terms to create more complex terms #337

Open caridy opened 2 years ago

caridy commented 2 years ago

When terms inside other terms, there is a limitation around passing variables down to other terms, but I'm not sure about the nature of such limitation. Here is an example:

-bar = { $n -> 
    [0] some
    *[1] another
}
-foo = before { -bar(n: $x) } after

-foo is just an abstraction around -bar, delegating to it a piece of the message, but passing $x down to -bar is forbidden, with parsing error E0014: Expected literal.

cc @gonzalocordero

zbraniecki commented 2 years ago

@stasm - can you recall the rationale?

stasm commented 2 years ago

I have a vague memory of wanting to forbid exactly this kind of use-cases. IIRC, my argument was that this increases the complexity, makes the translations harder to reason about, and is generally something that programmers like to do, because we like factoring things out in the name of DRY. Whereas Fluent was based around WET: write everything twice, because we assumed WET would easier for translators, translation memories, and machine translation systems.

When you're saying -foo is just an abstraction around -bar, it sounds like a red flag to me. Can you provide a more concrete example of what you're trying to achieve?