x/text/message/catalog: unclear how to implement Dictionary #59330
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
The documentation for
catalog.Dictionary
saysBut catmsg is an internal package that I can't use.
According to https://medium.com/@oborin/localization-in-go-with-enclosing-packages-6fe2efb85a15, I should prefix my message with
"\x02"
, but there's no explanation why that is. As far as I can tell that corresponds to handlercatmsg.msgRaw
, and seems to work, but since it is undocumented I'm afraid that could stop working any day.Let me take a step back and explain why I'm interested in this. My actual goal is to write unit tests for translated text that are independent of the actual translations, so they do not break if translations change. My understanding is that I can't mock
message.Printer
using an interface, as gotext relies on the exact type to extract the translation keys from the source code, so I have decided to instead use a custom Catalog that returns keys unchanged.This appears to work, but I'd like a guarantee that it will continue to do so.
The text was updated successfully, but these errors were encountered: