GNU Info

Info Node: (gawk.info)I18N Portability

(gawk.info)I18N Portability


Prev: Printf Ordering Up: Translator i18n
Enter node , (file) or (file)node

`awk' Portability Issues
------------------------

   `gawk''s internationalization features were purposely chosen to have
as little impact as possible on the portability of `awk' programs that
use them to other versions of `awk'.  Consider this program:

     BEGIN {
         TEXTDOMAIN = "guide"
         if (Test_Guide)   # set with -v
             bindtextdomain("/test/guide/messages")
         print _"don't panic!"
     }

As written, it won't work on other versions of `awk'.  However, it is
actually almost portable, requiring very little change.

   * Assignments to `TEXTDOMAIN' won't have any effect, since
     `TEXTDOMAIN' is not special in other `awk' implementations.

   * Non-GNU versions of `awk' treat marked strings as the
     concatenation of a variable named `_' with the string following
     it.(1) Typically, the variable `_' has the null string (`""') as
     its value, leaving the original string constant as the result.

   * By defining "dummy" functions to replace `dcgettext' and
     `bindtextdomain', the `awk' program can be made to run, but all
     the messages are output in the original language.  For example:

          function bindtextdomain(dir, domain)
          {
              return dir
          }
          
          function dcgettext(string, domain, category)
          {
              return string
          }

   * The use of positional specifications in `printf' or `sprintf' is
     _not_ portable.  To support `gettext' at the C level, many
     systems' C versions of `sprintf' do support positional specifiers.
     But it works only if enough arguments are supplied in the
     function call.  Many versions of `awk' pass `printf' formats and
     arguments unchanged to the underlying C library version of
     `sprintf', but only one format and argument at a time.  What
     happens if a positional specification is used is anybody's guess.
     However, since the positional specifications are primarily for use
     in _translated_ format strings, and since non-GNU `awk's never
     retrieve the translated string, this should not be a problem in
     practice.

   ---------- Footnotes ----------

   (1) This is good fodder for an "Obfuscated `awk'" contest.


automatically generated by info2www version 1.2.2.9