manzyuk / google-translate

Obsolete, see https://github.com/atykhonov/google-translate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

language ordering (abbrv ?)

drzraf opened this issue · comments

language's order is neutral, but confusing as one can't use iso 3166 codes as "es".
Eg: nor "es" or "espanol" would match "spanish", but "es" would match "estonian".
Someone translating probably knows codes.
workaround : reorder languages.

--- google-translate.el.1   2013-11-07 22:40:14.000000000 +0100
+++ google-translate.el 2013-11-07 22:43:50.000000000 +0100
@@ -149,7 +149,14 @@
 (eval-when-compile (require 'cl))

 (defvar google-translate-supported-languages-alist
-  '(("Afrikaans"           . "af")
+  '(("English"             . "en")
+    ("Spanish"             . "es")
+    ("Espanol"             . "es")
+    ("Chinese Simplified"  . "zh-CN")
+    ("Chinese Traditional" . "zh-TW")
+    ("German"              . "de")
+    ("French"              . "fr")
+    ("Afrikaans"           . "af")
     ("Albanian"            . "sq")
     ("Arabic"              . "ar")
     ("Armenian"            . "hy")
@@ -158,20 +165,15 @@
     ("Belarusian"          . "be")
     ("Bengali"             . "bn")
     ("Bulgarian"           . "bg")
-    ("Chinese Simplified"  . "zh-CN")
-    ("Chinese Traditional" . "zh-TW")
     ("Croatian"            . "hr")
     ("Czech"               . "cs")
     ("Danish"              . "da")
     ("Dutch"               . "nl")
-    ("English"             . "en")
     ("Estonian"            . "et")
     ("Filipino"            . "tl")
     ("Finnish"             . "fi")
-    ("French"              . "fr")
     ("Galician"            . "gl")
     ("Georgian"            . "ka")
-    ("German"              . "de")
     ("Greek"               . "el")
     ("Gujarati"            . "gu")
     ("Haitian Creole"      . "ht")

I'm somewhat reluctant to apply this patch because it really feels like a customization.

To support this idea, I chose not to cache the list of names of supported languages in a variable but recompute it every time it is needed. This way, you can customize google-translate-supported-languages-alist however you like (reorder it, add aliases for languages etc.) and have your changes reflected in the list of language names offered for completion at the interactive prompt.

Added this to my .emacs did the trick

(eval-after-load "google-translate" '
  (progn
    (setq google-translate-supported-languages-alist (delete '("Estonian". "et")  google-translate-supported-languages-alist))
    (setq google-translate-supported-languages-alist (add-to-list 'google-translate-supported-languages-alist '("Espanol" . "es")))
    ))

thx