.
Eloquence WEBDLG2 contact contact

Documentation / WEBDLG2 / Strings configuration and localization

Strings configuration and localization

 
.
  Document revision: 2022-08-15
Refers to WEBDLG2 version: PE83-2207080 (beta version 57)


WEBDLG2 allows to localize the default text strings used in the login and message dialogs, i.e., adapt the text to other languages/regions. To do so, a Javascript document needs to be created and loaded into the HTML documents.

The eq.strings() Javascript API is used to install a translation. Just to demonstrate this, the example below would install the default strings exactly as built-in:

eq.strings({
   login : {
      prompt : "Please enter your login and password to start:",
      label  : {
         name : "&Login:",
         pass : "&Password:"
      },
      ok     : "L&ogin",
      cancel : "&Cancel",
      save   : "&Save login"
   },
   message : {
      ok : "&Dismiss"
   }
});

The first eq.strings() argument is a structured object specifying the various strings used in the login and message dialogs (login and message properties).

Example for a French translation:

eq.strings({
   login : {
      prompt : "Veuillez entrer votre identifiant et votre mot de passe pour commencer:",
      label  : {
         name : "&Identifiant:",
         pass : "&Mot de passe:"
      },
      ok     : "C&ommencer",
      cancel : "&Annuler",
      save   : "&Enregistrer"
   },
   message : {
      ok : "&Rejeter"
  }
}, 'fr-FR');

Example for a German translation:

eq.strings({
   login : {
      prompt : "Bitte Benutzernamen und Kennwort eingeben für:",
      label  : {
         name : "&Benutzername:",
         pass : "&Kennwort:"
      },
      ok     : "&Einloggen",
      cancel : "&Abbruch",
      save   : "&Login speichern"
   },
   message : {
      ok : "&Schließen"
  }
}, 'de-DE');

The optional second eq.strings() argument is an IETF BCP 47 language tag, for example:

en-US English (United States)
en-GB English (United Kingdom)
fr-FR French (France)
de-DE German (Germany)

The default strings are set if the second argument is omitted. The default strings are used when the strings for a specific locale are not installed.

The eq.strings() API may be invoked multiple times if multiple translations should be installed.

To install the translations, create a text file named, for example, eq-strings.js, containing one or multiple eq.strings() invocation(s). Store the file in the web server document hierarchy.

Please note: The file needs to be UTF-8 encoded.

The file may then be integrated into the HTML documents, for example:

<script async src="/path/to/eq-strings.js"></script>

As shown here, using the async attribute is recommended to avoid that the script potentially delays loading the document (1).

Technical note:

IETF BCP 47 language tags start with a language code, for example fr (French), optionally followed by a region code, for example FR (France), separated with a hyphen (-).

When the second eq.strings() argument is set, for example, to fr-FR, the specified translation is used when the locale is either fr or fr-FR.

If multiple translations are installed for the same language code, for example fr-FR (French [France]) and fr-CA (French [Canada]), and the locale is fr, the translation installed first is used.


 
 
 
  Privacy | Webmaster | Terms of use | Impressum Revision: 2022-08-15  
  Copyright © 1995-2022 Marxmeier Software AG