DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Integrating applications into the Desktop

Localizing icon labels and messages

The environment variable $LANG sets a user's language preference. The presence and value of this variable determine how icon labels and messages are displayed during a user's session.

By default, your icon's label is taken from the name of your icon's object directory. If the directory is named Calendar.obj, by the icon will be labeled ``Calendar''. If the file title exists in the object directory, the contents of that file are used as the title.

Messages, such as menu titles and error messages, are often explicitly defined in the trigger files as absolute values, such as:

   title='analog clock'
In many cases, this default behavior is undesirable, such as when you want to be able to easily change messages and labels to another language. To do so, you must:

  1. Modify the rules found in the activate, drop, and menu trigger files to include a label and message variables rather than absolute values.

  2. Create or modify the text file associated with the specified language to define label and message variables.

To modify the trigger file:

  1. Change the absolute label name to a variable called $t1, and absolute message names to variables called $m1, $m2, and so on.

    For example, the menu example could be modified to localize messages:

      1 rule='
      2 menu: PopupClockMenu
      3 {
      4   menu_item
      5   {
      6     title='$m1'
      7     action
      8     {
      9 	begin
     10 	xclock -digital
     11 	finish
     12     }
     13   }
     14   menu_item
     15   {
     16     title='$m2'
     17     action
     18     {
     19 	begin
     20 	xclock
     21 	finish
     22     }
     23   }
     24   dividing_line;
     25   menu_item
     26   {
     27     title='$m3'
     28     action
     29     {
     30 	help 'static_arg'
     31     }
     32   }
     33 remove_dynamic_rule PopupClockMenu
     34 dynamic_rule PopupClockMenu $rule
     35 popup PopupClockMenu $static_arg
    

    lines 6, 16, 27
    These lines contain the new message variables to be localized in the object.obj/$LANG/text file.

To modify the text file:

  1. Ensure that the appropriate language directory exists in the object directory.

    For example, if you are localizing a Spanish language application for use in Spain, ensure that the spanish_SPAIN directory exists in the object directory.

  2. Create a file called text to include the messages and labels.

    Or, if the file already exists, edit it. Here is a sample text file:

       t1='Calendario'
       m1='Enero'
       m2='Febrero'
       .
       .
       .
       m12='Deciembre'
    
    In this sample file, the title (t1) is set to the Spanish translation of Calendar, and each message (m1-m12) corresponds to a month of the year.


Next topic: Creating icons for user data files
Previous topic: Animating icons

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003