adds ctx translate

This commit is contained in:
bignutty 2024-11-05 23:55:52 +01:00
parent 064845b307
commit 28af9c5cb5
4 changed files with 129 additions and 88 deletions

View file

@ -693,6 +693,27 @@ module.exports.DICTIONARY_LANGUAGES = Object.freeze({
zh: "Chinese"
})
// Default list of languages uses in various translate contexts
module.exports.TRANSLATE_DEFAULT_LANGUAGE_LIST = Object.freeze([
"en",
"de",
"fr",
"es",
"pt-PT",
"no",
"fi",
"sv",
"it",
"ja",
"ru",
"ar",
"he",
"tr",
"hi",
"zh-CN",
"zh-TW",
])
// hey if you're looking at this and are annoyed that a language
// doesn't as expected work lmk on discord @bignutty and i'll add
// it (within reason), same goes for flag emoji below
@ -1044,6 +1065,7 @@ module.exports.TRANSLATE_LANGUAGE_MAPPINGS = Object.freeze({
"pl": "🇵🇱",
"pt": "🇵🇹",
"pt-pt": "🇵🇹",
"pt-PT": "🇵🇹",
"pt-br": "🇧🇷",
"ro": "🇷🇴",
"ru": "🇷🇺",

View file

@ -1,4 +1,4 @@
const { TRANSLATE_LANGUAGES } = require("#constants");
const { TRANSLATE_LANGUAGES, TRANSLATE_DEFAULT_LANGUAGE_LIST } = require("#constants");
const { getLanguagesFromAny } = require("#utils/translate");
module.exports = async (context)=>{
@ -7,25 +7,7 @@ module.exports = async (context)=>{
choices = getLanguagesFromAny(context.value)
} else {
// Default language suggestions
choices = [
"en",
"de",
"fr",
"es",
"pt-PT",
"no",
"fi",
"sv",
"it",
"ja",
"ru",
"ar",
"he",
"tr",
"hi",
"zh-CN",
"zh-TW",
]
choices = TRANSLATE_DEFAULT_LANGUAGE_LIST
}
return context.respond({ choices: choices.splice(0, 20).map((l)=>({