Write messages

This section will give you helpful tips to make your message meaningful and concise.

The following tips help you make messages meaningful and concise:

  • Plan for the globalization of all messages, including messages that are displayed on panels.
  • Allow sufficient space for translated messages to be displayed. Translated messages often occupy more display columns than the original message text. In general, allow about 20% to 30% more space for translated messages, but in some cases, you might need to allow 100% more space for translated messages.
  • Use message catalogs to externalize any user and error messages. X applications can use resource files to externalize messages for each locale.
  • Provide default messages.
  • Make each message in a message source file be a complete entity. Building a message by concatenating parts makes translation difficult.
  • Use the $len directive in the message source file to control the maximum display length of the message text. (The $len directive is specific to the Message Facility.)
  • Use symbolic identifiers to specify the set number and message number. Programs should refer to set numbers and message numbers by their symbolic identifiers, not by their actual numbers. (The use of symbolic identifiers is specific to the Message Facility.)
  • Facilitate the reordering of sentence clauses by numbering the %s variables. This allows the translator to reorder the clauses if needed. For example, if a program needs to display the English message: The file %s is referenced in %s, a program may supply the two strings as follows:
    printf(message_pointer, name1, name2)
    The English message numbers the %s variables as follows:
    The file %1$s is referenced in %2$s\n
    The translated equivalent of this message may be:
    %2$s contains a reference to file %1$s\n
  • Do not use sys_errlist[errno] to obtain an error message. This defeats the purpose of externalizing messages. The sys_errlist[] is an array of error messages provided only in the English language. Use strerror(errno) , as it obtains messages from catalogs.
  • Do not use sys_siglist[signo] to obtain an error message. This defeats the purpose of externalizing messages. The sys_siglist[] is an array of error messages provided only in the English language. Use psignal(), as it obtains messages from catalogs.
  • Use the message comments facility to aid in the maintenance and translation of messages.
  • In general, create separate message source files and catalogs for messages that apply to each command or utility.