8

My Ubuntu system is installed with the Italian language so, when I search with the Dash, I obtain the results from the Italian version of Wikipedia. But let's say I need more information on my topic, and I know that the English version of Wikipedia is more comprehensive.

How can I obtain from the Dash the results from the English Wikipedia instead of the Italian one?

Vosaxalo
  • 703
  • In older version of some lens (Ubuntu versions prior to 14.04), it was possible to set the language with the appropriate code before the terms to search. For example if I wanted to search "Linux" in French, I could type "!fr Linux", for German "!de Linux", and so on. Now with Ubuntu 14.04 this syntax doesn't work anymore. – Vosaxalo May 08 '14 at 19:57

3 Answers3

1

In the Terminal, type:

gksu gedit /usr/share/libtranslate/services.xml

List item

In the file, make this line of code bold in the google section of the gedit file.

<language to="it" tag="en"/> `

When I looked in gedit, the language you want to change looks like this "*", so you still need to change that part to "it", but the rest is done for you.

After this, restart language translator from the dash. After you have done this, resart gnome-translate. Next, try it out with this code: echo"Hope this helps. Good luck." | translate-bin -s google -f it -t en.

amc
  • 7,142
BJsgoodlife
  • 1,160
  • 5
  • 31
  • 59
  • Hi, I'm not sure that I have correctly understood your advice. On my system I have already installed the English language (mandatory), and the Italian language (this is the active language for my desktop). If I search with the Dash, the results come from the italian Wikipedia because this is the active language on my desktop. If you suggest to set temporarily the English language, just to do a single search in the Dash, this is not a very comfortable solution. I don't want to change all my desktop interface just to search in the Dash in another language. – Vosaxalo May 12 '14 at 16:55
  • @Vosaxalo,Ok maybe you are right. I will contintue to try and research the topic, and let you know if I find anything. – BJsgoodlife May 12 '14 at 23:06
  • You wouldn't need to fully change the language, it is looking for the language from the LC_MESSAGES within the code, otherwise it would work like this. I wish I had read your post and link prior. – No Time May 17 '14 at 03:46
1

I am unsure how deep you want to delve into this, but I'll give it a shot at an answer.

It seems a quick and dirty way to change the search would be change the messages locale temporarily.

From terminal (before using lens, and while it is up):

LC_MESSAGES=en_US.UTF-8

Close the terminal and it should go back to your default.

Or before the application(if you want to run the lens from command line I guess).

I have looked at the source code for the '__ init __.py' for the actual lens (it was written in python) there are two lines, which check your locale messages, they get it from the system, but I am unsure what you would need to change to get it to be set to multi languages.It is grabbing the locale to determine which wikipedia (en,fr,de,it, etc.) to search.

More stuff below, which may be helpful

(from the '__ init __.py' in the lens package)


locale.setlocale(locale.LC_MESSAGES, '') loc = locale.getlocale(locale.LC_MESSAGES)[0].split("_")[0]

(line 28 and 29)


wiki= http://%s.wikipedia.org % (loc)

(line 31)


(Explanation of code: the locale is being checked from LC_MESSAGES on system, it is being put into a variable called (loc), which is then split to grab the first portion of the language code (something like 'en_US.UTF-8') for English the result would be 'en', French 'fr', etc. It then takes this variable, and puts it into the %s in the wiki variable before the .wikipedia.org)

It seems like the developer of the lens was probably the person who wrote this entry in the developer section. (the code looks the same)

If you wanted to hard code a language in, it looks like you could do that as well.

You could make a custom lens for Wikipedia and change the locale (or have multiple locales if you wanted to program it in somehow)

http://developer.ubuntu.com/2012/04/how-to-create-a-wikipedia-unity-lens-for-ubuntu/

You will then need to restart for these changes to take effect.

Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172
No Time
  • 1,073
  • 11
  • 25
  • Thank you for your explanation. I have tried to set LC_MESSAGES in a terminal. Then, keeping the terminal open, I have made a search with the Dash, but it's not working. I still have the results from the Italian Wikipedia. – Vosaxalo May 17 '14 at 11:43
  • Moreover, the wikipedia's scope is only an example, but I was searching a "global" solution to change temporarily the language in the Dash. And, diving in the code is not a "user friendly" solution. At this point I suppose that a real solution doesn't exist, and perhaps this can be a new functionality for the Unity Dash in the future. Thank you all. – Vosaxalo May 17 '14 at 11:52
1

Just an idea: add Wikipedia (en) in firefox's list of search engines: go to https://en.wikipedia.org/wiki/Main_Page then click the small arrow in the search engines drop list and choose Add "Wikipedia (en)".
Sorry this answer may only expand searches to Wikipedia (en) only, not to all English sources. If it works you could add the same way any other localized search engine you'd like.

Further more I believe you need to have the ubuntu firefox plugin(s) installed and activated. Not sure at all as I disable/remove all that unity lenses web integration stuff.

useful
  • 1,834
  • 4
  • 25
  • 32