wok-current view emacs-pkg-text-translator/stuff/text-translator-vars.el @ rev 16864

up qupzilla-locales
author Xander Ziiryanoff <psychomaniak@xakep.ru>
date Sun Jul 13 07:46:17 2014 +0000 (2014-07-13)
parents
children
line source
1 ;;; text-translator-vars.el --- Text Translator
3 ;; Copyright (C) 2007-2010 khiker
5 ;; Author: khiker <khiker.mail+elisp@gmail.com>
6 ;; plus <MLB33828@nifty.com>
8 ;; This file is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; any later version.
13 ;; This file is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
23 ;;; Commentary:
25 ;; Variables for text-translator
27 ;;; Code:
29 (defconst text-translator-version "0.7.4"
30 "version numbers of this version of text-translator")
32 (defconst text-translator-buffer "*translated*"
33 "Buffer name that displays translation result.")
35 (defconst text-translator-mode-name "Translator"
36 "Major mode name for displaying to mode line.")
38 (defconst text-translator-work-buffer (concat " " text-translator-buffer)
39 "Output Buffer name from translation site.")
41 (defgroup text-translator nil
42 "Text Translator"
43 :tag "Text Translator"
44 :group 'text-translator)
46 (defcustom text-translator-prefix-key "\C-c"
47 "*Prefix key for text-translator commands."
48 :tag "Prefix Key of text-translator"
49 :type '(string :size 10)
50 :group 'text-translator)
52 (defcustom text-translator-auto-window-adjust t
53 "*Whether or not you adjust height of window displayed by dividing."
54 :type 'boolean
55 :group 'text-translator)
57 (defcustom text-translator-window-min-height 4
58 "*Specify minimum height of the translation result display buffer."
59 :type 'integer
60 :group 'text-translator)
62 (defcustom text-translator-leave-string nil
63 "*Whether or not you leave the character string before the translating."
64 :type 'boolean
65 :group 'text-translator)
67 (defcustom text-translator-pre-string-replace-alist
68 '(("+" . "+") ("&#8211;" . "-") ("&#8226;" . "・"))
69 "*Rule that converts character string that wants to translate."
70 :type '(repeat
71 (cons :tag "Rule"
72 (string :tag "Letter before the converting.")
73 (string :tag "Letter after the converting.")))
74 :group 'text-translator)
76 (defcustom text-translator-post-string-replace-alist
77 '(("\r" . "") ("&#39;" . "'") ("&quot;" . "\"")
78 ("&amp;" . "&") ("&lt;" . "<") ("&gt;" . ">") ("&#8211;" . "-")
79 ("&#264;" . "Ĉ") ("&#265;" . "ĉ") ("&#284;" . "Ĝ") ("&#285;" . "ĝ")
80 ("&#292;" . "Ĥ") ("&#293;" . "ĥ") ("&#308;" . "Ĵ") ("&#309;" . "ĵ")
81 ("&#348;" . "Ŝ") ("&#349;" . "ŝ") ("&#364;" . "Ŭ") ("&#365;" . "ŭ"))
82 "*Rule that converts character string after the translation."
83 :type '(repeat
84 (cons :tag "Rule"
85 (string :tag "Letter before the converting.")
86 (string :tag "Letter after the converting.")))
87 :group 'text-translator)
89 (defcustom text-translator-proxy-server
90 (let ((proxy (or (getenv "HTTP_PROXY") "")))
91 (and (string-match "^\\(http://\\)?\\(.+\\):\\([0-9]+\\)" proxy)
92 (match-string 2 proxy)))
93 "*Proxy server used."
94 :type '(choice (string :tag "specify proxy")
95 (const :tag "not use proxy" nil))
96 :group 'text-translator)
98 (defcustom text-translator-proxy-port
99 (let ((proxy (or (getenv "HTTP_PROXY") "")))
100 (or (and (string-match "^\\(http://\\)?\\(.+\\):\\([0-9]+\\)" proxy)
101 (string-to-number (match-string 3 proxy)))
102 8080))
103 "*Proxy port number used."
104 :type 'integer
105 :group 'text-translator)
107 (defcustom text-translator-proxy-user nil
108 "*Basic proxy authorization user name."
109 :type '(choice (string :tag "Basic proxy authorization user name")
110 (const :tag "Not use Basic proxy authorization" nil))
111 :group 'text-translator)
113 (defcustom text-translator-proxy-password nil
114 "*Basic proxy authorization password."
115 :type '(choice (string :tag "Basic proxy authorization password")
116 (const :tag "Not use Basic proxy authorization" nil))
117 :group 'text-translator)
119 (defcustom text-translator-site-data-template-alist
120 '(;; Google.com
121 ("google.com"
122 "translate.google.com"
123 "/ HTTP/1.1"
124 "js=n&prev=_t&hl=ja&ie=UTF-8&text=%s&file=&sl=%o&tl=%t"
125 utf-8-dos
126 (lambda ()
127 (text-translator-extract-tag-exclusion-string
128 "<span id=result_box[^>]*>\\(\\(<span [^>]*>\\([^<]\\|<br>\\)*</span>\\)+\\)</span>"))
129 (("en" . "ja") ("ja" . "en")
130 ("en" . "es") ("es" . "en")
131 ("en" . "fr") ("fr" . "en")
132 ("en" . "de") ("de" . "en")
133 ("en" . "it") ("it" . "en")
134 ("en" . "ar") ("ar" . "en")
135 ("de" . "fr") ("fr" . "de")
136 ("en" . "pt") ("pt" . "en")
137 ("en" . "ru") ("ru" . "en")
138 ("en" . "ko") ("ko" . "en")
139 ("en" . "zh-CN") ("zh-CN" . "en")
140 ("en" . "zh-TW") ("zh-TW" . "en")
141 ("zh-CN" . "zh-TW") ("zh-TW" . "zh-CN"))
142 (("zh-TW" . "tw") ("zh-CN" . "ch")))
144 ;; Yahoo.com
145 ("yahoo.com"
146 "babelfish.yahoo.com"
147 "/translate_txt HTTP/1.1"
148 "ei=UTF-8&doit=done&intl=1&tt=urltext&trtext=%s&lp=%o_%t&btnTrTxt=Translate"
149 utf-8
150 " <div id=\"result\"><div style=\"padding:0.6em;\">\\([^<]*\\)</div>"
151 (("en" . "ja") ("ja" . "en")
152 ("en" . "nl") ("nl" . "en")
153 ("en" . "fr") ("fr" . "en")
154 ("en" . "de") ("de" . "en")
155 ("en" . "el") ("el" . "en")
156 ("en" . "it") ("it" . "en")
157 ("en" . "ko") ("ko" . "en")
158 ("en" . "pt") ("pt" . "en")
159 ("en" . "ru") ("ru" . "en")
160 ("en" . "es") ("es" . "en")
161 ("nl" . "fr")
162 ("fr" . "de")
163 ("fr" . "el") ("el" . "fr")
164 ("fr" . "it") ("it" . "fr")
165 ("fr" . "pt") ("pt" . "fr")
166 ("fr" . "es") ("es" . "fr")
167 ("en" . "zh") ("zh" . "en")
168 ("en" . "zt") ("zt" . "en"))
169 (("zh" . "ch") ("zt" . "tw")))
171 ;; Freetranslation.com
172 ("freetranslation.com"
173 "ets.freetranslation.com"
174 "/ HTTP/1.1"
175 "sequence=core&mode=html&charset=UTF-8&template=results_en-us.htm&language=%o/%t&srctext=%s"
176 utf-8
177 "<textarea name=\"dsttext\" cols=\"40\" rows=\"6\" style=\"width:99%;height:142px;\" id=\"resultsBox\">\\([^<]*\\)</textarea>"
178 (("English" . "Spanish") ("Spanish" . "English")
179 ("English" . "French") ("French" . "English")
180 ("English" . "German") ("German" . "English")
181 ("English" . "Italian") ("Italian" . "English")
182 ("English" . "Dutch") ("Dutch" . "English")
183 ("English" . "Portuguese") ("Portuguese" . "English")
184 ("English" . "Norwegian"))
185 (("English" . "en") ("Spanish" . "es")
186 ("French" . "fr") ("German" . "de")
187 ("Italian" . "it") ("Dutch" . "nl")
188 ("Portuguese" . "pt") ("Norwegian" . "no")))
189 ("freetranslation.com"
190 "ets6.freetranslation.com"
191 "/ HTTP/1.1"
192 "sequence=core&mode=html&charset=UTF-8&template=results_en-us.htm&language=%o/%t&srctext=%s"
193 utf-8
194 "<textarea name=\"dsttext\" cols=\"40\" rows=\"6\" style=\"width:99%;height:142px;\" id=\"resultsBox\">\\([^<]*\\)</textarea>"
195 (("English" . "Russian") ("Russian" . "English")
196 ("English" . "SimplifiedChinese")
197 ("English" . "TraditionalChinese"))
198 (("English" . "en") ("Russian" . "ru")
199 ("SimplifiedChinese" . "ch") ("TraditionalChinese" . "tw")))
200 ("freetranslation.com"
201 "tets9.freetranslation.com"
202 "/ HTTP/1.1"
203 "sequence=core&mode=html&charset=UTF-8&template=results_en-us.htm&language=%o/%t&srctext=%s"
204 utf-8
205 "<textarea name=\"dsttext\" cols=\"40\" rows=\"6\" style=\"width:99%;height:142px;\" id=\"resultsBox\">\\([^<]*\\)</textarea>"
206 (("English" . "Japanese") ("Japanese" . "English"))
207 (("English" . "en") ("Japanese" . "ja")))
209 ;; Livedoor.com
210 ("livedoor.com"
211 "translate.livedoor.com"
212 "/ HTTP/1.1"
213 "clear_flg=1&src_text=%s&trns_type=%o,%t&sumit=翻訳"
214 utf-8
215 "<textarea name=\"tar_text\" cols=\"40\" rows=\"10\" wrap=\"physical\">\\([^<]*\\)</textarea>"
216 (("1" . "2") ("2" . "1")
217 ("2" . "9") ("9" . "2")
218 ("2" . "6") ("6" . "2"))
219 (("1" . "en") ("2" . "ja")
220 ("6" . "ch") ("9" . "ko")))
222 ;; Fresheye.com
223 ("fresheye.com"
224 "mt.fresheye.com"
225 "/ft_result.cgi HTTP/1.1"
226 "gen_text=%s&e=%o%t"
227 utf-8
228 "<TEXTAREA class=\"out-form\" name=\"gen_text2\" cols=\"25\" rows=\"15\">\\([^<]*\\)</TEXTAREA>"
229 (("E" . "J") ("J" . "E"))
230 (("E" . "en") ("J" . "ja")))
231 ("fresheye.com"
232 "mt.fresheye.com"
233 "/ft_cjresult.cgi HTTP/1.1"
234 "gen_text=%s&charset=gb2312&cjjc=%o%t"
235 utf-8
236 "<TEXTAREA class=\"out-form\" name=\"gen_text2\" cols=\"25\" rows=\"15\">\\([^<]*\\)</TEXTAREA>"
237 (("c" . "j") ("j" . "c") ("e" . "c"))
238 (("c" . "ch") ("j" . "ja") ("e" . "en")))
239 ("fresheye.com"
240 "mt.fresheye.com"
241 "/ft_cjresult.cgi HTTP/1.1"
242 "gen_text=%s&charset=big5&cjjc=%o%t"
243 utf-8
244 "<TEXTAREA class=\"out-form\" name=\"gen_text2\" cols=\"25\" rows=\"15\">\\([^<]*\\)</TEXTAREA>"
245 (("c" . "j") ("j" . "c") ("e" . "c"))
246 (("c" . "tw") ("j" . "ja") ("e" . "en")))
248 ;; Excite.co.jp
249 ("excite.co.jp"
250 "www.excite.co.jp"
251 "/world/english/ HTTP/1.1"
252 "wb_lp=%o%t&before=%s"
253 utf-8
254 "<textarea name=\"after\" id=\"after\">\\([^<]*\\)</textarea>"
255 (("EN" . "JA") ("JA" . "EN"))
256 (("EN" . "en") ("JA" . "ja")))
257 ("excite.co.jp"
258 "www.excite.co.jp"
259 "/world/chinese/ HTTP/1.1"
260 "wb_lp=%o%t&before=%s"
261 utf-8
262 "<textarea name=\"after\" id=\"after\">\\([^<]*\\)</textarea>"
263 (("JA" . "CH") ("CH" . "JA"))
264 (("JA" . "ja") ("CH" . "ch")))
265 ("excite.co.jp"
266 "www.excite.co.jp"
267 "/world/chinese/ HTTP/1.1"
268 "wb_lp=%o%t&big5=yes&before=%s"
269 utf-8
270 "<textarea name=\"after\" id=\"after\">\\([^<]*\\)</textarea>"
271 (("JA" . "CH") ("CH" . "JA"))
272 (("JA" . "ja") ("CH" . "tw")))
273 ("excite.co.jp"
274 "www.excite.co.jp"
275 "/world/korean/ HTTP/1.1"
276 "wb_lp=%o%t&before=%s"
277 utf-8
278 "<textarea name=\"after\" id=\"after\">\\([^<]*\\)</textarea>"
279 (("JA" . "KO") ("KO" . "JA"))
280 (("JA" . "ja") ("KO" . "ko")))
282 ;; Yahoo.co.jp
283 ("yahoo.co.jp"
284 "honyaku.yahoo.co.jp"
285 "/transtext HTTP/1.1"
286 "both=TH&text=%s&clearFlg=1&eid=CR-%o%t"
287 utf-8
288 "<textarea rows=12 cols=30 name=\"trn_text\" id=\"trn_textText\" class=\"smaller\">\\([^<]*\\)</textarea>"
289 (("E" . "J") ("J" . "E")
290 ("C" . "J") ("J" . "C-CN")
291 ("K" . "J") ("J" . "K"))
292 (("E" . "en") ("J" . "ja")
293 ("C" . "ch") ("C-CN" . "ch")
294 ("K" . "ko")))
296 ;; Ocn.ne.jp
297 ("ocn.ne.jp"
298 "cgi01.ocn.ne.jp"
299 "/cgi-bin/translation/index.cgi HTTP/1.1"
300 "langpair=%o%t&sourceText=%s"
301 utf-8
302 "<TEXTAREA NAME=\"responseText\" ROWS=\"5\" COLS=\"41\" WRAP=\"virtual\" CLASS=\"in2\">\\([^<]*\\)</TEXTAREA>"
303 (("en" . "ja") ("ja" . "en")
304 ("ja" . "ko") ("ko" . "ja")
305 ("ja" . "zh") ("zh" . "ja"))
306 (("zh" . "ch"))))
307 "The alist where setting of the site which is used for text translation is
308 described. To update site-data, evalute `text-translator-site-data-init`."
309 :type '(repeat
310 (list :tag "Web Site"
311 (string :tag "Web site name and translation type")
312 (string :tag "Host name")
313 (string :tag "POST path and HTTP version")
314 (string :tag "POST contents")
315 (symbol :tag "Character code")
316 (choice (string :tag "regexp") (symbol :tag "function"))
317 (list :tag (concat "The correspondence of translation-able "
318 "name (used by translation sites)"))
319 (list :tag (concat "The correspondence of name that used by "
320 "text-translator and name that used by "
321 "translation sites"))))
322 :group 'text-translator)
324 (defcustom text-translator-site-data-minimum-alist
325 '(;; lou5.jp (Japanese, Lou)
326 ("lou5.jp_*normal"
327 "lou5.jp"
328 "/ HTTP/1.1"
329 "v=1&text=%s"
330 utf-8
331 (lambda ()
332 (text-translator-extract-tag-exclusion-string
333 "<p class=\"large align-left box\">\\(\\(.\\|\n\\)*?\\)</p>"
334 t)))
335 ;; lou5.jp (Japanese, Lou Blog)
336 ("lou5.jp_*blog"
337 "lou5.jp"
338 "/ HTTP/1.1"
339 "v=2&text=%s"
340 utf-8
341 "<p class=\"large align-left box\">\\(\\(.\\|\n\\)*?\\)</p>")
343 ;; tatoeba.org (Furigana, romaji)
344 ("tatoeba.org_furigana"
345 "tatoeba.org"
346 "/eng/tools/romaji_furigana?query=%s&type=furigana HTTP/1.1"
347 nil
348 utf-8
349 "class=\"furigana\">\\(\\(.\\|\n\\)*?\\)</div><form id=\"ToolRomajiFuriganaForm")
350 ("tatoeba.org_romaji"
351 "tatoeba.org"
352 "/eng/tools/romaji_furigana?query=%s&type=romaji HTTP/1.1"
353 nil
354 utf-8
355 "class=\"furigana\">\\(\\(.\\|\n\\)*?\\)</div><form id=\"ToolRomajiFuriganaForm")
357 ;; traduku.net (Esperanto, English)
358 ("traduku.net_eoen"
359 "traduku.net"
360 "/cgi-bin/traduku HTTP/1.0"
361 "eo_en&t=%s"
362 utf-8
363 " id=\"rezulto\">\\(\\(.\\|\n\\)*?\\)</div>")
364 ("traduku.net_eneo"
365 "traduku.net"
366 "/cgi-bin/traduku HTTP/1.0"
367 "en_eo_trukilo&t=%s"
368 utf-8
369 " id=\"rezulto\">\\(\\(.\\|\n\\)*?\\)</div>"))
371 "*The alist where setting of the site which is used for text translation is
372 described. To update site-data, evalute `text-translator-site-data-init`."
373 :type '(repeat
374 (list :tag "Web Site"
375 (string :tag "Web site name and translation type")
376 (string :tag "Host name")
377 (string :tag "POST path and HTTP version")
378 (string :tag "POST contents")
379 (symbol :tag "Character code")
380 (choice (string :tag "regexp") (symbol :tag "function"))))
381 :group 'text-translator)
383 ;; text-translator-site-data-template-alist
384 ;; + text-translator-site-data-minimum-alist
385 ;; = text-translator-site-data-alist
386 (defvar text-translator-site-data-alist nil
387 "The alist where setting of the site which is used for text translation is
388 described.")
390 (defcustom text-translator-default-engine "google.com_enja"
391 "*Translation engine used by default."
392 :type (cons 'radio
393 (mapcar
394 (lambda (x)
395 (list 'const (car x)))
396 text-translator-site-data-alist))
397 :group 'text-translator)
399 (defcustom text-translator-user-agent
400 ;; "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4"
401 "Mozilla/5.0 (Windows; U; Windows NT 5.0; ja; rv:1.9) Gecko/2008052906 Firefox/3.0"
402 "*text-translator's User Agent. Default is Firefox."
403 :type 'string
404 :group 'text-translator)
406 (defcustom text-translator-mode-hook nil
407 "*Hook run at the end of function `text-translator-mode'."
408 :type 'hook
409 :group 'text-translator)
411 (defcustom text-translator-auto-selection-func nil
412 "*Value is function that select translation engine automatic.
413 this value is function for `text-translator-translate-by-auto-selection'."
414 :type 'symbol
415 :group 'text-translator)
417 (defcustom text-translator-display-popup nil
418 "*Non-nil means translated message is displayed by using popup-tip.
419 To use this option, you have to require popup.el.
420 popup.el URL: http://github.com/m2ym/auto-complete"
421 :type 'symbol
422 :group 'text-translator)
424 (defcustom text-translator-do-fill-region nil
425 "*Default is nil. if value is non-nil, it deletes
426 linefeed\\(and CR\\) from pre translation string(\"\\n\" -> \" \",
427 \"\r\" -> \"\"). and processing to straighten faces with
428 fill-paragraph after the translation. it is countermeasure
429 against the translation engines that processes per line."
430 :type 'symbol
431 :group 'text-translator)
433 (defcustom text-translator-space-division-languages
434 '("en" "es" "fr" "de" "it" "pt" "ru" "nl" "el" "no")
435 "*List of language that word is delimited by blank."
436 :type '(repeat (string :tag "language(2char)"))
437 :group 'text-translator)
439 (defvar text-translator-last-string ""
440 "The last time, character string which was thrown to the translation site.")
442 (defvar text-translator-engine-history nil
443 "The history of translation engine which you used.")
445 (defvar text-translator-search-regexp-or-func nil)
447 (defvar text-translator-sitedata-hash nil)
449 (provide 'text-translator-vars)
450 ;;; text-translator-vars.el ends here
452 ;; Local Variables:
453 ;; Coding: utf-8
454 ;; End: