MozillaZine

keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
morat
 
Posts: 3673
Joined: February 3rd, 2009, 6:29 pm

Post Posted March 23rd, 2020, 8:05 am

You're welcome.

bege
 
Posts: 125
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted March 23rd, 2020, 3:35 pm

Hello,
I want to switch the current dictionary in the compose window of Thunderbird 68. The codes I found in this thread switch the preference (to be seen in about:config) but don't switch the dictionary in the current compose window.
Can someone help with a code to select a certain dictionary (eg. en-US, en-GB, de-DE ...) that works in Thunderbird 68?

morat
 
Posts: 3673
Joined: February 3rd, 2009, 6:29 pm

Post Posted March 25th, 2020, 6:21 pm

@bege

Try this:

* toggle between two languages in compose window

Code: Select all
(function () {
  var lang = document.documentElement.getAttribute("lang");
  if (lang == "en-US") {
    ComposeChangeLanguage("de-DE");
  } else if (lang == "de-DE") {
    ComposeChangeLanguage("en-US");
  }
})();

German Dictionary (de-DE)
http://addons.thunderbird.net/thunderbird/addon/3077

Use another else if statement if you want to toggle between three languages.

P.S.

You can find the ComposeChangeLanguage function using the Developer Toolbox. (same as Browser Toolbox in Firefox)

More info: viewtopic.php?f=23&t=3034448

Select the messengercompose.xul file. (picture)

Find the label="English (United States)" toolbarbutton in the inspector.

Code: Select all
<toolbarbutton xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  id="languageStatusButton"
  tooltiptext="Spellcheck language"
  oncommand="showPopupById('languageMenuList','languageStatusButton', before_start');"
  label="English (United States)"/>

Find the id="languageMenuList" menupopup in the inspector.

Code: Select all
<menupopup xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  id="languageMenuList"
  oncommand="ChangeLanguage(event);"
  onpopupshowing="OnShowDictionaryMenu(event.target);"
  hasbeenopened="true">...</menupopup>

Examine the ChangeLanguage function in the console to get the definition.

Code: Select all
function ChangeLanguage(event) {
  ComposeChangeLanguage(event.target.value);
  event.stopPropagation();
}

bege
 
Posts: 125
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted March 26th, 2020, 9:50 am

@morat
Thank you very much, works perfect.
And thank you for the explanation how to find it out. I am familiar with the browser toolbox and have come until languageMenuList but then I didn't know how to continue.
How can I examine the function in the console? What exactly must I enter into the console? How to find ComposeChangeLanguage?
And I didn't know about document.documentElement.getAttribute("lang").
I am afraid I have to ask again in a similar case.

morat
 
Posts: 3673
Joined: February 3rd, 2009, 6:29 pm

Post Posted March 26th, 2020, 11:23 am

You can find the id="languageMenuList" menupopup by searching for a css selector in the "Search HTML" textbox in the inspector.

e.g. #languageMenuList

You can use the "Jump to definition" icon in the console after you type "ChangeLanguage" and press enter.

Image

If you get a "ChangeLanguage is not defined" error, then you are likely in the 3pane window, not the compose window.

3pane window i.e. chrome://messenger/content/messenger.xul
compose window i.e. chrome://messenger/content/messengercompose/messengercompose.xul

Targeting a document
http://developer.mozilla.org/docs/Tools/Browser_Toolbox#Targeting_a_document

The lang attribute code snippet is in the ComposeChangeLanguage function.

bege
 
Posts: 125
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted March 26th, 2020, 11:54 am

@morat
Thank you. =D>
This time I could follow, but I am not sure whether I can transform that for my next question. I will try and see and hope you are there if I fail :-k

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 1 guest