Skip to content
Neil O'Keeffe edited this page Jan 18, 2023 · 4 revisions

Introduction

PxStat may be adapted for any language, however the application itself is entirely language agnostic. All language specific data and functionality must be defined in language plugins, one for each language. Any new language plugin must conform entirely to the ILanguagePlugin interface.

Creating a language plugin - what you need to know:

  • Language plugins will only work for PxStat versions 5.5.0 onwards.
  • Language plugins for version 5.5.0 must be written in .Net 4.7.2. Plugins for version 6.0.0 onwards must be written in .Net 6.
  • The plugin must contain a public class that fully implements ILanguagePlugin.
  • The plugin will be compiled as a DLL
  • Once built and deployed, the DLL is kept in the Resources/Internationalisation/LanguagePlugins folder in the PxStat project
  • The server.config must contain the path to the DLL along with some other data as outlined below.
  • If you setup a new language in PxStat without having created and configured a language plugin, the application will still work, however all server messages will be in English and there will be only very basic search engine capability. In these cases you will be using the inbuilt GenericLanguagePlugin.
  • It is recommended that you use the GenericLanguagePlugin as a template for creating additional plugins.

ILanguage interface

You must create a full implementation of the ILanguage interface shown below:

    public interface ILanguagePlugin
    {
        string LngIsoCode { get; set; }
        bool IsLive { get; set; } 
        dynamic GetLabelValues();
        string Sanitize(string words);
        string Singularize(string word);
        IEnumerable< string> GetSynonyms(string word);
        IEnumerable<string> GetExcludedTerms();
        IEnumerable<string> GetDoNotAmend();

    }

LngIsoCode:

This is the 2 character ISO 639-1 code for the language

IsLive

Used to flag if the language is currently in use in PxStat. This is generally set to true, however an example of where we set to false is where we want the Generic language to act as a default when the requested language is not found. In that case Generic will simulate the rules of the required langauge with some restrictions.

GetLabelValues()

Returns the full list of PxStat server messages translated into the required language

Sanitize(string words)

Removes unwanted characters from a string.

Singularize(string word)

Expresses an inflected word in a single standard format. For example, in English this would return "car" for "cars" and "woman" for "women". Languages that have more inflection will require much more processing in this function. This is used to in order to keep a limited set of keywords in the PxStat database for the search function.

GetSynonyms(string word)

Returns a list of synonyms for a word. Synonyms for a language are typically found in publicly available Wordnets. If your Wordnet has the same structure as the Open English Wordnet you may use the Wordnet Synonym Extractor to extract a synonym list.

GetExcludedTerms()

Gets a list of words that will not form part of the search even if they are included in the search query

GetDoNotAmend()

Gets a list of words that will not be singularized

Installing the plugin

Once the plugin has been built and tested, it should be compiled to a Release version and included in the PxStat project at \server\PxStat\Resources\Internationalisation\LanguagePlugins\ . You will also need to set some configuration in the the PxStat server.config file. Please see the PxStat wiki for more details.

GenericLanguagePlugin

The Generic Language plugin has two functions. Firstly, it acts as a template for creating real language plugins. Secondly, it is always included in PxStat as a fall-back for when a service is requested in a language for which a plugin doesn't exist. In these cases, the generic plugin will assume the identity of the required language. A number of restrictions will apply in that case:

  • All server messages will be in English
  • Singularization will just return the requested word unchanged
  • There will be no synonyms

Next Steps

When you have created and deployed your language plugin we would invite you to include the DLL in the PxStat project at https://github.com/CSOIreland/PxStat