Merge branch 'main' into dev

This commit is contained in:
thororen1234 2024-07-29 16:50:51 -04:00
commit 370237f4c2
2 changed files with 13 additions and 9 deletions

View file

@ -58,13 +58,17 @@ export default definePlugin({
start() { start() {
addAccessory("ec-translation", props => <Accessory message={props.message} />); addAccessory("ec-translation", props => <Accessory message={props.message} />);
addButton("ec-translate", message => ({ addButton("ec-translate", message => {
if (!message.content) return null;
return {
label: "Translate", label: "Translate",
icon: Icon, icon: Icon,
message: message, message: message,
channel: ChannelStore.getChannel(message.channel_id), channel: ChannelStore.getChannel(message.channel_id),
onClick: () => handleTranslate(message), onClick: () => handleTranslate(message),
})); };
});
}, },
stop() { stop() {
removeButton("ec-translate"); removeButton("ec-translate");

View file

@ -25,7 +25,7 @@ function isShavian(text: string) {
} }
async function translateShavian(message: string) { async function translateShavian(message: string) {
const dictionary = await (await fetch("https://github.com/ForkPrince/TranslatePlus/raw/322199d5fdb1a9506591c9f4a2826338b5d67e38/shavian.json")).json(); const dictionary = await (await fetch("https://raw.githubusercontent.com/ForkPrince/TranslatePlus/322199d5fdb1a9506591c9f4a2826338b5d67e38/shavian.json")).json();
const punctuationMap = { const punctuationMap = {
'"': "\"", '"': "\"",
@ -72,7 +72,7 @@ async function translateShavian(message: string) {
async function translateSitelen(message: string) { async function translateSitelen(message: string) {
message = Array.from(message).join(" "); message = Array.from(message).join(" ");
const dictionary = await (await fetch("https://github.com/ForkPrince/TranslatePlus/raw/5ca152b134ea11433971f21b2ef8d556d4306717/sitelen-pona.json")).json(); const dictionary = await (await fetch("https://raw.githubusercontent.com/ForkPrince/TranslatePlus/5ca152b134ea11433971f21b2ef8d556d4306717/sitelen-pona.json")).json();
const sorted = Object.keys(dictionary).sort((a, b) => b.length - a.length); const sorted = Object.keys(dictionary).sort((a, b) => b.length - a.length);