We’ve had a number of conversations in the past two weeks about Message- and Termreferences. They’ve all been in various combinations of individuals involved, or on only somewhat related issues.
To set the stage, there’s been questions on the why of references. I’ll start with that, as that’s already a mouthful.
I’ll give this post a bit of time to settle and get feedback, and then add more about the problems we have with the current design, and what we could do to address those.
Use-cases
Firstly, this is my personal perspective on them, that’s why I want to give this first segment of the conversation a chance to actually be a conversation.
The use of references differs a bit between Messages and Terms.
Avoid repetition
This is often cited, but actually an anti-use-case. As stated in the Fluent docs, it’s OK to Write Everything Twice. Or Thrice. Or to break the acronym, Do Repeat Yourself.
Terminology
Using Terms and Termreferences is a way to encode terminology in a Localization project. The right use of Terminology is also language dependent. A special case of Terminology is …
Branding
Product owners care even more strongly about the use of branding throughout localizations. This is a tricky problem in particular in software localization, as some languages don’t use programs as subjects in phrases, so the use of Terms can’t be enforced in general.
One aspect of branding in libraries is that they can be dynamic. A localization of Firefox talks about Firefox, or Nightly, depending on update channel. Or a string in toolkit might talk about Firefox or Thunderbird.
This isn’t just a gecko problem. Think about a store platform, where the individual stores have different brands.
Consistency
This is similar to Terminology, and the boundaries are in flux. Basically, the difference is between 2-3 vs 15 uses. Also, literal quotations are a good example, where TM/MT can’t help to ensure consistency. Also, different technical implementations of the same thing in two places (.value
vs .description
, for example).
Here, you’ll end up using message references instead of introducing terms and references.
Back-up strings
Say, you have a good string, and a better string. You’d love to pick up the better string, but be OK with the good string.
One way to do this would be to add a fall-back string, that just redirects to the good string:
better-string = {good_string}
Sneak peek, I’ve dropped this from my recommendations as I don’t see that working in the current implementations. At least not better than just asking for localizations of better-string
right away.
Factorization
If you have a often-used segment that contains logic, you would like to create a single place for that logic, and reference it where needed. This is a term reference again. For example, update-channel-dependent branding would be an example.
There’s also a language-dependent variant of this, for example to implement platform variations in Japanese. This is a good deal tougher on the l10n ecosystem, though. This requires support for localized entities that only exist in a single localization, which is rare in l10n processes, and thus not widely implemented.
Factorization squared
aka dynamic references. Message and Term references are dynamic when you build Localization
objects (and by that, bundles). Dynamic references take that a step further by introducing an option for the call into the Localization.formatValue
to take varying references to resolve to.