Skip to content

Commit

Permalink
Use a more sane way of treating the language/isocode alist
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-mueller committed Jan 29, 2021
1 parent b208476 commit affb99e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 65 deletions.
121 changes: 60 additions & 61 deletions company-wordfreq.el
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,11 @@ introduce latency to the completion proposals."

(defun company-wordfreq--proposal-list ()
"Get the friendly names of the languages."
(mapcar (lambda (elt) (car (cdr elt))) company-wordfreq--language-alist))
(mapcar 'car company-wordfreq--language-alist))

(defun company-wordfreq--iso-code (language)
"Get the iso code of LANGUAGE"
(car (seq-find (lambda (elt) (equal (car (cdr elt)) language))
company-wordfreq--language-alist)))
(cdr (assoc language company-wordfreq--language-alist)))

(defconst company-wordfreq--frequency-word-url-prefix
"https://raw.githubusercontent.com/johannes-mueller/FrequencyWords/master/content/2018/")
Expand Down Expand Up @@ -222,64 +221,64 @@ Consider filing an issue"))
(setq company-wordfreq--word-list-buffer nil)))

(defconst company-wordfreq--language-alist
'(("af" "afrikaans")
("ar" "arabic")
("bg" "bulgarian")
("bn" "bengali")
("br" "breton")
("bs" "bosnian")
("ca" "catalan")
("cs" "czech")
("da" "danish")
("de" "german")
("el" "greek")
("en" "english")
("eo" "esperanto")
("es" "spanish")
("et" "estonian")
("eu" "basque")
("fa" "persian")
("fi" "finnish")
("fr" "french")
("gl" "galician")
("he" "hebrew")
("hi" "hindi")
("hr" "croatian")
("hu" "hungarian")
("hy" "armenian")
("id" "indonesian")
("is" "icelandic")
("it" "italian")
("ja" "japanese")
("ka" "georgian")
("kk" "kazakh")
("ko" "korean")
("lt" "lithuanian")
("lv" "latvian")
("mk" "macedonian")
("ml" "malayalam")
("ms" "malay")
("nl" "dutch")
("no" "norwegian")
("pl" "polish")
("pt" "portuguese")
("pt_br" "brasileiro")
("ro" "romanian")
("ru" "russian")
("si" "sinhala")
("sk" "slovak")
("sl" "slovenian")
("sq" "albanian")
("sr" "serbian")
("sv" "swedish")
("ta" "tamil")
("te" "telugu")
("th" "thai")
("tl" "tagalog")
("tr" "turkish")
("uk" "ukrainian")
("ur" "urdu")
("vi" "vietnamese")))
'(("afrikaans" . "af")
("arabic" . "ar")
("bulgarian" . "bg")
("bengali" . "bn")
("breton" . "br")
("bosnian" . "bs")
("catalan" . "ca")
("czech" . "cs")
("danish" . "da")
("german" . "de")
("greek" . "el")
("english" . "en")
("esperanto" . "eo")
("spanish" . "es")
("estonian" . "et")
("basque" . "eu")
("persian" . "fa")
("finnish" . "fi")
("french" . "fr")
("galician" . "gl")
("hebrew" . "he")
("hindi" . "hi")
("croatian" . "hr")
("hungarian" . "hu")
("armenian" . "hy")
("indonesian" . "id")
("icelandic" . "is")
("italian" . "it")
("japanese" . "ja")
("georgian" . "ka")
("kazakh" . "kk")
("korean" . "ko")
("lithuanian" . "lt")
("latvian" . "lv")
("macedonian" . "mk")
("malayalam" . "ml")
("malay" . "ms")
("dutch" . "nl")
("norwegian" . "no")
("polish" . "pl")
("portuguese" . "pt")
("brasileiro" . "pt_br")
("romanian" . "ro")
("russian" . "ru")
("sinhala" . "si")
("slovak" . "sk")
("slovenian" . "sl")
("albanian" . "sq")
("serbian" . "sr")
("swedish" . "sv")
("tamil" . "ta")
("telugu" . "te")
("thai" . "th")
("tagalog" . "tl")
("turkish" . "tr")
("ukrainian" . "uk")
("urdu" . "ur")
("vietnamese" . "vi")))

(provide 'company-wordfreq)
;;; company-wordfreq.el ends here
8 changes: 4 additions & 4 deletions test/company-wordfreq.el-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@
(should (equal (company-wordfreq--default-path) "/home/user/.emacs.d/wordfreq-dicts"))))

(ert-deftest test-language-proposal-list ()
(let ((company-wordfreq--language-alist '(("eo" "esperanto")
("en" "english"))))
(let ((company-wordfreq--language-alist '(("esperanto" . "eo")
("english" . "en"))))
(should (equal (company-wordfreq--proposal-list) '("esperanto" "english")))))

(ert-deftest test-language-iso-code-list ()
(let ((company-wordfreq--language-alist '(("eo" "esperanto")
("en" "english"))))
(let ((company-wordfreq--language-alist '(("esperanto" . "eo")
("english" . "en"))))
(should (equal (company-wordfreq--iso-code "esperanto") "eo"))))

(ert-deftest test-make-url-full ()
Expand Down

0 comments on commit affb99e

Please sign in to comment.