ITADN

How do people check in CI that en.ftl is complete

#397Openkrobelus 创建于 2025-12-09
K
krobeluscommented
Unlike gettext messages, fluent messages don't have a guaranteed fallback (I'm not counting the fluent ID). fish shell wants to have all messages available in English (which will be the unconditional fallback). Their CI will probably check this by 1. extracting the set of used fluent IDs from Rust sources via [a proc-macro](https://github.com/fish-shell/fish-shell/commit/80033adcf572dd3df74d49a186febf9fcac12ce1#diff-8523a18cc4b6a7568a228011373282fb657785e715c6cbdd70f3c5d5ec4afea0R5-R67) 2. parsing `en.ftl` to get the set of fluent IDs with English translations 3. checking that both sets of fluent IDs are equal Step 1 is a bit unorthodox, since there doesn't seem to be a clean way of extracting used IDs, especially in [parallel compilation scenarios](https://github.com/fish-shell/fish-shell/pull/12125/commits/e592a996132e57bcac89a2cca721561f3e442a5a). --- I suppose they could instead have `en.ftl` be the single source of fluent IDs, and guard every use of fluent IDs from Rust with a macro that checks (at compile time) that the given message ID is actually contained in `en.ftl`. This can be done with `include_str("en.ftl")`, like done [here](https://github.com/fish-shell/fish-shell/commit/4ffa06fb7e8c8f8c7c5783d1f4cd27ed25326ee5#diff-e24518d69b6357926bce35868225330c1992a4029b521c0112b4ec8523ddc31cR1358-R1363), but probably build a static set of fluent IDs (using the `phf` crate). The downside of this alternative is that it doesn't allow finding unused entries in `en.ftl`. I guess that could be mostly remedied with grep... --- I'm curious what other people use, since this seems like a common requirement. cc @danielrainer
7 条评论