chickadee » free-gettext » gettext

textdomain #!optional <name>procedure
gettext <message>procedure
(use free-gettext)
(textdomain "myapp")
(print (gettext "Hello, world!"))

The above is the most basic usage and is equivalent to the GNU gettext module. TEXTDOMAIN sets the name of the current "domain", which is the name of the message catalog (typically the name of the application). With no arguments it returns the name of that domain. GETTEXT then fetches the translation of the message in that domain in the current locale (from the LANG environment variable), or returns the original string if the message can't be found.

Apart from actually creating the message files (which you can put off indefinitely), that's all you need to internationalize your message strings. Since every natural language string needs to be translated, a common idiom is to give a short name to GETTEXT:

(define _ gettext)
(print (_"Hello, world!"))

Alternately, you could make , a prefix for all message strings:

(define-syntax unquote
  (syntax-rules ()
    ((_ str) (gettext str))))

(print ,"Hello, world!")

Note that free-gettext converts all strings to utf8 internally, to work best with the utf8 egg and other eggs which assume Chicken strings are utf8. This is a feature - all strings are consistently the same encoding, and you don't need to create separate message files for every different encoding a user might want. Many GUI toolkits like Gtk also assume utf8. On the other hand, if you want to output text to a non-utf8 terminal you'll need to perform the translation manually.