// Module: Localization
// Localization is used to translate text fragments that appear in the user interface from English
// to the language of the user.
// Dependencies
// These files shall be included before this file is included:
// - Utilities

  /*to do: copy quoted text from English to translation without using the dictionary. Remove such entries from the dictionary.*/
  /*to do: define rules for capitalised words.
  A capitalised word, at the beginning of a sentence, that otherwise cannot be translated, can be
  translated by a capitalized translation of the undercapitalised English word.
  A capitalised word, not at the beginning of the sentence, otherwise cannot be translated, can be
  considered to be a name. Names can be copied from the English to the translation without using
  the dictionary.*/
  /*to do: build-in a self test that checks that no dictionary entry (or part of it) can be translated correctly
  using the remainder of the dictionary. Such dictionary entries are obsolete.*/

User-Defined Object: DictEntry
function DictEntry(English, translation) {
  this.mEnglish = English;
  this.mTranslation = translation;
} //DictEntry

User-Defined Object: Localization
function Localization() {
  var mLanguage;
  Publications                                                                                    */
  this.translate = translate;
  function setLanguage(language) {
    assert('setLanguage01', true, language === 'en' || language === 'nl');
    mLanguage = language;
    mDict = new Array;
    if (mLanguage === 'nl') {
      mDict.push(new DictEntry('a', 'een'));
      mDict.push(new DictEntry('à', 'à'));
      mDict.push(new DictEntry('á', 'á'));
      mDict.push(new DictEntry('â', 'â'));
      mDict.push(new DictEntry('ä', 'ä'));
      mDict.push(new DictEntry('è', 'è'));
      mDict.push(new DictEntry('é', 'é'));
      mDict.push(new DictEntry('ê', 'ê'));
      mDict.push(new DictEntry('ë', 'ë'));
      mDict.push(new DictEntry('ì', 'ì'));
      mDict.push(new DictEntry('í', 'í'));
      mDict.push(new DictEntry('î', 'î'));
      mDict.push(new DictEntry('ï', 'ï'));
      mDict.push(new DictEntry('℃', '℃'));
      mDict.push(new DictEntry('●', '●'));
      mDict.push(new DictEntry('an', 'een'));
      mDict.push(new DictEntry('and', 'en'));
      mDict.push(new DictEntry('and you\'ll land', 'en komt u terecht'));
      mDict.push(new DictEntry('at that board', 'bij dat bord'));
      mDict.push(new DictEntry('board', 'prikbord'));
      mDict.push(new DictEntry('Answers', 'Antwoorden'));
      mDict.push(new DictEntry('Create a new recipe page', 'Maak een nieuwe receptpagina aan'));
      mDict.push(new DictEntry('Delete', 'Verwijderen'));
      mDict.push(new DictEntry('discussion', 'discussie'));
      mDict.push(new DictEntry('Dispatch', 'Verwijzing'));
      mDict.push(new DictEntry('Due to', 'Vanwege'));
      mDict.push(new DictEntry('Due to technical problems this board is', 'Vanwege technische probl' +
        'emen is dit prikbord'));
      mDict.push(new DictEntry('Edit', 'Bewerk'));
      mDict.push(new DictEntry('Exit without saving', 'Sluiten zonder op te slaan'));
      mDict.push(new DictEntry('file your request', 'uw verzoek in te dienen'));
      mDict.push(new DictEntry('file your request there', 'uw verzoek daar in te dienen'));
      mDict.push(new DictEntry('h', 'h'));
      mDict.push(new DictEntry('If you click the OK-button, this page will close', 'Als u op de OK-' +
        'button klikt, wordt deze pagina gesloten'));
      mDict.push(new DictEntry('Insert row', 'Voeg rij in'));
      mDict.push(new DictEntry('Insert symbol', 'Voeg symbool in'));
      mDict.push(new DictEntry('is', 'is'));
      mDict.push(new DictEntry('is the best spot to', 'is de beste plek om'));
      mDict.push(new DictEntry('Move down', 'Verplaats omlaag'));
      mDict.push(new DictEntry('Move up', 'Verplaats omhoog'));
      mDict.push(new DictEntry('OK', 'OK'));
      mDict.push(new DictEntry('on', 'op'));
      mDict.push(new DictEntry('Publish', 'Publiseren'));
      mDict.push(new DictEntry('Questions', 'Vragen'));
      mDict.push(new DictEntry('Save and exit', 'Opslaan en sluiten'));
      mDict.push(new DictEntry('Service_Desk_Front_Page', 'Service_Balie_Start_Pagina'));
      mDict.push(new DictEntry('Something else', 'Iets anders'));
      mDict.push(new DictEntry('sorry', 'onze excuses'));
      mDict.push(new DictEntry('Special', 'Speciaal'));
      mDict.push(new DictEntry('start', 'start'));
      mDict.push(new DictEntry('technical problems', 'technische problemen'));
      mDict.push(new DictEntry('that', 'dat'));
      mDict.push(new DictEntry('Thank you for using', 'Dank u wel voor het gebruik van'));
      mDict.push(new DictEntry('The Board: "Service Balie, overige vragen"', 'Het Prikbord: "Serv' +
        'ice Balie, overige vragen"'));
      mDict.push(new DictEntry('the newly created page', 'de net gecreëerde pagina'));
      mDict.push(new DictEntry('the Service Desk Front Page', 'de Service Balie Start Pagina'));
      mDict.push(new DictEntry('this board', 'dit prikbord'));
      mDict.push(new DictEntry('This is the place to ask for help from other members of this wiki\'' +
        's community', 'Dit is de plek om hulp te vragen aan andere leden van deze wikigemeenschap'));
      mDict.push(new DictEntry('To', 'Om'));
      mDict.push(new DictEntry('To create a new Service Request, answer these questions', 'Om een S' +
        'ervice Verzoek in te dienen, beantwoord de volgende vragen'));
      mDict.push(new DictEntry('unavailable', 'niet beschikbaar'));
      mDict.push(new DictEntry('Welcome to the Service Desk', 'Welkom bij de Service Balie'));
      mDict.push(new DictEntry('What can we do for you', 'Wat kunnen we voor u doen'));
      mDict.push(new DictEntry('What shall be the name of the new page', 'Wat zal de naam van de ni' +
        'euwe pagina worden'));
      mDict.push(new DictEntry('Your request will be handled by the Service Desk Wizard', 'Uw verz' +
        'oek zal behandeld worden door de Service Desk Wizard'));
  This function returns the translation of the specified English word, phrase, sentence or text.  */
  function translate(English) {
    track.enter('Localization::translate("' + English + '")');
    var translation = "";
    if (mLanguage === 'en') {
      translation = English;
    } else {
      assert('translate01', true, mDict != null);
      //Punctuation markers are in Unicode sequence, for maintenance reasons only.
      var punctuationMarkers = '\t\n\r !"#$%&\'()*+,-./0123456789:;<=>?@[\\]^_`{|}~☐☑';
      var remainder = English;
      while (remainder.length > 0 && punctuationMarkers.indexOf(remainder[0]) >= 0) {
        translation += remainder[0];
        remainder = remainder.substr(1);
      while (remainder.length > 0) {
        var bestMatch = null;
        track.log('remainder: "' + remainder + '", remainder.length: ' + remainder.length + '.');
        for (var i = 0; i < mDict.length; ++i) {
          track.log('considering: "' + mDict[i].mEnglish + '", length: ' + mDict[i].mEnglish.length +
          if (mDict[i].mEnglish.length > remainder.length) {
            track.log('too long.');
          } else if (mDict[i].mEnglish.length < remainder.length) {
            if (remainder.substr(0, mDict[i].mEnglish.length) == mDict[i].mEnglish) {
              if (punctuationMarkers.indexOf(remainder[(mDict[i].mEnglish.length)]) >= 0) {
                if (bestMatch == null || bestMatch.mEnglish.length < mDict[i].mEnglish.length) {
                  bestMatch = mDict[i];
                  track.log('bestMatch.mEnglish: "' + bestMatch.mEnglish + '".');
              } else {
                track.log('next character "' + English[(mDict[i].mEnglish.length)] +
                  '" is not a punctuation marker.');
            } else {
          } else {
            if (remainder == mDict[i].mEnglish &&
              (!bestMatch || bestMatch.mEnglish.length < mDict[i].mEnglish.length)
            ) {
              bestMatch = mDict[i];
              track.log('bestMatch.mEnglish: "' + bestMatch.mEnglish + '".');
        if (bestMatch == null) {
          console.warn('No translation found for "' + remainder + '".');
          translation += remainder;
          remainder = '';
        } else {
          translation += bestMatch.mTranslation;
          remainder = remainder.substr(bestMatch.mEnglish.length);
          while (remainder.length > 0 && punctuationMarkers.indexOf(remainder[0]) >= 0) {
            translation += remainder[0];
            remainder = remainder.substr(1);
    return translation;
  /*Examples:*/ {
    assert('translate01', 'Antwoorden', translate('Answers'));
      'Vanwege technische problemen is dit prikbord niet beschikbaar, onze excuses.',
      translate('Due to technical problems this board is unavailable, sorry.'));
      'Uw verzoek zal behandeld worden door de Service Desk Wizard. Als u op de OK-button klikt, ' +
        'wordt deze pagina gesloten, en komt u terecht op de net gecreëerde pagina.',
      translate('Your request will be handled by the Service Desk Wizard. If you click the OK-but' +
        'ton, this page will close, and you\'ll land on the newly created page.'));
    assert('translate04', '☑ Iets anders.', translate('☑ Something else.'));
  } //Example of translate

  track.log('User: "' + mw.config.get('wgUserName') + '", language preference: "' + mLanguage +
} //Localization()
var localization = new Localization();


Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Around Wikia's network

Random Wiki