Skip to content

Commit

Permalink
various fixes for dislate lite
Browse files Browse the repository at this point in the history
- case unsenitify search bar on languages page
- fix my stupid mistakes caused bu gigacode (fuck gigacode, i hate gigacode autocomplition)
- fix clyde ephemeral message being unclosable (i hope)
  • Loading branch information
Rico040 committed Jun 2, 2024
1 parent 1e5ff14 commit 894c6a5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 0 additions & 2 deletions plugins/dislate/src/api/GTranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const translate = async (text: string, source_lang: string = "auto", target_lang

const data: GTranslateResponse = await (await fetch(API_URL)).json()

console.log(data)

return {
source_lang,
text: data.sentences.map(s => s.trans).join('') }
Expand Down
4 changes: 2 additions & 2 deletions plugins/dislate/src/patches/ActionSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export default () => before("openLazy", LazyActionSheet, ([component, key, msg])
switch(settings.translator) {
case 0:
console.log("Translating with DeepL: ", originalMessage.content)
translate = await DeepL.translate(originalMessage.content, null, target_lang, !isTranslated)
translate = await DeepL.translate(originalMessage.content, undefined, target_lang, !isTranslated)
case 1:
console.log("Translating with GTranslate: ", originalMessage.content)
translate = await GTranslate.translate(originalMessage.content, null, target_lang, !isTranslated)
translate = await GTranslate.translate(originalMessage.content, undefined, target_lang, !isTranslated)
}

FluxDispatcher.dispatch({
Expand Down
20 changes: 12 additions & 8 deletions plugins/dislate/src/patches/Commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ const langOptionsDeepL = Object.entries(DeepLLangs).map(([key, value]) => ({
displayName: key,
value: value
}))
const langOptionsGTranslate = Object.entries(GTranslate).map(([key, value]) => ({
name: key,
displayName: key,
value: value
}))

// TODO: Make command option somehow vary with different translators
// const langOptionsGTranslate = Object.entries(GTranslate).map(([key, value]) => ({
// name: key,
// displayName: key,
// value: value
// }))
// const langOptions = settings?.translator === 1 ? langOptionsGTranslate : langOptionsDeepL;

export default () => registerCommand({
name: "translate",
displayName: "translate",
Expand Down Expand Up @@ -56,9 +60,9 @@ export default () => registerCommand({
var content
switch(settings.translator) {
case 0:
content = await DeepL.translate(text.value, null, lang.value)
content = await DeepL.translate(text.value, undefined, lang.value)
case 1:
content = await GTranslate.translate(text.value, null, lang.value)
content = await GTranslate.translate(text.value, undefined, lang.value)
}
return await new Promise((resolve): void => showConfirmationAlert({
title: "Are you sure you want to send it?",
Expand All @@ -73,7 +77,7 @@ export default () => registerCommand({
}))
} catch (e) {
logger.error(e)
return ClydeUtils.sendBotMessage(ctx.channel.id, "Failed to translate message. Please check Debug Logs for more info.", getAssetIDByName("Small"))
return ClydeUtils.sendBotMessage(ctx.channel.id, "Failed to translate message. Please check Debug Logs for more info.")
}
}
})
4 changes: 2 additions & 2 deletions plugins/dislate/src/settings/TargetLang.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default () => {
}}
/>
{
Object.entries(DeepLLangs).filter(([key, value]) => key.includes(query)).map(([key, value]) => <FormRow
Object.entries(DeepLLangs).filter(([key, value]) => key.toLowerCase().includes(query.toLowerCase())).map(([key, value]) => <FormRow
label={key}
trailing={() => <FormRow.Arrow />}
onPress={() => {
Expand All @@ -43,7 +43,7 @@ export default () => {
}}
/>
{
Object.entries(GTranslateLangs).filter(([key, value]) => key.includes(query)).map(([key, value]) => <FormRow
Object.entries(GTranslateLangs).filter(([key, value]) => key.toLowerCase().includes(query.toLowerCase())).map(([key, value]) => <FormRow
label={key}
trailing={() => <FormRow.Arrow />}
onPress={() => {
Expand Down

0 comments on commit 894c6a5

Please sign in to comment.