Csound Csound-dev Csound-tekno Search About

Re: Localization of CSound

Date1999-04-29 13:55
FromThomas Hudson
SubjectRe: Localization of CSound
jpff@maths.bath.ac.uk wrote:
> 
> Message written at 29 Apr 1999 07:51:25 +0100
> --- Copy of mail to thudson@cygnus.com ---
> 
> If it is GNU code then presumably it has GNU licencing?  

If has the library GPL, which is more lenient than the standard
GPL. The LGPL allows non-GPL code to link with it.

> I have
> checked my SGI and Linux machines and neither of them has such a
> system.
  
If would appear on Linux machines using the latest C library (libc6 aka
glibc).

> I remain reluctant to use it.  It is on my friend's SUN

I believe Ulrich Drepper did the original work when at Sun, and completed
it at Cygnus. The original sun man pages might not give the full picture.

> machine so we did look at the man pages for some time yesterday
> lunchtime, but I am not very enthusiastic.  I am inclined to do it teh
> obvious way.

You may want to consider stealing a few ideas from it. First wrapping
all error messages in a macro:

  char* message = _("Error message");

This macro can then be defined to call a catalog lookup:

#define _(x) mygettext(x)


This makes it easy for a simple perl/python/shell script to extract all
strings into a text file for translation:

egrep "_\(.*\)" *.[ch] > messages.txt

There are several caveats to this system. Quoting from Ulrich Drepper's
original article:

--- begin quote

Special string occurences in C source code

In almost every program one will find situations where the scheme for 
marking strings as we described it will fail. The following code 
fragments both will fail: 

     void
     f (int idx)
     {
       const char *tab[] = {_("one"), _("two"),
                            _("three")};
       puts (tab[idx]);
     }

and 

     void
     f (int idx)
     {
       const char *tab[] = {"one", "two",
                            "three"};
       puts (_(tab[idx]));
     }

The former will fail because initializers cannot be computed at runtime 
and the second will fail because the strings are not marked and so 
cannot be extracted by xgettext.

The answer is a mixture between both examples: 

     void
     f (int idx)
     {
       const char *tab[] = {N_("one"), N_("two"),
                            N_("three")};
       puts (_(tab[idx]));
     }

N_ is another of the semi-standard macros used in GNU packages. It is 
defined as the no-op macro with one argument: 

     #define N_(String) (String)

The meaning of this macro is to provide a wrapping function call which 
the xgettext program can recognize. So we can extract the strings and 
at runtime translate them using the _() (i.e., gettext) function.

-- end quote

Whether using GNU gettext or writing your own, the best overview of the 
problems and solutions is Ulrich Drepper's document:

http://i44www.info.uni-karlsruhe.de/~drepper/conf96/paper-6.html