Update Translator.plugin.js
This commit is contained in:
parent
45dfa62a83
commit
cfb392a09f
|
@ -2,7 +2,7 @@
|
|||
* @name Translator
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 2.6.1
|
||||
* @version 2.6.2
|
||||
* @description Allows you to translate Messages and your outgoing Messages within Discord
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -14,9 +14,7 @@
|
|||
|
||||
module.exports = (_ => {
|
||||
const changeLog = {
|
||||
"added": {
|
||||
"Microsoft Translate": "Added"
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
|
||||
|
@ -262,7 +260,7 @@ module.exports = (_ => {
|
|||
type: "Switch",
|
||||
plugin: _this,
|
||||
keys: ["general", key],
|
||||
label: _this.labels[`general_${key}`],
|
||||
label: _this.labels[`general_${key}`] || _this.defaults.general[key].description,
|
||||
tag: BDFDB.LibraryComponents.FormComponents.FormTags.H5,
|
||||
value: _this.settings.general[key]
|
||||
})),
|
||||
|
@ -392,7 +390,8 @@ module.exports = (_ => {
|
|||
addTranslateButton: {value: true, popout: false},
|
||||
usePerChatTranslation: {value: true, popout: false},
|
||||
sendOriginalMessage: {value: false, popout: true},
|
||||
showOriginalMessage: {value: false, popout: true}
|
||||
showOriginalMessage: {value: false, popout: true},
|
||||
useSpoilerInOriginal: {value: false, popout: false, description: "Use Spoilers instead of Quotes for the original Message Text"}
|
||||
},
|
||||
choices: {},
|
||||
exceptions: {
|
||||
|
@ -458,7 +457,7 @@ module.exports = (_ => {
|
|||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["general", key],
|
||||
label: this.labels[`general_${key}`],
|
||||
label: this.labels[`general_${key}`] || this.defaults.general[key].description,
|
||||
value: this.settings.general[key]
|
||||
}));
|
||||
|
||||
|
@ -685,7 +684,7 @@ module.exports = (_ => {
|
|||
if (this.isTranslationEnabled(e.instance.props.channel.id) && e2.methodArguments[0].value) {
|
||||
e2.stopOriginalMethodCall();
|
||||
this.translateText(e2.methodArguments[0].value, messageTypes.SENT, (translation, input, output) => {
|
||||
translation = !translation ? e2.methodArguments[0].value : (this.settings.general.sendOriginalMessage ? (translation + "\n\n> *" + e2.methodArguments[0].value.split("\n").join("*\n> *") + "*") : translation);
|
||||
translation = !translation ? e2.methodArguments[0].value : (this.settings.general.sendOriginalMessage ? (translation + (!this.settings.general.useSpoilerInOriginal ? ("\n\n> *" + e2.methodArguments[0].value.split("\n").join("*\n> *") + "*").replace(/> \*\*\n/g, "> \n") : `\n\n||${e2.methodArguments[0].value}||`)) : translation);
|
||||
e2.originalMethod(Object.assign({}, e2.methodArguments[0], {value: translation}));
|
||||
});
|
||||
return Promise.resolve({
|
||||
|
@ -880,12 +879,12 @@ module.exports = (_ => {
|
|||
let oldStrings = orignalContent.split(/\n{0,1}__________________ __________________ __________________\n{0,1}/);
|
||||
let strings = translation.split(/\n{0,1}__________________ __________________ __________________\n{0,1}/);
|
||||
let oldContent = this.settings.general.showOriginalMessage && (oldStrings.shift() || "").trim();
|
||||
let content = (strings.shift() || "").trim() + (oldContent ? `\n\n${oldContent}` : "");
|
||||
let content = (strings.shift() || "").trim() + (oldContent ? (!this.settings.general.useSpoilerInOriginal ? ("\n\n> *" + oldContent.split("\n").join("*\n> *") + "*").replace(/> \*\*\n/g, "> \n") : `\n\n||${oldContent}||`) : "");
|
||||
let embeds = {};
|
||||
for (let i in message.embeds) {
|
||||
message.embeds[i].message_id = message.id;
|
||||
let oldEmbedString = this.settings.general.showOriginalMessage && (oldStrings.shift() || "").trim();
|
||||
embeds[message.embeds[i].id] = (strings.shift() || message.embeds[i].rawDescription).trim() + (oldEmbedString ? `\n\n${oldEmbedString}` : "");
|
||||
embeds[message.embeds[i].id] = (strings.shift() || message.embeds[i].rawDescription).trim() + (oldEmbedString ? (!this.settings.general.useSpoilerInOriginal ? ("\n\n> *" + oldEmbedString.split("\n").join("*\n> *") + "*").replace(/> \*\*\n/g, "> \n") : `\n\n||${oldEmbedString}||`) : "");
|
||||
}
|
||||
translatedMessages[message.id] = {content, embeds, input, output};
|
||||
BDFDB.MessageUtils.rerenderAll(true);
|
||||
|
|
Loading…
Reference in New Issue