mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 06:33:05 -04:00
language support for translate
This commit is contained in:
parent
db8de1c6f9
commit
3cea3331da
4 changed files with 77 additions and 10 deletions
|
@ -291,9 +291,10 @@ module.exports.tiktok = async function(context, text, voice){
|
|||
})
|
||||
}
|
||||
|
||||
module.exports.dictionary = async function(context, query){
|
||||
module.exports.dictionary = async function(context, query, language){
|
||||
return await request(Api.UTILS_DICTIONARY, "GET", {}, {
|
||||
q: query
|
||||
q: query,
|
||||
l: language
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -435,6 +435,46 @@ module.exports.MICROSOFT_VOICE_CONFIG = {
|
|||
"Male Whisper": { pitch: 113, speed: 170 }
|
||||
}
|
||||
|
||||
module.exports.DICTIONARY_LANGUAGES = Object.freeze({
|
||||
ar: "Arabic",
|
||||
ca: "Catalan",
|
||||
cs: "Czech",
|
||||
da: "Danish",
|
||||
de: "German",
|
||||
el: "Greek",
|
||||
"en-uk": "English (UK)",
|
||||
en: "English (US)",
|
||||
es: "Spanish",
|
||||
fi: "Finnish",
|
||||
fr: "French",
|
||||
hi: "Hindi",
|
||||
hr: "Croatian",
|
||||
id: "Indonesian",
|
||||
it: "Italian",
|
||||
iw: "Hebrew",
|
||||
ja: "Japanese",
|
||||
ko: "Korean",
|
||||
nl: "Dutch",
|
||||
no: "Norwegian",
|
||||
pl: "Polish",
|
||||
"pt-br": "Portuguese",
|
||||
"pt-pt": "Portuguese",
|
||||
pt: "Portuguese",
|
||||
ro: "Romanian",
|
||||
ru: "Russian",
|
||||
sr: "Serbian",
|
||||
sk: "Slovak",
|
||||
sv: "Swedish",
|
||||
th: "Thai",
|
||||
tl: "Tagalog",
|
||||
tr: "Turkish",
|
||||
uk: "Ukrainian",
|
||||
vi: "Vietnamese",
|
||||
"zh-cn": "Chinese",
|
||||
"zh-tw": "Chinese",
|
||||
zh: "Chinese"
|
||||
})
|
||||
|
||||
// hey if you're looking at this and annoyed that a language doesnt
|
||||
// work lmk on discord @bignutty and i'll add it (if reasonable)
|
||||
// same goes for emoji below
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { TRANSLATE_LANGUAGES, TRANSLATE_LANGUAGE_MAPPINGS, TRANSLATE_LANGUAGE_ALIASES } = require("../constants");
|
||||
const { TRANSLATE_LANGUAGES, TRANSLATE_LANGUAGE_MAPPINGS, TRANSLATE_LANGUAGE_ALIASES, DICTIONARY_LANGUAGES } = require("../constants");
|
||||
|
||||
function getCode(desiredLang) {
|
||||
if (!desiredLang) {
|
||||
|
@ -38,6 +38,15 @@ module.exports.getCodeFromAny = function (prompt) {
|
|||
return languages[0];
|
||||
};
|
||||
|
||||
|
||||
module.exports.dictionaryGetCodeFromAny = function (prompt) {
|
||||
if(DICTIONARY_LANGUAGES[prompt.toLowerCase()]) return prompt.toLowerCase()
|
||||
let languages = [];
|
||||
for(const i of Object.keys(DICTIONARY_LANGUAGES)) if(!languages.includes(i) && DICTIONARY_LANGUAGES[i].toLowerCase() == prompt.toLowerCase()) languages.push(i)
|
||||
return languages[0];
|
||||
};
|
||||
|
||||
|
||||
module.exports.isSupported = function (desiredLang) {
|
||||
return Boolean(getCode(desiredLang));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue