Highlighted

Localisation problem

Advocate ,
Jul 11, 2017

Copy link to clipboard

Copied

Friends and experts,

On my English Win7-x64 with FrameMaker 14.0.2.425 (en) I have this very simple script, which I also tested on the machine of my wife (Win7-x32, German) with the German version of FM 14.0.2.425:

/* ETBtest.jsx
   To be placed in Startup folder of user area */
#target framemaker

alert ("Testing $.locale= " + $.locale);
var gsETBtest_title = { en: "Testing a jsx script in %apdata%\...\FrameMaker\vv\Startup [ETB]",
                        de: "Test eines jsx scripts in %apdata%\...\FrameMaker\vv\Startup[ETB]"
                      };
var gsETBtest_msg   = { en: "Befor You test your own script, rename this script to ETBtest-ori.jsx"
                          + "\n• Name Your script ETBtest.jsx"
                          + "\n• You can now invoke it from the ETB tool-bar Extra (last icon)."
                          + "\n\nAfter your tests please rename ETBtest-ori.jsx back to ETBtest.jsx",
                        de: "Vor dem test Ihres scripts bitte dieses script auf ETBtest-ori.jsx umbenennen"
                          + "\n• Benennen Sie ihr script ETBtest.jsx"
                          + "\n• Nun kann ihr script von der ETB tool-bar Extra (letztes icon) aufgerufen werden."
                          + "\n\nNach den tests bitte ETBtest-ori.jsx zurück benennen auf ETBtest.jsx"
                      };
var gsETBtest_NoDoc = { en: "No book or document active",
                        de: "Kein buch oder dokument aktiv"
                      };

SetUpMenu();                                      // out-comment for debugging

function SetUpMenu() { // =========================================================================
// This function MUST NOT be named DefineMenu - because this is a reserved function!
// Errors in ESTK: Menu position can not be changed - see bug report FRMAKER-2752
// No menu is defined here - it is set up in customui.cfg / menus.cfg
  var cmdDoc = DefineCommand (1, "ETBtest", "Test a script [ETB]", "");
  UpdateMenus();
} // --- end SetUpMenu

function Command(cmd) { // ========================================================================
    switch(cmd)  {                                    // Respond to menu command.
        case 1:
      WhatIsToDo();
      break;
    }
} // --- end Command

function WhatIsToDo () { // === This is what the test script will do ===============================
  alert (localize(gsETBtest_msg), localize(gsETBtest_title));
  return;
}

On my English system/FM the alert reports

  Script Alert
  Testing $.locale= 2

and the invoked script (by button) reports the en message from the gsETBtest_msg object.

On the German system/FM the alert reports

  Script Fehler
  Testing $.locale= 3

and the invoked script (by button) reports the en message from the gsETBtest_msg object.

I get the German 'reaction' of the script only if I insert on the top of the script - which of course is not very useful for a bi-lingual script:

  $.locale = "de";

What goes wrong here?

The method is described in JavaScript Tools Guide of CS5.

By the way: changing the order of the string declarations (have de first, en second) has no effect on both systems.

The solution with the automatic localisation is not bullet proof:

My system is in English (Windows, FM and all apps which provide this UI language). The input language (keyboard) is de-CH) which will trigger German in the scrips. Hence I need  a longer way - a function to switch the UI language:

function SwitchLanguage () {; // === Switch language according to application language ============
  switch (app.Language) {
    case Constants.FV_LANG_BRITISH:
    case Constants.FV_LANG_ENGLISH: {
      $.locale = "en"; break;
    }
    case Constants.FV_LANG_CANADIAN_FRENCH:
    case Constants.FV_LANG_FRENCH: {
      $.locale = "fr"; break;
    }
    case Constants.FV_LANG_GERMAN:
    case Constants.FV_LANG_NEW_GERMAN:
    case Constants.FV_LANG_NEW_SWISS_GERMAN:   
    case Constants.FV_LANG_SWISS_GERMAN:    {
      $.locale = "de"; break;
    }
    default: {
      $.locale = "en"; break;
    }
  }
} // --- end SwitchLanguage

TOPICS
Scripting

Views

199

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Localisation problem

Advocate ,
Jul 11, 2017

Copy link to clipboard

Copied

Friends and experts,

On my English Win7-x64 with FrameMaker 14.0.2.425 (en) I have this very simple script, which I also tested on the machine of my wife (Win7-x32, German) with the German version of FM 14.0.2.425:

/* ETBtest.jsx
   To be placed in Startup folder of user area */
#target framemaker

alert ("Testing $.locale= " + $.locale);
var gsETBtest_title = { en: "Testing a jsx script in %apdata%\...\FrameMaker\vv\Startup [ETB]",
                        de: "Test eines jsx scripts in %apdata%\...\FrameMaker\vv\Startup[ETB]"
                      };
var gsETBtest_msg   = { en: "Befor You test your own script, rename this script to ETBtest-ori.jsx"
                          + "\n• Name Your script ETBtest.jsx"
                          + "\n• You can now invoke it from the ETB tool-bar Extra (last icon)."
                          + "\n\nAfter your tests please rename ETBtest-ori.jsx back to ETBtest.jsx",
                        de: "Vor dem test Ihres scripts bitte dieses script auf ETBtest-ori.jsx umbenennen"
                          + "\n• Benennen Sie ihr script ETBtest.jsx"
                          + "\n• Nun kann ihr script von der ETB tool-bar Extra (letztes icon) aufgerufen werden."
                          + "\n\nNach den tests bitte ETBtest-ori.jsx zurück benennen auf ETBtest.jsx"
                      };
var gsETBtest_NoDoc = { en: "No book or document active",
                        de: "Kein buch oder dokument aktiv"
                      };

SetUpMenu();                                      // out-comment for debugging

function SetUpMenu() { // =========================================================================
// This function MUST NOT be named DefineMenu - because this is a reserved function!
// Errors in ESTK: Menu position can not be changed - see bug report FRMAKER-2752
// No menu is defined here - it is set up in customui.cfg / menus.cfg
  var cmdDoc = DefineCommand (1, "ETBtest", "Test a script [ETB]", "");
  UpdateMenus();
} // --- end SetUpMenu

function Command(cmd) { // ========================================================================
    switch(cmd)  {                                    // Respond to menu command.
        case 1:
      WhatIsToDo();
      break;
    }
} // --- end Command

function WhatIsToDo () { // === This is what the test script will do ===============================
  alert (localize(gsETBtest_msg), localize(gsETBtest_title));
  return;
}

On my English system/FM the alert reports

  Script Alert
  Testing $.locale= 2

and the invoked script (by button) reports the en message from the gsETBtest_msg object.

On the German system/FM the alert reports

  Script Fehler
  Testing $.locale= 3

and the invoked script (by button) reports the en message from the gsETBtest_msg object.

I get the German 'reaction' of the script only if I insert on the top of the script - which of course is not very useful for a bi-lingual script:

  $.locale = "de";

What goes wrong here?

The method is described in JavaScript Tools Guide of CS5.

By the way: changing the order of the string declarations (have de first, en second) has no effect on both systems.

The solution with the automatic localisation is not bullet proof:

My system is in English (Windows, FM and all apps which provide this UI language). The input language (keyboard) is de-CH) which will trigger German in the scrips. Hence I need  a longer way - a function to switch the UI language:

function SwitchLanguage () {; // === Switch language according to application language ============
  switch (app.Language) {
    case Constants.FV_LANG_BRITISH:
    case Constants.FV_LANG_ENGLISH: {
      $.locale = "en"; break;
    }
    case Constants.FV_LANG_CANADIAN_FRENCH:
    case Constants.FV_LANG_FRENCH: {
      $.locale = "fr"; break;
    }
    case Constants.FV_LANG_GERMAN:
    case Constants.FV_LANG_NEW_GERMAN:
    case Constants.FV_LANG_NEW_SWISS_GERMAN:   
    case Constants.FV_LANG_SWISS_GERMAN:    {
      $.locale = "de"; break;
    }
    default: {
      $.locale = "en"; break;
    }
  }
} // --- end SwitchLanguage

TOPICS
Scripting

Views

200

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 11, 2017 0
Advocate ,
Jul 11, 2017

Copy link to clipboard

Copied

Well, most likely the cause is the missing ESTK tool kit - which is not contained in TCS7. Hence I could not install it on the German system.

Since only used for a test period I will install it from TCS6 and look further.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 11, 2017 0
Advocate ,
Jul 11, 2017

Copy link to clipboard

Copied

The installation of ESTK 3.5 (which is free and not a cloud stuff) did only help in one point: in FM File > Scripts > New Script opens ESTK.

However, the script still does not automatically adapt to the language of the application FM. So I introduce the script with this:

$.locale = app.Language;    // 2: en; 3: de, 4: fr
if ($.locale = 3) {
    $.locale= "de";
}

or with forcing the automatic localisation by

$.localize = true;

The necessity of this is - however - not clear from the documentation (JavaScript Tools Guide of CS5) which states on page 104:

The localize function always performs its translation, regardless of the setting of the $.localize
variable. For example:
//Only works if the $.localize=true
   b1 = w.add ("button", undefined, btnText);
//Always works, regardless of $.localize value
   b1 = w.add ("button", undefined, localize (btnText));

This "Regardless of the setting of the $.localize variable" is simply wrong.

Klaus

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 11, 2017 0
Advocate ,
Jul 12, 2017

Copy link to clipboard

Copied

The solution with the automatic localisation is not bullet proof:

My system is in English (Windows, FM and all apps which provide this UI language). The input language (keyboard) is de-CH) which will trigger German in the scrips. Hence I need  a longer way - a function to switch the UI language:

function SwitchLanguage () {; // === Switch language according to application language ============
  switch (app.Language) {
    case Constants.FV_LANG_BRITISH:
    case Constants.FV_LANG_ENGLISH: {
      $.locale = "en"; break;
    }
    case Constants.FV_LANG_CANADIAN_FRENCH:
    case Constants.FV_LANG_FRENCH: {
      $.locale = "fr"; break;
    }
    case Constants.FV_LANG_GERMAN:
    case Constants.FV_LANG_NEW_GERMAN:
    case Constants.FV_LANG_NEW_SWISS_GERMAN:   
    case Constants.FV_LANG_SWISS_GERMAN:    {
      $.locale = "de"; break;
    }
    default: {
      $.locale = "en"; break;
    }
  }
} // --- end SwitchLanguage

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 12, 2017 0