Skip to content

Commit

Permalink
undo
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico040 committed May 30, 2024
1 parent 56d62aa commit 251fbb7
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 26 deletions.
141 changes: 139 additions & 2 deletions plugins/dislate/src/lang.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const DeepLLangs = {
"arabic": "AR",
"bulgarian": "BG",
"czech": "CS",
Expand Down Expand Up @@ -29,4 +29,141 @@ export default {
"turkish": "TR",
"ukrainian": "UK",
"chinese-simplified": "ZH"
}
} as const

export const GTranslateLangs = {
// "auto": "Detect language",
"Afrikaans": "af",
"Albanian": "sq",
"Amharic": "am",
"Arabic": "ar",
"Armenian": "hy",
"Assamese": "as",
"Aymara": "ay",
"Azerbaijani": "az",
"Bambara": "bm",
"Basque": "eu",
"Belarusian": "be",
"Bengali": "bn",
"Bhojpuri": "bho",
"Bosnian": "bs",
"Bulgarian": "bg",
"Catalan": "ca",
"Cebuano": "ceb",
"Chichewa": "ny",
"Chinese (Simplified)": "zh-CN",
"Chinese (Traditional)": "zh-TW",
"Corsican": "co",
"Croatian": "hr",
"Czech": "cs",
"Danish": "da",
"Dhivehi": "dv",
"Dogri": "doi",
"Dutch": "nl",
"English": "en",
"Esperanto": "eo",
"Estonian": "et",
"Ewe": "ee",
"Filipino": "tl",
"Finnish": "fi",
"French": "fr",
"Frisian": "fy",
"Galician": "gl",
"Georgian": "ka",
"German": "de",
"Greek": "el",
"Guarani": "gn",
"Gujarati": "gu",
"Haitian Creole": "ht",
"Hausa": "ha",
"Hawaiian": "haw",
"Hebrew": "iw",
"Hindi": "hi",
"Hmong": "hmn",
"Hungarian": "hu",
"Icelandic": "is",
"Igbo": "ig",
"Ilocano": "ilo",
"Indonesian": "id",
"Irish": "ga",
"Italian": "it",
"Japanese": "ja",
"Javanese": "jw",
"Kannada": "kn",
"Kazakh": "kk",
"Khmer": "km",
"Kinyarwanda": "rw",
"Konkani": "gom",
"Korean": "ko",
"Krio": "kri",
"Kurdish (Kurmanji)": "ku",
"Kurdish (Sorani)": "ckb",
"Kyrgyz": "ky",
"Lao": "lo",
"Latin": "la",
"Latvian": "lv",
"Lingala": "ln",
"Lithuanian": "lt",
"Luganda": "lg",
"Luxembourgish": "lb",
"Macedonian": "mk",
"Maithili": "mai",
"Malagasy": "mg",
"Malay": "ms",
"Malayalam": "ml",
"Maltese": "mt",
"Maori": "mi",
"Marathi": "mr",
"Meiteilon (Manipuri)": "mni-Mtei",
"Mizo": "lus",
"Mongolian": "mn",
"Myanmar (Burmese)": "my",
"Nepali": "ne",
"Norwegian": "no",
"Odia (Oriya)": "or",
"Oromo": "om",
"Pashto": "ps",
"Persian": "fa",
"Polish": "pl",
"Portuguese": "pt",
"Punjabi": "pa",
"Quechua": "qu",
"Romanian": "ro",
"Russian": "ru",
"Samoan": "sm",
"Sanskrit": "sa",
"Scots Gaelic": "gd",
"Sepedi": "nso",
"Serbian": "sr",
"Sesotho": "st",
"Shona": "sn",
"Sindhi": "sd",
"Sinhala": "si",
"Slovak": "sk",
"Slovenian": "sl",
"Somali": "so",
"Spanish": "es",
"Sundanese": "su",
"Swahili": "sw",
"Swedish": "sv",
"Tajik": "tg",
"Tamil": "ta",
"Tatar": "tt",
"Telugu": "te",
"Thai": "th",
"Tigrinya": "ti",
"Tsonga": "ts",
"Turkish": "tr",
"Turkmen": "tk",
"Twi": "ak",
"Ukrainian": "uk",
"Urdu": "ur",
"Uyghur": "ug",
"Uzbek": "uz",
"Vietnamese": "vi",
"Welsh": "cy",
"Xhosa": "xh",
"Yiddish": "yi",
"Yoruba": "yo",
"Zulu": "zu"
} as const;
12 changes: 8 additions & 4 deletions plugins/dislate/src/patches/Commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ import { showConfirmationAlert } from "@vendetta/ui/alerts"
import { findByProps } from "@vendetta/metro"
import { settings } from ".."

import Lang from "../lang"
import { DeepLLangs} from "../lang"
import { DeepL, GTranslate } from "../api"

const ClydeUtils = findByProps("sendBotMessage")
const langOptions = Object.entries(Lang).map(([key, value]) => ({
const langOptionsDeepL = Object.entries(DeepLLangs).map(([key, value]) => ({
name: key,
displayName: key,
value: value
}))
const langOptionsGTranslate = Object.entries(GTranslate).map(([key, value]) => ({
name: key,
displayName: key,
value: value
}))

export default () => registerCommand({
name: "translate",
displayName: "translate",
Expand All @@ -42,7 +46,7 @@ export default () => registerCommand({
displayDescription: "The language that Dislate will translate the text into. This can be any language from the list.",
type: ApplicationCommandOptionType.STRING as number,
// @ts-ignore
choices: [...langOptions],
choices: [...langOptionsDeepL],
required: true
}
],
Expand Down
63 changes: 43 additions & 20 deletions plugins/dislate/src/settings/TargetLang.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,55 @@ import { Forms, Search } from "@vendetta/ui/components"
import { showToast } from "@vendetta/ui/toasts"
import { useProxy } from "@vendetta/storage"
import { settings } from ".."
import Lang from "../lang"
import { DeepLLangs, GTranslateLangs } from "../lang"

const { FormRow } = Forms
const { ScrollView } = ReactNative

export default () => {
useProxy(settings)
const [query, setQuery] = React.useState("")
return (<ScrollView style={{ flex: 1 }}>
<Search
style={{ padding: 15 }}
placeholder="Search Language"
onChangeText={(text: string) => {
setQuery(text)
}}
/>
{
Object.entries(Lang).filter(([key, value]) => key.includes(query)).map(([key, value]) => <FormRow
label={key}
trailing={() => <FormRow.Arrow />}
onPress={() => {
if (settings.target_lang == value) return
settings.target_lang = value
showToast(`Saved ToLang to ${key}`, getAssetIDByName("check"))
if (settings.translator == 0) {
return (<ScrollView style={{ flex: 1 }}>
<Search
style={{ padding: 15 }}
placeholder="Search Language"
onChangeText={(text: string) => {
setQuery(text)
}}
/>)
}
</ScrollView>)
/>
{
Object.entries(DeepLLangs).filter(([key, value]) => key.includes(query)).map(([key, value]) => <FormRow
label={key}
trailing={() => <FormRow.Arrow />}
onPress={() => {
if (settings.target_lang == value) return
settings.target_lang = value
showToast(`Saved ToLang to ${key}`, getAssetIDByName("check"))
}}
/>)
}
</ScrollView>)
} else {
return (<ScrollView style={{ flex: 1 }}>
<Search
style={{ padding: 15 }}
placeholder="Search Language"
onChangeText={(text: string) => {
setQuery(text)
}}
/>
{
Object.entries(GTranslateLangs).filter(([key, value]) => key.includes(query)).map(([key, value]) => <FormRow
label={key}
trailing={() => <FormRow.Arrow />}
onPress={() => {
if (settings.target_lang == value) return
settings.target_lang = value
showToast(`Saved ToLang to ${key}`, getAssetIDByName("check"))
}}
/>)
}
</ScrollView>)
}
}

0 comments on commit 251fbb7

Please sign in to comment.