I am trying to localize samedec, a rust crate which parses weather warning messages. While I am using the fluent-rs rust crate, my question is more general. I’d like tips on writing FSL for large switchyards of messages.
My phrases are weather alerts which (in en-US) are deceptively simple:
same-msg = {$org} issued {$evt}
but $org
and $evt
are themselves translated strings from an enumeration, not user input. Some examples:
- The National Weather Service has issued a Required Weekly Test
- The National Weather Service has issued a Flash Flood Watch
- The National Weather Service has issued a Flash Flood Warning
- Civil authorities have issued a Fire Warning
but there are many, many more. There are also location and time representations that I’m omitting from this example.
The wiki recommends being W-E-T with one FSL message per combination, forming complete sentences or paragraphs. That is impractical here. I have over 2,250 possible combinations. That is less WET and more a hurricane.
My alternatives seem to be (1) using FSL selectors for my switchyard and/or (2) making multiple passes at fluent… but the docs say both of these are bad practice. Neither of these really let me do a lot of compile-time verification.
So what is the “less bad” approach here? Selectors and a hefty dose of unit tests for completeness?
issued-event = {$evt ->
[RMT] a Required Monthly { -sig-test }
[RWT] a Required Weekly { -sig-test }
⋮
[FF] a Flash Flood { significance }
⋮
*[unk] an Unknown { significance }
}
(The “unknown event” is possible and does have meaning.)
I could put the switchyard in my application, either with multiple calls to fluent or by (misusing) fluent functions to do the same thing:
same-msg = {ORG($org, usage: "issued")} issued {EVT($evt, usage: "issued")}
## for the EVT function
evt-rmt = Required Monthly Test
.issued = a Required Monthly Test
I could do a bit more compile-time checking this way, but only at the cost of further decontextualizing my text strings.
Perhaps fluent is not the right tool for this problem, since it is edging into text generation as opposed to simply translating UI widgets. But if fluent is not the right tool, what is?