##- # Dedicated to the public domain # # Date: September 2016 # Modified: 2016-10-25/01:13-0400 ##+ # # unicon-i18n.icn, demonstrate GNU gettext locale translation # # tectonics: gcc -o unicon-i18n.so -shared -fpic unicon-i18n.c # link printf procedure main() write("Test error message about invalid width in environment") initlocale("coreutils", "/usr/share") write(printf(_("ignoring invalid width in environment _ variable COLUMNS: %s"), -4)) write("\nTest message about write error") write(_("write error")) write("\nTest message about specifying fields") write(_("you must specify a list of bytes, characters, or fields")) write("\nTest messages about invalid pattern and regex") write(printf(_("%s: invalid pattern"), &progname || ":" || &line)) write(printf(_("%s: invalid regular expression: %s"), &progname || ":" || &line, "[")) end # # i18n/L10n setup # procedure initlocale(domain, localedir) &error +:= 1 initlocale := loadfunc("./unicon-i18n.so", "initlocale") | nolocale &error -:= 1 return initlocale(domain, localedir) end procedure nolocale(domain, localedir) return &null end # # i18n/L10n # procedure _(text:string) &error +:= 1 _ := loadfunc("./unicon-i18n.so", "translate") | _none &error -:= 1 return _(text) end procedure _none(text:string) return text end