You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since #80 / PR #527, dcgettext(), dcngettext(), and bindtextdomain() exist but perform no actual translation: text is returned untranslated and dcngettext() applies the English plural rule. This matches gawk built without gettext — gawk's own test suite accepts this: its nlstringtest target compares against nlstringtest-nogettext.ok first, and Jawk's GawkLocaleIT.test_nlstringtest passes against that baseline.
Proposed feature
Implement real message catalog support so the i18n functions translate like gawk built with gettext:
Parse the GNU .mo binary catalog format (simple: magic 0x950412de, offset tables of original/translated strings, optional hash table).
Resolve the catalog path as gettext does: <binding directory>/<locale>/LC_MESSAGES/<domain>.mo, with the binding from bindtextdomain(), the domain from the argument or TEXTDOMAIN, and the locale from the CLI --locale option / JVM default locale (gawk uses GAWKLOCALE/LC_ALL).
Plural selection in dcngettext() per the catalog's Plural-Forms: header, which requires evaluating its small C-like expression (e.g. nplurals=2; plural=(n > 1); for French).
Sandbox: catalog loading reads files at runtime, so it must respect SandboxedAwk restrictions (probably disabled under sandbox).
Acceptance test
gawk's own fixture: running nlstringtest.awk with the compiled catalog test/fr/LC_MESSAGES/nlstringtest.mo (from the gawk source tree) under a French locale must produce the translated nlstringtest.ok:
Current state
Since #80 / PR #527,
dcgettext(),dcngettext(), andbindtextdomain()exist but perform no actual translation: text is returned untranslated anddcngettext()applies the English plural rule. This matches gawk built without gettext — gawk's own test suite accepts this: itsnlstringtesttarget compares againstnlstringtest-nogettext.okfirst, and Jawk'sGawkLocaleIT.test_nlstringtestpasses against that baseline.Proposed feature
Implement real message catalog support so the i18n functions translate like gawk built with gettext:
.mobinary catalog format (simple: magic0x950412de, offset tables of original/translated strings, optional hash table).<binding directory>/<locale>/LC_MESSAGES/<domain>.mo, with the binding frombindtextdomain(), the domain from the argument orTEXTDOMAIN, and the locale from the CLI--localeoption / JVM default locale (gawk usesGAWKLOCALE/LC_ALL).dcngettext()per the catalog'sPlural-Forms:header, which requires evaluating its small C-like expression (e.g.nplurals=2; plural=(n > 1);for French).%2$s remplace %1$s.in gawk's French catalog), so full fidelity also needs positionalprintfargument support.SandboxedAwkrestrictions (probably disabled under sandbox).Acceptance test
gawk's own fixture: running
nlstringtest.awkwith the compiled catalogtest/fr/LC_MESSAGES/nlstringtest.mo(from the gawk source tree) under a French locale must produce the translatednlstringtest.ok:🤖 Generated with Claude Code