Skip to content

Commit

Permalink
feat: support more languages
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone committed Feb 22, 2023
1 parent 37d14d6 commit 7825f2e
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 12 deletions.
123 changes: 123 additions & 0 deletions src/lang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
var supportLanguages = [
["auto", "auto"],
["zh-Hans", "zh-CN"],
["zh-Hant", "zh-TW"],
["en", "en"],
["yue", "zh"],
["wyw", "zh"],
["en", "en"],
["ja", "ja"],
["ko", "ko"],
["fr", "fr"],
["de", "de"],
["es", "es"],
["it", "it"],
["ru", "ru"],
["pt", "pt"],
["nl", "nl"],
["pl", "pl"],
["ar", "ar"],
["af", "af"],
["am", "am"],
["az", "az"],
["be", "be"],
["bg", "bg"],
["bn", "bn"],
["bs", "bs"],
["ca", "ca"],
["ceb", "ceb"],
["co", "co"],
["cs", "cs"],
["cy", "cy"],
["da", "da"],
["el", "el"],
["eo", "eo"],
["et", "et"],
["eu", "eu"],
["fa", "fa"],
["fi", "fi"],
["fj", "fj"],
["fy", "fy"],
["ga", "ga"],
["gd", "gd"],
["gl", "gl"],
["gu", "gu"],
["ha", "ha"],
["haw", "haw"],
["he", "he"],
["hi", "hi"],
["hmn", "hmn"],
["hr", "hr"],
["ht", "ht"],
["hu", "hu"],
["hy", "hy"],
["id", "id"],
["ig", "ig"],
["is", "is"],
["jw", "jw"],
["ka", "ka"],
["kk", "kk"],
["km", "km"],
["kn", "kn"],
["ku", "ku"],
["ky", "ky"],
["la", "lo"],
["lb", "lb"],
["lo", "lo"],
["lt", "lt"],
["lv", "lv"],
["mg", "mg"],
["mi", "mi"],
["mk", "mk"],
["ml", "ml"],
["mn", "mn"],
["mr", "mr"],
["ms", "ms"],
["mt", "mt"],
["my", "my"],
["ne", "ne"],
["no", "no"],
["ny", "ny"],
["or", "or"],
["pa", "pa"],
["ps", "ps"],
["ro", "ro"],
["rw", "rw"],
["si", "si"],
["sk", "sk"],
["sl", "sl"],
["sm", "sm"],
["sn", "sn"],
["so", "so"],
["sq", "sq"],
["sr", "sr"],
["sr-Cyrl", "sr"],
["sr-Latn", "sr"],
["st", "st"],
["su", "su"],
["sv", "sv"],
["sw", "sw"],
["ta", "ta"],
["te", "te"],
["tg", "tg"],
["th", "th"],
["tk", "tk"],
["tl", "tl"],
["tr", "tr"],
["tt", "tt"],
["ug", "ug"],
["uk", "uk"],
["ur", "ur"],
["uz", "uz"],
["vi", "vi"],
["xh", "xh"],
["yi", "yi"],
["yo", "yo"],
["zu", "zu"],
];

exports.supportLanguages = supportLanguages;
exports.langMap = new Map(supportLanguages);
exports.langMapReverse = new Map(
supportLanguages.map(([standardLang, lang]) => [lang, standardLang])
);
17 changes: 5 additions & 12 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
var items = [
["auto", "auto"],
["zh-Hans", "zh"],
["zh-Hant", "zh"],
["en", "en"],
];

var langMap = new Map(items);
var langMapReverse = new Map(
items.map(([standardLang, lang]) => [lang, standardLang])
);
var lang = require("./lang.js");

function supportLanguages() {
return items.map(([standardLang, lang]) => standardLang);
return lang.supportLanguages.map(([standardLang]) => standardLang);
}

function translate(query, completion) {
Expand Down Expand Up @@ -82,3 +72,6 @@ function translate(query, completion) {
});
});
}

exports.supportLanguages = supportLanguages;
exports.translate = translate;

0 comments on commit 7825f2e

Please sign in to comment.