‘Search with Google’ context menu extension for LO Writer?

Hey LibreOffice Folk,

If there’s one thing I miss from my OS X days it’s this: in the simple OS-bundled word processor TextEdit I could select text, right-click to bring up the context menu, and choose ‘Search with Google’ – TextEdit would then pass my text selection to the Safari web browser, which would display Google web search results for my text selection as a search query term, in a new tab.

I know that LibreOffice can open a website URL – such as https://www.google.co.uk – with a Ctrl-click on the hyperlinked text in a Writer document; on my new Win8.1 tablet, it seems the URL is handed over to the default application for https (in my case Firefox browser), and the linked website appears in a new Firefox tab. Very. Useful. Indeed! So my question is:

Q: Does a LibreOffice extension already exist that adds a TextEdit-like ‘Search with Google’ context menu item to Writer?

For instance, if I selected the word “elephant” while writing in a LibreOffice Writer file, I’d like to be able to right-click to bring up the context menu, then click on a new ‘Search with Google’ context menu item – this would then incorporate my text selection into a Google web search query URL (such as elephant - Google Suche ), pass the query URL to my default web browser, which would open a new tab and fill it with Google web search results for the search term “elephant”. Even. MORE. Useful!! Wouldn’t you agree?

Question is, does such a ‘Search with Google’ LibreOffice Writer extension already exist?

If yes – could you please point me in the right direction for me to acquire it. (BTW, I have tried searching for such an extension, but come up empty.)

If no – could I please invite a coding genius volunteer to write such a ‘Search with Google’ LibreOffice Writer extension to step forward?

I’m aware that there may well be a particular place in the LibreOffice community’s web presence where folk with appropriate LibreOffice coding genius expertise might best be recruited for such an extension-crafting task – so any pointers as to where that place may be would also be most gratefully received, too.

Thanks in advance for all your help,

Tim

My software:

  • LibreOffice 4.3.2.2 in English, Writer component
  • Windows 8.1 Pro 64-bit

[UPDATE #3]

Hey LibreOffice Folk,

Since I rate his Translator’s Tools extension for Writer so highly, I’ve chosen to put my money where my mouth is, and donated $10 to this wonderful extension’s developer Sergei Medvedev, via the project’s Donate link at SourceForge.

I’ve also emailed Sergei to ask if he could please make me a custom recompilation of the extension installer binary file, incorporating the ‘Search with Ecosia/OneLook/Google UK’ customisations mentioned in UPDATEs #1 + #2 below – as illustrated in this before-&-after maquette:

Here’s hoping that, before too long, I’ll not only be continuing to enjoy the delicious cake of Translator’s Tools websearch functionality, but also the icing on the cake of custom websearch menu items.

Warm regards,

Tim

PS: I’m also deriving wry entertainment from the way my karma score and badge count hereabouts keep on rising as a result of this thread’s expansion and popularity. I guess this is one example of the way in which the gamer culture staples of (1) an ever-rising score and (2) striving to attain achievement awards is coming to cross-fertilise net-mediated social discourse – and I for one really rather like it. { sappy grin }


[UPDATE #2]

Hi Miguel, and apologies for my previously assuming your name was Mario.

I like trying to be the change I want to see in the world, so paying forward a Very Useful Improvement in a way that may assist other folk seeking just such an improvement is my pleasure – and thank you for your appreciation.

Following your welcome suggestion, I’ve taken a look a the Translator’s Tools source code. I’ve identified the source of the four changes that I’d like to make, and prepared modified versions of the appropriate files:

  1. file: addon.xcu – modded to include menu item titles ‘Search with Ecosia’, ‘Search with OneLook’, and ‘Search with Google UK’
  2. subdirectory: icons, file: lookupdict1.png – modded to Ecosia favicon, 16 × 16 px
  3. subdirectory: icons, file: lookupdict2.png – modded to OneLook favicon, 16 × 16 px
  4. subdirectory: icons, file: lookupdict3.png – modded to Google UK favicon, 16 × 16 px

I’ve uploaded these four files to a DropBox called TranslatorsToolsMods, from where they can be accessed online:
» Dropbox - TranslatorsToolsMods - Simplify your life

However, having taken a look at the Extensions Development wiki page (» Extensions development - Apache OpenOffice Wiki ), it looks like I might be facing several hours of climbing a steep learning curve to understand how to incorporate these and the other Translator’s Tools source files into a recompiled translatortools_1.02_eog.oxt extension installer binary file (which seems rather disproportionate to me).

So I’ll be asking Translator’s Tools maintainer Sergei Medvedev if he could please do this modified recompilation for me; and if yourself or any other readers have sufficient OOo/LibreOffice extension development skills that such a modified recompilation would be an easy favour which you could offer me, I’d be most grateful for such assistance.

Warm regards,

Tim


[UPDATE #1]

Hi Mario,

Thank you very much indeed for your suggestion of the…

• Translator’s Tools extension
» http://extensions.services.openoffice.org/en/project/translators-tools

…which – with a little tweaking – has led to not only the addition of my desired ‘Search with Google’ functionality, but also to adding ‘Search with Ecosia’, ‘Search with OneLook’, AND ‘Google Translate’ functionality too: RESULT! In order to help other LibreOffice Writer users, such as Greektranslation, get similar results, here’s my brief guide to said tweaking.

The Translator’s Tools extension adds a new menu of the same name to the LibreOffice menu bar:


The new Translator’s Tools menu

A click on ‘Settings’ opens translators-tools-ini.txt for writing in Writer. Since it’s designed to be human readable, it’s fairly easy to see that it defines which are the ‘Dict 1’, ‘Dict 2’, and ‘Dict 3’ of the new Translator’s Tools menu; in fact it contains 10 dictionary settings, including ‘Google define:’ as #7. So I discovered the appropriate search URLs for green search engine Ecosia, dictionary metasearch engine OneLook, and Google UK, then tweaked the top three Dict definitions as follows:

[Section 1. Online Dictionaries]
[Section 1.1 Dictionary 1]
OnlineDictionary01=https://www.ecosia.org/search?q=
SearchForWholeSentences1=False
UseQuotationMarks1=False

[Section 1.2 Dictionary 2]
OnlineDictionary02=http://www.onelook.com/?w=
SearchForWholeSentences2=False
UseQuotationMarks2=False

[Section 1.3 Dictionary 3]
OnlineDictionary03=http://www.google.co.uk/search?q=
SearchForWholeSentences3=False
UseQuotationMarks3=False

After saving the tweaked translators-tools-ini.txt file and restarting Writer, I can now select a word or phrase in a Writer document and use the selected text as search query term at Ecosia, OneLook, Google UK, and Google Translate – which is even better than I asked for!

The icing on the cake would be discovering how to modify my new Translator’s Tools menu:

  1. to change ‘Lookup Dict 1’ to ‘Search with Ecosia’
  2. to change ‘Lookup Dict 2’ to ‘Search with OneLook’
  3. to change ‘Lookup Dict 3’ to ‘Search with Google UK’
  4. to include the favicon images of Ecosia, OneLook, and Google UK

But the usual route of Tools menu > Customise… > Menus tab > ‘Menu’ pull-down menu doesn’t show my new Translator’s Tools menu. Can anybody please give me a pointer as to how to make these changes? (BTW, I’ll be asking this of the coder of Translator’s Tools, Sergei Medvedev, too.)

Many thanks,

Tim


[PREVIOUSLY…]

I now see I’m not the first person hereabouts to be after adding such a ‘Search with Google’ functionality to LibreOffice Writer:

Select current word in Writer and lookup in Google

I want to have a macro so that when the cursor is in a word, it will
select the word and look it up in
Google (using system default browser).
When a word or phrase is already
selected, then it will look up in
Google straight away after trimming
whitespace before and after. The macro
should work with any language script,
not just Latin characters.”

~ Greektranslation, asked 02 Oct
2013 »
Select current word in Writer and lookup in Google

Here’s hoping that the Ask.LibreOffice.org community have become more helpful over the last year, since I note that Greektranslation’s question has remained unanswered.

1 Like

Look if this extension can help translators-tools, from Aoo extensions, seems it works with 4.3.3, but when installing, do it [Only for me], installing for all hangs the installation.

Hi Mario,

Thank you very much indeed for your suggestion of the…

• Translator’s Tools extension
» http://extensions.services.openoffice.org/en/project/translators-tools

…which – with a little tweaking – has led to not only the addition of my desired ‘Search with Google’ functionality, but also to adding ‘Search with Ecosia’, ‘Search with OneLook’, AND ‘Google Translate’ functionality too: RESULT!

Thanks you for a such detailed explanation on how to tweak the configuration file. In download page there is the link to source code, and in tutorial-on-extension-writing there is information about create an extension, if you feel able to do it. Sorry, I can’t help with that.
Miguel Ángel.

Hi Miguel, and apologies for assuming your name was Mario. Thanks for your encouraging response – please see [UPDATE #2] at the top of my answer for details of where your encouragement has led me. Warm regards, Tim

1 Like

Please don’t worry, easy with my user name. As I have said I can’t help with the extension. Seems a right step contact with the maintainer.

1 Like

Cheers, Miguel – I’ve both donated to and emailed Translator’s Tools extension developer Sergei Medvedev, in the hope of acquiring the ‘Search with Ecosia/OneLook/Google UK’ customisations mentioned in UPDATEs #1 + #2 (see UPDATE #3 for a new before-&-after illustration).

1 Like