Description
If we invest in error fallbacking, we're likely to follow the decision made by Fluent to ask developers to always use named parameters, rather than positional, because named are more meaningful in a fallback scenario.
In such a case, we'll vastly minimize scenarios where #
, 0
is used, in favor of emailCount
, userName
etc.
The resulting problem is that variables, references, variant names, argument names and argument values become similar to translatable words.
In Fluent, we tried to follow the rule that everything that is meant not to be translated has some sigil around it. For example compare
Welcome = { function ->
one: Welcome to the World, { user }
other: Welcome to the Worlds, { function2(user, units: two) }
}
with:
welcome-message-one = { FUNCTION() ->
[one] Welcome to the World, { $user }
*[other] Welcome to the Worlds, { FUNCTION2($user, minimumFractionUnits: "two") }
}
Several things to notice about this syntax:
- the message ID is dash-delimited. We don't enforce it but we strongly encourage longer, more meaningful ids that pose less risk of collision when combining multiple resources into a single context, and ids that may help user understand the message as last resort, but finally, also likely to help reader of the syntax know that
welcome-message-one
is not a sentence. - variables are denoted by
$
because they show up often, and usually will have fairly short, english sounding names.$
is meant to help user recognize that this is not translatable word - variant keys are in
[]
brackets - function names are all-caps
- function arguments are long camel-case
- function argument values are in
""
We did make some shortcuts - message references don't have a sigil, and argument names may still be confusing, but I think that if we decide to go for syntax, and not just data model, we should strongly considering designing the syntax with readability in mind.