Skip to content

Server Multilingual Support

DeclanBuckley edited this page Dec 8, 2023 · 18 revisions

Home / Developer / Server Tier / Multilingual Support

PxStat Application Server Side Multilingual Support including required steps to accommodate another language.

Summary.

PxStat may be extended to cater for languages other than English but may also be adapted to use multiple languages in the same implementation. Server side language support is enabled via specific language plugins, one per language. Language support is a necessary feature of the following aspects of the application:

  • Versions of the same Matrix in other languages.
  • Product and Subject names in multiple language versions.
  • Efficient searching using multiple language search terms.
  • Navigation terms in multiple language versions.

Prerequisites.

Languages are managed via PxStat.System.Settings.Language_API. All languages used in the application must be defined in the database. Note the following:

  • Languages are identified by their ISO Code (LngIsoCode in the application). For details see https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes .
  • The ISO code must consist of 2 characters and must correspond to a valid ISO_639-1 code.
  • A PxStat implementation must define a default language. This is defined in Static.Config under APP_DEFAULT_LANGUAGE.
  • Language specific code is managed by use of language plugins. A language plugin must be written for each language and added to PxStat. The PxStat code does NOT need to be amended to cater for additional languages. For details on how to create a language plugin, please go to https://github.com/CSOIreland/PxLanguagePlugins.

Matrix.

A .px file contains a definition for language. Provided the language has already been set up in the system, the uploaded matrix will contain a language attribute. It is therefore possible to upload multiple language versions of the same .px file.

Products.

Products are managed via PxStat.System.Navigation.Product_API. When a Product is created, it is defined in the default language. However alternative language versions can be created via the Update method. Once the alternatives are created, it is possible to specify which language version we want in the Read action. If a version exists in the requested language, this will be returned, if it doesn't exist then the default language version will be returned.

Subjects.

Subjects are managed via PxStat.System.Navigation.Subject_API. Similarly to Products, Subjects are initially defined in the default language but alternative language versions can be created via the Update method. Once the alternatives are created, it is possible to specify which language version we want in the Read action. If a version exists in the requested language, this will be returned, if it doesn't exist then the default language version will be returned.

Navigation.

The PxStat.System.Navigation.Navigation_API.Read method returns a set of Navigation data. If a LngIsoCode of a specific Language is passed then the returned Subject and Product names will be in that language where they are defined - otherwise these are returned in the default language.

Keyword Search.

The PxStat.System.Navigation.Navigation_API.Search method enables the user to search for Releases using a combination of Keyword search and specific entities related to Releases. For Keyword search to work, once either a Release, a Subject or a Product are created/amended we create a set of keywords in order to enable fast search and matching.

General rules for Keywords:

  • Keywords should be the simplest version of a word possible.
  • Keywords can be transformed in order create a simple version. Search terms should then undergo exactly the same process in order to match them with the keywords.
  • When searching for Releases we need to state our language preference.
  • Different languages will require very different transformation processes. The complexity of this transformation will depend on the grammar rules of the language, most especially the degree to which nouns are inflected. This must be reflected in the details of the language plugin DLL.

Required steps for extending PxStat to accommodate another language.

  • If a plugin for the language doesn't exist, you will need to create one. Please see https://github.com/CSOIreland/PxLanguagePlugins/wiki for details of how to create one for your language.
  • Place the DLL into the folder at \server\PxStat\Resources\Internationalisation\LanguagePlugins
  • Configure the language settings in the server.config file as outlined in the next section

Language configuration settings.

The config.server file is found at \server\PxStat\Resources\Config\config.server.json An live example of language settings is shown below. In this case there are two languages in the system, English and Gaeilge. A default is also included but will not be normally accessed by the application because is-live is shown as false. The default language will substitute itself for any language that does not have a defined plugin.

  "language-resource": [
    {
      "iso": "en",
      "name": "English",
      "plugin-location": "Resources\\Internationalisation\\LanguagePlugins\\EnglishLanguagePlugin.dll",
      "namespace-class": "EnglishLanguagePlugin.Language",
      "is-live": true
    },
    {
      "iso": "ga",
      "name": "Gaeilge",
      "plugin-location": "Resources\\Internationalisation\\LanguagePlugins\\GaeilgePlugin.dll",
      "namespace-class": "GaeilgePlugin.Language",
      "is-live": true
    },
    {
      "iso": "default",
      "name": "Generic",
      "plugin-location": "Resources\\Internationalisation\\LanguagePlugins\\GenericLanguagePlugin.dll",
      "namespace-class": "GenericLanguagePlugin.Language",
      "is-live": false
    }
  ]

Tags are as shown below:

  • "iso" - The 2 letter ISO 639-1 code for the language
  • "name" - The name of the language
  • "plugin-location" - The relative path of the plugin dll
  • "namespace-class" - The namespace followed by the class name in dot notation for the class that implements the interface
  • "is-live" - Denotes whether or not the plugin is currently live in the system. This is generally set to true in all cases apart from the Default plugin.

Next Steps

This completes the server side setup. You will also need to:

  • Create a dictionary file for the front end. You can do this by copying \client\internationalisation\label\en.json, renaming it with the iso code of your language and translating all of the terms in the file.
  • Add the language to the system via the System menu on the PxStat client
Clone this wiki locally