calavera / gm-pootle-search

Greasemonkey script that searchs a selected sentence from a web page into a pootle server

This URL has Read+Write access

david (author)
Tue Aug 26 04:57:59 -0700 2008
gm-pootle-search / pootleSearch.user.js
100644 34 lines (29 sloc) 0.936 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// ==UserScript==
// @name pootleSearch
// @namespace http://localhost
// @description search sentences in pootle
// @include http://localhost/*
// ==/UserScript==
 
var pootleProjectName = "pootle"; //the name of the pootle project goes here
var pootleUrl = "http://localhost:5005/{lang}/" + pootleProjectName + "/translate.html?searchtext="; //pootle server url
 
pootleSearch = function(lang) {
  if (document.getSelection()) {
    window.open(pootleUrl.replace('{lang}', lang) + document.getSelection());
  }
};
 
//languages' array
langs = [
  en = {
    key: 'e',
    label: 'english version',
    func: function() { pootleSearch('en'); }
  },
  ca = {
    key: 'c',
    label: 'catalonian version',
    func: function() { pootleSearch('ca'); }
  }
];
 
for (l in langs) {
  GM_registerMenuCommand("Search sentence in pootle, " + langs[l].label, langs[l].func, langs[l].key, "control alt", langs[l].key);
}