Listing of Source client/LocalizedTextStrings.java
package se.entra.phantom.client;

import java.util.Locale;

import se.entra.phantom.common.Utilities;

/**
 * The localized text string class is used to keep all
 * strings that cannot come from the server after this one
 * has been contacted.
 *
 * <p>This class is static only, so all texts for the client
 * use a single language.
 */
public class LocalizedTextStrings
{
  /**
   * Title message in "Connecting..." dialog box.
   */
  public static final int connectTitle = 0;

  /**
   * First message in "Connecting..." dialog box.
   */
  public static final int loading = 1;

  /**
   * Second message in "Connecting..." dialog box.
   */
  public static final int contactingServer = 2;

  /**
   * Third message in "Connecting..." dialog box.
   */
  public static final int contactingBackupServer = 3;

  /**
   * Loading application message in "Connecting..." dialog box.
   */
  public static final int loadingApplication = 4;

  /**
   * Initial communications failure with the Server.
   */
  public static final int communicationsFailure = 5;

  /**
   * Initial communications failure with the Server.
   */
  public static final int communicationsFailure1 = 6;

  /**
   * The string for "Server".
   */
  public static final int server = 7;

  /**
   * The string for "Error".
   */
  public static final int error = 8;
  
  /**
   * The text for "Press OK to exit".
   */
  public static final int communicationsFailure2 = 9;

  /**
   * Exit message heading.
   */
  public static final int exitTitle = 10;

  /**
   * Parameter error message.
   */
  public static final int paramError = 11;
  
  /**
   * The Cancel button.
   */
  public static final int cancel = 12;

  /**
   * The OK button.
   */
  public static final int ok = 13;

  /**
   * The Enter button.
   */
  public static final int enter = 14;

  /**
   * The Yes button.
   */
  public static final int yes = 15;

  /**
   * The No button.
   */
  public static final int no = 16;

  /**
   * The Retry button.
   */
  public static final int retry = 17;

  /**
   * The Ignore button.
   */
  public static final int ignore = 18;

  /**
   * The No connection text.
   */
  static final int noConnection = 19;

  /**
   * Initializing file download.
   */
  static final int initializingFileDownload = 20;

  /**
   * Error processing Client JAR files. 
   */
  static final int errorProcessingClientJARFiles = 21;

  /**
   * Checking downloaded file
   */
  static final int checkingDownloadedFile = 22;

  /**
   * Downloading file.
   */
  static final int downloadingFile = 23;

  /**
   * Client couldn't create the directory to place the Client JAR files
   */
  static final int clientCouldntCreateTheDirectoryToPlaceTheClientJARFiles = 24;

  /**
   * Error transferring Client JAR.
   */
  static final int errorTransferringClientJAR = 25;

  /**
   * Reconnecting to server.
   */
  static final int reconnectTitle = 26;

  /**
   * Reconnecting to server.
   */
  static final int reconnecting = 27;

  /**
   * Couldn't reconnecting to server.
   */
  static final int cantReconnect = 28;

  /**
   * Couldn't reconnecting to server.
   */
  static final int reconnectTimeout = 29;

  /**
   * Couldn't reconnecting to server.
   */
  static final int reconnectIDerr = 30;

  ///

  /**
   * The array of localized strings.
   */
  private static String [] strings;

  /**
   * The texts in English.
   */
  private static String [] strings_us =
    {
    "Connecting to $S",
    "Loading, please wait...",
    "Contacting the primary $S",
    "Contacting the backup $S",
    "Loading application...",
    "Communications failure with $S. Press OK to exit.",
    "Failure connecting to $S:",
    "Server",
    "Error",
    "Press OK to exit.",
    "Exiting $C",
    "Parameter error. Closing the $C...",
    "Cancel",
    "OK",
    "Enter",
    "Yes",
    "No",
    "Retry",
    "Ignore",
    "No connection",
    "Initializing file download",
    "Error processing Client JAR files",
    "Checking downloaded file",
    "Downloading file",
    "Client couldn't create the directory to place the Client JAR files",
    "Error transferring Client JAR",
    "Reconnecting to $S",
    "Reconnecting to $S, please wait...",
    "Could not reconnect to server $S. Press OK to exit.",
    "$C session has timed out at the $S. Press OK to exit.", 
    "$C session ID mismatch with $S session ID after reconnect. Press OK to exit." 
    };

  /**
   * The texts in German.
   */
  private static String [] strings_de =
    {
    "Verbindungsaufbau mit dem $S",
    "Ladevorgang, bitte warten...",
    "Kontaktiere den Primären $S",
    "Kontaktiere den Backup $S",
    "Die Applikation wird geladen...",
    "Kommunikationsfehler mit dem $S. Betätigen Sie OK zum Beenden.",
    "Fehler beim Aufbau der Serververbindung:",
    "Server",
    "Fehler",
    "Betätigen Sie OK zum Beenden.",
    "Der $C wird beendet",
    "Parameter-Fehler. Das $C wird beendet...",
    "Abbrechen",
    "OK",
    "Eingabe",
    "Ja",
    "Nein",
    "Wiederholen",
    "Ignorieren",
    "Keine Verbindung",
    "Initialisieren Download der Datei",
    "Fehler die Verarbeitung von Client-JAR-Dateien",
    "Überprüfen die heruntergeladene Datei",
    "Download Datei",
    "Client könnte nicht erstellt das Verzeichnis zu platzieren Sie den Client-JAR-Dateien",
    "Fehler beim Übertragen von Client-JAR",
    "Wiederverbinden mit dem $S",
    "Wiederverbinden mit dem $S, bitte warten...",
    "Konnte keine Verbindung zum dem $S verbinden. Betätigen Sie OK zum Beenden.",
    "$C-Sitzung hat sich bei der $S gestopp. Betätigen Sie OK zum Beenden.", 
    "$C-Sitzung ID mmt nicht mit der $S session ID-Sitzung ID nach der Wiederverbindung. Betätigen Sie OK zum Beenden." 
    };

  /**
   * The texts in Swedish.
   */
  private static String [] strings_sv =
    {
    "Kontaktar $S",
    "Laddar, vänligen vänta...",
    "Kontaktar primär $S",
    "Kontaktar backup $S",
    "Laddar applikationen...",
    "Kommunikationsfel med $S. Tryck OK för att avsluta.",
    "Kunde inte kontakta $S:",
    "Server",
    "Fel",
    "Tryck OK för att avsluta.",
    "Avsluta $C",
    "Parameterfel. Avslutar $C...",
    "Avbryt",
    "OK",
    "Enter",
    "Ja",
    "Nej",
    "Försök igen",
    "Fortsätt",
    "Inte ansluten",
    "Initierar filnedladdning",
    "Fel vid processing av klient-JAR-filer",
    "Kontrollerar nedladdad fil",
    "Laddar ned fil",
    "Klienten kunde inte skapa biblioteket för lagring av klient-JAR-filer",
    "Fel vid överföring av klient-JAR",
    "Återansluter till $S",
    "Återansluter till $S, vänligen vänta...",
    "Kunde inte återansluta till $S . Tryck OK för att avsluta.",
    "$C sessionen har gått ut vid $S. Tryck OK för att avsluta.", 
    "$C sessionen's ID överensstämmer inte med $S session's ID efter återanslutning. Tryck OK för att avsluta." 
    };

  /**
   * Available locales.
   */
  private static Object [] locales =
    {
    "sv", strings_sv,
    "de", strings_de
    };

  ///
  
  /**
   * At initialization, check for correct language locale.
   */
  static
    {
    setup();
    }
  
  /**
   * Gets the language.
   */
  static void setup()
    {
    String [] s=strings_us;
    try
      {
      String lang=System.getProperty("user.language").toLowerCase();
      for ( int ii=0; ii<locales.length; ii+=2 )
        {
        if ( lang.equalsIgnoreCase((String)locales[ii]) )
          {
          s=(String [])locales[ii+1];
          break;
          }
        }
      }
    catch(Throwable t)
      {
      // In case of SecurityException...
      }
    strings=s;
    }
  
  /**
   * Set's up a new setting from command line or server.
   */
  public static void setup(String ss)
    {
    if ( ss!=null && ss.length()>=2 )
      {
      // Split into language/country.
      String s1=ss.toLowerCase();
      String s2=null;
      int d=ss.indexOf('_');
      if ( d>=0 )
        {
        s1=ss.substring(0,d);
        s2=ss.substring(d+1).toUpperCase();
        }
      try
        {
        Locale.setDefault((s2==null)? new Locale(s1): new Locale(s1,s2));
        System.out.println("System locale: "+Locale.getDefault().toString());
        }
      catch(Throwable t) {}
      
      // Set in system properties.
      try
        {
        System.setProperty("user.language",s1);
        if ( s2!=null )
          System.setProperty("user.country",s2);
        setup();
        }
      catch(Throwable t) {}
      }
    }
  
  ///
  
  /**
   * Gets a text from an index.
   */
  public static String get(int index)
    {
    return strings[index]
       .replace("$N",Utilities.PROGRAM_NAME)
       .replace("$C",Utilities.PROGRAM_NAME_CLIENT)
       .replace("$S",Utilities.PROGRAM_NAME_SERVER)
       .replace("$E",Utilities.PROGRAM_NAME_EDITOR);
    }
}