Csound Csound-dev Csound-tekno Search About

[Cs-dev] New getstring implementation

Date2005-01-28 13:24
FromIstvan Varga
Subject[Cs-dev] New getstring implementation
Here is the documentation of the new localization system I added to the CVS
version of Csound5.

------------------------------------------------------------------------------

The file format is (quoting from the source):

/* File format of string database files:                                    */
/*                                                                          */
/* Bytes 0 to 3:    magic number (the string "cStr")                        */
/* Bytes 4, 5:      file version (two bytes, big-endian, should be 0x1000)  */
/* Bytes 6, 7:      language code (two bytes, big-endian; see H/text.h)     */
/* Bytes 8 to 11:   number of strings (four bytes, big-endian, must be > 0) */
/* From byte 12:                                                            */
/*   list of strings, in the following format:                              */
/*     0x81     (1 byte)                                                    */
/*     original string, terminated with '\0' (maximum length is 16383)      */
/*     0x82     (1 byte)                                                    */
/*     translated string, terminated with '\0' (maximum length is 16383)    */
/*   there should be as many string pairs as defined by bytes 8 to 11.      */

------------------------------------------------------------------------------

There are two new API functions:

/* Translate string 's' to the current language, and return pointer to      */
/* the translated message.                                                  */
/* This may be the same as 's' if language was set to CSLANGUAGE_DEFAULT,   */
/* or the string is not found in the database.                              */

char    *csoundLocalizeString(const char *s);

/* Set language to 'lang_code' (lang_code can be for example            */
/* CSLANGUAGE_ENGLISH_UK or CSLANGUAGE_FRENCH or many others, see       */
/* H/text.h for the list of languages).                                 */
/* This affects all Csound instances running in the address space       */
/* of the current process.                                              */
/* The special language code CSLANGUAGE_DEFAULT can be used to disable  */
/* translation of messages and free all memory allocated by a previous  */
/* call to csoundSetLanguage().                                         */
/* csoundSetLanguage() loads all files for the selected language from   */
/* the directory specified by the CSSTRNGS environment variable.        */

void    csoundSetLanguage(cslanguage_t lang_code);

------------------------------------------------------------------------------

Replaced/changed functions and macros:
   * Str(x) is now defined as csoundLocalizeString(x); it no longer takes
     an integer argument
   * if csoundLocalizeString() is not available, csound->LocalizeString()
     should be called (e.g. in plugin opcodes, but an Str() macro specifically
     for plugins may be included in csdl.h)
   * getstring() was removed
   * free_strings() was removed
   * init_getstring() is called the same way as the original version (it
     ignores the two arguments, though), but the functionality is slightly
     different. The environment variable CS_LANG is checked, and
     csoundSetLanguage() is called with a language code determined by the
     value of CS_LANG which is assumed to be a string name of a language.
     If CS_LANG is unset, or set to an unknown language name,
     csoundSetLanguage(CSLANGUAGE_DEFAULT) is called, disabling localization.
   * makedb.c was rewritten. The current version is really a temporary hack
     that emulates the old program. New, better utilities need to be written
     for converting ASCII string lists to binary databases and back, and
     merging two or more database files.



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net