User:Strepon

From The Document Foundation Wiki
Jump to: navigation, search

Bookmarklet for translating in Pootle

Link to Help page for currently translated string

Example: used for this Pootle string, it returns this Help page.

javascript:(function(){%20var%20wrappers%20=%20document.getElementsByClassName("content-wrapper");%20var%20path%20=%20"";%20for%20(var%20w%20=%200;%20w%20<%20wrappers.length;%20w++)%20{%20if%20(wrappers[w].innerText.substring(0,%2011)%20===%20"LibreOffice")%20{%20path%20=%20wrappers[w%20+%201].innerText;%20break;%20}%20}%20path%20=%20path.replace(".po",%20"");%20var%20file%20=%20document.getElementsByClassName("translate-locations")[0].innerText;%20file%20=%20file.split(".")[0];%20var%20url%20=%20"https://helponline.libreoffice.org/6.0/cs/text/"%20+%20path%20+%20"/"%20+%20file%20+%20".html";%20window.prompt("Copy%20to%20clipboard:%20Ctrl+C,%20Enter",%20url);%20return%20undefined;%20})();

Replace 6.0/cs by your required version/language.

Making it work:

  1. In your browser, create a new bookmark.
  2. Put the JavaScript above as its address, add a keyword (e.g. "pohelp").
  3. At a Pootle page, type the keyword ("pohelp") to the address bar and press Enter – a dialog window with a URL to be copied will appear.