FIX: Allow invalid plural keys in MF translations

We can get translations with invalid plural keys from Crowdin
or from custom overrides. Currently, this will raise an error and the
locales won’t be outputted at all.

This patch addresses this issue by using the new `strict: false` option
of our `messageformat-wrapper` gem, allowing to generate locales even if
there are invalid plural keys present.
This commit is contained in:
Loïc Guitaut
2024-07-24 18:05:17 +02:00
committed by Loïc Guitaut
parent 5dca68dc1d
commit c4845acf5e
3 changed files with 40 additions and 8 deletions

View File

@ -150,7 +150,7 @@ module JsLocaleHelper
)
end
.compact_blank
compiled = MessageFormat.compile(message_formats.keys, message_formats)
compiled = MessageFormat.compile(message_formats.keys, message_formats, strict: false)
transpiled = DiscourseJsProcessor.transpile(<<~JS, "", "discourse-mf")
import Messages from '@messageformat/runtime/messages';
#{compiled.sub("export default", "const msgData =")};