.
Eloquence WEBDLG2 contact contact

Documentation / WEBDLG2 / Strings configuration and localization

Strings configuration and localization

 
.
  Document revision: 2024-10-28
Refers to WEBDLG2 version: B0840 2409-1


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",
      cancel    : "&Cancel",
      dlgListen : "<html>Waiting for DLG connection on port"
   }
});

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",
      cancel    : "&Annuler",
      dlgListen : "<html>En attente de connexion DLG sur le port"
  }
}, '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",
      cancel    : "&Abbruch",
      dlgListen : "<html>Warte auf DLG Verbindung auf Port"
  }
}, '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.

To use the translations in your WEBDLG2 applications, configure an URI in the eloqwebd2.uri file for the directory containing the translation files, for example:

[/plugin]
Path = /directory/in/web/server/document/hierarchy

This configuration associates the /plugin URI with the directory containing the translations in the file system. Now the application can be configured to load the translations by setting PluginURL as shown below:

PluginURL = /plugin/eq-strings.js

Alternatively, the translation files may be integrated into the HTML documents. This is necessary when using an external web server.

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: 2024-10-28  
  Copyright © 1995-2024 Marxmeier Software AG