Internationalisation

FUNCTIONS

  void  set_string(App *app, char *key, char *value);
  char *get_string(App *app, char *key);

NOTES

The set_string function associates a string value with a string key, for use in internationalising programs. Keys and values are case-sensitive and UTF-8 encoded. Once a value is associated with a key, that stored value can be returned by passing the key to get_string, otherwise NULL is returned.

The dialog functions use certain keys to determine what message strings to display. Changing the values associated with these keys allows a program to internationalise the dialog functions.

The current set of dialog keys and values are given in the table below.

KeyDefault Value
"Yes""Yes"
"No""No"
"Cancel""Cancel"
"OK""OK"
"Quit""Quit"
"Create""Create"
"Overwrite""Overwrite"
"Error""Error"
"File:""File:"
"Files:""Files:"
"Path:""Path:"
"Folder:""Folder:"
"Folders:""Folders:"
"Create file?""That file does not exist. Create the file?"
"Already a folder!""That file name is already is use as a folder."
"Overwrite file?""That file already exists. Overwrite the file?"
"Create File""Create File"
"Error: Create File""Error: Create File"
"Overwrite File""Overwrite File"
"Error: Save File""Error: Save File"

Standard keys and default values used by dialog functions.

To create a program which uses dialogs in a language other than English, each of the above values should be translated into the new language, using set_string after the App structure has been created but before using any dialog functions. For example, a French program might begin:

  int main(int argc, char *argv[])
  {
    App *app = new_app(argc, argv);
    set_string(app, "Yes", "Oui");
    set_string(app, "No", "Non");
    set_string(app, "Cancel", "Annuler");
    set_string(app, "OK", "Oui");
    ...
    ask_yes_no(app, "Quitter?", "Quitter le programme?");
    ...
  }

Some of the defined strings appear on dialog buttons, some in the title bar of dialog windows, some as messages. Those strings that appear in title bars (the last 4 in the given table) may be impossible to properly internationalise, since some window managers incorrectly display Unicode text, and might only allow ISO Latin 1 or even only ASCII text to be used in title bars.