Advertisement
Jean-Yves-Du-Tieks

Untitled

Apr 13th, 2019
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.50 KB | None | 0 0
  1. //META{"name":"GoogleTranslateOption","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/GoogleTranslateOption","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/GoogleTranslateOption/GoogleTranslateOption.plugin.js"}*//
  2.  
  3. class GoogleTranslateOption {
  4. getName () {return "GoogleTranslateOption";}
  5.  
  6. getVersion () {return "1.6.7";}
  7.  
  8. getAuthor () {return "DevilBro";}
  9.  
  10. getDescription () {return "Adds a Google Translate option to your context menu, which shows a preview of the translated text and on click will open the selected text in Google Translate. Also adds a translation button to your textareas, which will automatically translate the text for you before it is being send.";}
  11.  
  12. initConstructor () {
  13. this.changelog = {
  14. "fixed":[["Recognize Binary when Auto is selected","GTO now tries to auto translate from binary, if a string contains only 0s and 1s (excluding whitespaces)"]]
  15. };
  16.  
  17. this.labels = {};
  18.  
  19. this.patchModules = {
  20. "ChannelTextArea":"componentDidMount",
  21. "Message":"componentDidMount",
  22. "MessageOptionPopout":"componentDidMount",
  23. "StandardSidebarView":"componentWillUnmount"
  24. };
  25.  
  26. this.languages = {};
  27.  
  28. this.doTranslate = false;
  29. this.translating = false;
  30.  
  31. this.defaults = {
  32. settings: {
  33. addTranslateButton: {value:true, description:"Adds an translate button to the chatbar."},
  34. sendOriginalMessage: {value:false, description:"Send the original message together with the translation."}
  35. },
  36. choices: {
  37. inputContext: {value:"auto", place:"Context", direction:"Input", popout:false, description:"Input Language in selected Messages:"},
  38. outputContext: {value:"$discord", place:"Context", direction:"Output", popout:false, description:"Output Language in selected Messages:"},
  39. inputMessage: {value:"auto", place:"Message", direction:"Input", popout:true, description:"Input Language in your Message:"},
  40. outputMessage: {value:"$discord", place:"Message", direction:"Output", popout:true, description:"Output Language in your Message:"}
  41. }
  42. };
  43.  
  44. this.messageTranslateContextEntryMarkup =
  45. `<div class="${BDFDB.disCN.contextmenuitemgroup}">
  46. <div class="${BDFDB.disCN.contextmenuitem} googletranslateoption-item googletranslateoption-translate-item">
  47. <span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_messagetranslateoption_text</div></span>
  48. <div class="${BDFDB.disCN.contextmenuhint}"></div>
  49. </div>
  50. </div>`;
  51.  
  52. this.messageUntranslateContextEntryMarkup =
  53. `<div class="${BDFDB.disCN.contextmenuitemgroup}">
  54. <div class="${BDFDB.disCN.contextmenuitem} googletranslateoption-item googletranslateoption-untranslate-item">
  55. <span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_messageuntranslateoption_text</div></span>
  56. <div class="${BDFDB.disCN.contextmenuhint}"></div>
  57. </div>
  58. </div>`;
  59.  
  60. this.messageSearchContextEntryMarkup =
  61. `<div class="${BDFDB.disCN.contextmenuitemgroup}">
  62. <div class="${BDFDB.disCN.contextmenuitem} googletranslateoption-item googletranslateoption-search-item">
  63. <span class="DevilBro-textscrollwrapper" speed=3><div class="DevilBro-textscroll">REPLACE_context_googletranslateoption_text</div></span>
  64. <div class="${BDFDB.disCN.contextmenuhint}"></div>
  65. </div>
  66. </div>`;
  67.  
  68. this.popoutTranslateEntryMarkup =
  69. `<button type="button" class="${BDFDB.disCNS.optionpopoutitem + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow} googletranslateoption-itembtn googletranslateoption-translate-itembtn">
  70. <div class="${BDFDB.disCN.buttoncontents}">REPLACE_popout_translateoption_text</div>
  71. </button>`;
  72.  
  73. this.popoutUntranslateEntryMarkup =
  74. `<button type="button" class="${BDFDB.disCNS.optionpopoutitem + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow} googletranslateoption-itembtn googletranslateoption-untranslate-itembtn">
  75. <div class="${BDFDB.disCN.buttoncontents}">REPLACE_popout_untranslateoption_text</div>
  76. </button>`;
  77.  
  78. this.translateButtonMarkup =
  79. `<button type="button" class="${BDFDB.disCNS.textareabuttonwrapper + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow} translate-button-wrapper">
  80. <div class="${BDFDB.disCNS.buttoncontents + BDFDB.disCNS.textareabutton + BDFDB.disCN.textareapickerbutton} translate-button-inner">
  81. <svg version="1.1" xmlns="http://www.w3.org/2000/svg" class="${BDFDB.disCN.textareaicon}" viewBox="0 0 22 22" fill="currentColor">
  82. <path d="M 19.794, 3.299 H 9.765 L 8.797, 0 h -6.598 C 0.99, 0, 0, 0.99, 0, 2.199 V 16.495 c 0, 1.21, 0.99, 2.199, 2.199, 2.199 H 9.897 l 1.1, 3.299 H 19.794 c 1.21, 0, 2.199 -0.99, 2.199 -2.199 V 5.498 C 21.993, 4.289, 21.003, 3.299, 19.794, 3.299 z M 5.68, 13.839 c -2.48, 0 -4.492 -2.018 -4.492 -4.492 s 2.018 -4.492, 4.492 -4.492 c 1.144, 0, 2.183, 0.407, 3.008, 1.171 l 0.071, 0.071 l -1.342, 1.298 l -0.066 -0.06 c -0.313 -0.297 -0.858 -0.643 -1.671 -0.643 c -1.441, 0 -2.612, 1.193 -2.612, 2.661 c 0, 1.468, 1.171, 2.661, 2.612, 2.661 c 1.507, 0, 2.161 -0.962, 2.337 -1.606 h -2.43 v -1.704 h 4.344 l 0.016, 0.077 c 0.044, 0.231, 0.06, 0.434, 0.06, 0.665 C 10.001, 12.036, 8.225, 13.839, 5.68, 13.839 z M 11.739, 9.979 h 4.393 c 0, 0 -0.374, 1.446 -1.715, 3.008 c -0.588 -0.676 -0.995 -1.336 -1.254 -1.864 h -1.089 L 11.739, 9.979 z M 13.625, 13.839 l -0.588, 0.583 l -0.72 -2.452 C 12.685, 12.63, 13.13, 13.262, 13.625, 13.839 z M 20.893, 19.794 c 0, 0.605 -0.495, 1.1 -1.1, 1.1 H 12.096 l 2.199 -2.199 l -0.896 -3.041 l 1.012 -1.012 l 2.953, 2.953 l 0.803 -0.803 l -2.975 -2.953 c 0.99 -1.138, 1.759 -2.474, 2.106 -3.854 h 1.397 V 8.841 H 14.697 v -1.144 h -1.144 v 1.144 H 11.398 l -1.309 -4.443 H 19.794 c 0.605, 0, 1.1, 0.495, 1.1, 1.1 V 19.794 z"/>
  83. </svg>
  84. </div>
  85. </button>`;
  86.  
  87. this.reverseButtonMarkup =
  88. `<svg class="reverse-button ${BDFDB.disCN.flexchild}" type="REPLACETYPE" version="1.1" xmlns="http://www.w3.org/2000/svg" width="22" height="22" fill="currentColor" style="flex: 0 0 auto;">
  89. <path d="M 0, 10.515 c 0, 2.892, 1.183, 5.521, 3.155, 7.361 L 0, 21.031 h 7.887 V 13.144 l -2.892, 2.892 C 3.549, 14.722, 2.629, 12.75, 2.629, 10.515 c 0 -3.418, 2.235 -6.309, 5.258 -7.492 v -2.629 C 3.418, 1.577, 0, 5.652, 0, 10.515 z M 21.031, 0 H 13.144 v 7.887 l 2.892 -2.892 C 17.482, 6.309, 18.402, 8.281, 18.402, 10.515 c 0, 3.418 -2.235, 6.309 -5.258, 7.492 V 20.768 c 4.469 -1.183, 7.887 -5.258, 7.887 -10.121 c 0 -2.892 -1.183 -5.521 -3.155 -7.361 L 21.031, 0 z"/>
  90. </svg>`;
  91.  
  92. this.translatePopoutMarkup =
  93. `<div class="${BDFDB.disCNS.popout + BDFDB.disCNS.popoutbottomright + BDFDB.disCNS.popoutnoarrow + BDFDB.disCN.popoutnoshadow} popout-googletranslate DevilBro-modal" style="z-index: 2000; overflow: visible; visibility: visible; transform: translateX(-100%) translateY(-100%) translateZ(0px);">
  94. <div class="${BDFDB.disCN.popoutthemedpopout}">
  95. <div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop8 + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">
  96. <h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Words starting with "!" will be ignored</h3>
  97. </div>
  98. ${Object.keys(this.defaults.choices).map((key, i) =>
  99. `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop8 + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">
  100. <h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.choices[key].description}</h3>
  101. ${this.defaults.choices[key].direction == "Output" ? this.reverseButtonMarkup.replace("REPLACETYPE",key) : ""}
  102. </div>
  103. <div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">
  104. <div class="${BDFDB.disCN.selectwrap}" style="flex: 1 1 auto;">
  105. <div class="${BDFDB.disCNS.select + BDFDB.disCNS.selectsingle + BDFDB.disCN.selecthasvalue}" type="${key}" value="${this.defaults.choices[key].value}">
  106. <div class="${BDFDB.disCN.selectcontrol}">
  107. <div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectvalue}" style="flex: 1 1 auto;">
  108. <div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="flex: 1 1 auto;"></div>
  109. </div>
  110. <span class="${BDFDB.disCN.selectarrowzone}">
  111. <span class="${BDFDB.disCN.selectarrow}"></span>
  112. </span>
  113. </div>
  114. </div>
  115. </div>
  116. </div>`).join("")}
  117. <div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">
  118. <h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Translate:</h3>
  119. <div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCNS.switchthemedefault + BDFDB.disCN.switchvalueunchecked}" style="flex: 0 0 auto;">
  120. <input type="checkbox" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}" id="translating-checkbox">
  121. </div>
  122. </div>
  123. </div>
  124. </div>`;
  125.  
  126. this.css = `
  127. ${BDFDB.dotCNS.textareawrapall + BDFDB.dotCN.textareainner} {
  128. align-items: center;
  129. }
  130.  
  131. ${BDFDB.dotCNS.textareawrapall + BDFDB.dotCN.textareainner} .send-button {
  132. top: 0;
  133. bottom: 0;
  134. right: 9px;
  135. }
  136.  
  137. ${BDFDB.dotCN.textareabuttonwrapper}.popout-open ${BDFDB.dotCN.textareabutton}.translate-button-inner {
  138. opacity: 1;
  139. }
  140.  
  141. ${BDFDB.dotCN.textareabuttonwrapper + BDFDB.dotCNS.textareabuttonactive + BDFDB.dotCN.textareabutton}.translate-button-inner {
  142. color: #F04747 !important;
  143. }
  144.  
  145. ${BDFDB.dotCNS.textareabuttonwrapper + BDFDB.dotCN.textareabutton}.translate-button-inner ${BDFDB.dotCN.textareaicon} {
  146. height: 24px;
  147. width: 24px;
  148. }
  149.  
  150. ${BDFDB.dotCN.textareabuttonwrapper}.popout-open ${BDFDB.dotCN.textareabutton}.translate-button-inner ${BDFDB.dotCN.textareaicon} {
  151. transform: none;
  152. }
  153.  
  154. .reverse-button {
  155. margin-top: -5px;
  156. opacity: 0.2;
  157. transition: all 200ms ease;
  158. }
  159.  
  160. ${BDFDB.dotCN.themedark} .reverse-button {
  161. fill: #fff;
  162. }
  163.  
  164. ${BDFDB.dotCN.themelight} .reverse-button {
  165. fill: #4f545c;
  166. }
  167. .reverse-button:hover {
  168. cursor: pointer;
  169. opacity: 1;
  170. }
  171.  
  172. ${BDFDB.dotCN.popout}.popout-googletranslate ${BDFDB.dotCN.popoutthemedpopout} {
  173. padding: 0 10px;
  174. width: 400px;
  175. }
  176.  
  177. ${BDFDB.dotCN.selectmenuouter}.inChat {
  178. top: 0%;
  179. transform: translateY(-100%);
  180. border-radius: 4px 4px 0 0;
  181. margin-top: 1px;
  182. }`;
  183. }
  184.  
  185. getSettingsPanel () {
  186. if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
  187. var choices = BDFDB.getAllData(this, "choices");
  188. var settings = BDFDB.getAllData(this, "settings");
  189. var settingshtml = `<div class="${this.name}-settings DevilBro-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="DevilBro-settings-inner">`;
  190. for (let key in choices) {
  191. let choice = this.getLanguageChoice(key);
  192. settingshtml += `<h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCN.flexchild} marginBottom8-1mABJ4 marginTop8-2gOa2N" style="flex: 1 1 auto;">${this.defaults.choices[key].description}</h3><div class="ui-form-item ${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><div class="${BDFDB.disCN.selectwrap}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.select + BDFDB.disCNS.selectsingle + BDFDB.disCN.selecthasvalue}" type="${key}" value="${choice}"><div class="${BDFDB.disCN.selectcontrol}"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectvalue}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="padding:0;">${this.languages[choice].name}</div></div><span class="${BDFDB.disCN.selectarrowzone}"><span class="${BDFDB.disCN.selectarrow}"></span></span></div></div></div></div>`
  193. }
  194. for (let key in settings) {
  195. settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
  196. }
  197. settingshtml += `</div></div>`;
  198.  
  199. let settingspanel = BDFDB.htmlToElement(settingshtml);
  200.  
  201. BDFDB.initElements(settingspanel, this);
  202.  
  203. BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu("inSettings", e);});
  204.  
  205. return settingspanel;
  206. }
  207.  
  208. //legacy
  209. load () {}
  210.  
  211. start () {
  212. if (!global.BDFDB) global.BDFDB = {myPlugins:{}};
  213. if (global.BDFDB && global.BDFDB.myPlugins && typeof global.BDFDB.myPlugins == "object") global.BDFDB.myPlugins[this.getName()] = this;
  214. var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
  215. if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) {
  216. if (libraryScript) libraryScript.remove();
  217. libraryScript = document.createElement("script");
  218. libraryScript.setAttribute("type", "text/javascript");
  219. libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
  220. libraryScript.setAttribute("date", performance.now());
  221. libraryScript.addEventListener("load", () => {if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();});
  222. document.head.appendChild(libraryScript);
  223. }
  224. else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
  225. this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
  226. }
  227.  
  228. initialize () {
  229. if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
  230. if (this.started) return;
  231. BDFDB.loadMessage(this);
  232.  
  233. this.GuildUtils = BDFDB.WebModules.findByProperties("getGuilds","getGuild");
  234. this.ChannelUtils = BDFDB.WebModules.findByProperties("getChannels","getChannel");
  235. this.LastGuildStore = BDFDB.WebModules.findByProperties("getLastSelectedGuildId");
  236. this.LastChannelStore = BDFDB.WebModules.findByProperties("getLastSelectedChannelId");
  237.  
  238. this.setLanguage();
  239.  
  240. BDFDB.WebModules.forceAllUpdates(this);
  241. }
  242. else {
  243. console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
  244. }
  245. }
  246.  
  247. stop () {
  248. if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
  249. document.querySelectorAll(BDFDB.dotCN.message + ".translated").forEach(message => {
  250. this.resetMessage(message);
  251. });
  252.  
  253. BDFDB.removeEles(".translate-button-wrapper", ".popout-googletranslate");
  254.  
  255. BDFDB.unloadMessage(this);
  256. }
  257. }
  258.  
  259.  
  260. // begin of own functions
  261.  
  262. changeLanguageStrings () {
  263. this.messageTranslateContextEntryMarkup = this.messageTranslateContextEntryMarkup.replace("REPLACE_context_messagetranslateoption_text", this.labels.context_messagetranslateoption_text);
  264. this.messageUntranslateContextEntryMarkup = this.messageUntranslateContextEntryMarkup.replace("REPLACE_context_messageuntranslateoption_text", this.labels.context_messageuntranslateoption_text);
  265. this.messageSearchContextEntryMarkup = this.messageSearchContextEntryMarkup.replace("REPLACE_context_googletranslateoption_text", this.labels.context_googletranslateoption_text);
  266.  
  267. this.popoutTranslateEntryMarkup = this.popoutTranslateEntryMarkup.replace("REPLACE_popout_translateoption_text", this.labels.popout_translateoption_text);
  268. this.popoutUntranslateEntryMarkup = this.popoutUntranslateEntryMarkup.replace("REPLACE_popout_untranslateoption_text", this.labels.popout_untranslateoption_text);
  269. }
  270.  
  271. onMessageContextMenu (instance, menu) {
  272. if (instance.props && instance.props.message && instance.props.channel && instance.props.target && !menu.querySelector(".googletranslateoption-item")) {
  273. let {messagediv, pos} = this.getMessageAndPos(instance.props.target);
  274. if (!messagediv || pos == -1) return;
  275. let pinentry = BDFDB.React.findDOMNodeSafe(BDFDB.getOwnerInstance({node:menu,name:"MessagePinItem"}));
  276. let messageTranslateContextEntry = BDFDB.htmlToElement(BDFDB.containsClass(messagediv, "translated") ? this.messageUntranslateContextEntryMarkup : this.messageTranslateContextEntryMarkup);
  277. if (pinentry) pinentry.parentElement.insertBefore(messageTranslateContextEntry, pinentry.nextElementSibling);
  278. else menu.insertBefore(messageTranslateContextEntry, menu.firstElementChild);
  279. let translateitem = messageTranslateContextEntry.querySelector(".googletranslateoption-item");
  280. translateitem.addEventListener("click", () => {
  281. BDFDB.closeContextMenu(menu);
  282. this.translateMessage(instance.props.message, instance.props.target, instance.props.channel);
  283. });
  284. if (BDFDB.isPluginEnabled("MessageUtilities")) {
  285. BDFDB.setContextHint(translateitem, bdplugins.MessageUtilities.plugin.getActiveShortcutString("__Translate_Message"));
  286. }
  287. let text = document.getSelection().toString();
  288. if (text) {
  289. let searchentry = BDFDB.React.findDOMNodeSafe(BDFDB.getOwnerInstance({node:menu,props:["handleSearchWithGoogle"]}));
  290. if (searchentry) {
  291. let messageSearchContextEntry = BDFDB.htmlToElement(this.messageSearchContextEntryMarkup);
  292. searchentry.parentElement.appendChild(messageSearchContextEntry);
  293. let searchitem = messageSearchContextEntry.querySelector(".googletranslateoption-search-item");
  294. searchitem.addEventListener("mouseenter", e => {
  295. this.translateText(text, "context", (translation, input, output) => {
  296. if (translation) {
  297. var openGoogleSearch = () => {
  298. BDFDB.closeContextMenu(menu);
  299. window.open(this.getGoogleTranslatePageURL(input.id, output.id, text), "_blank");
  300. };
  301. searchitem.removeEventListener("click", openGoogleSearch);
  302. searchitem.addEventListener("click", openGoogleSearch);
  303. let rects = BDFDB.getRects(searchitem);
  304. BDFDB.createTooltip(`From ${input.name}:\n${text}\n\nTo ${output.name}:\n${translation}`, searchitem, {type: "right",selector:"googletranslate-tooltip",style:`max-width: ${window.outerWidth - rects.left - rects.width}px !important;`});
  305. }
  306. });
  307. });
  308. }
  309. }
  310. }
  311. }
  312.  
  313. setLanguage () {
  314. this.languages = Object.assign({},
  315. {"auto": {name:"Auto", id:"auto", integrated:false, dic:false, deepl:true}},
  316. BDFDB.languages,
  317. {"binary": {name:"Binary", id:"binary", integrated:false, dic:false, deepl:true}}
  318. );
  319. }
  320.  
  321. getLanguageChoice (direction, place) {
  322. this.setLanguage();
  323. var type = typeof place === "undefined" ? direction : direction.toLowerCase() + place.charAt(0).toUpperCase() + place.slice(1).toLowerCase();
  324. var choice = BDFDB.getData(type, this, "choices");
  325. choice = this.languages[choice] ? choice : Object.keys(this.languages)[0];
  326. choice = type.indexOf("output") > -1 && choice == "auto" ? "en" : choice;
  327. return choice;
  328. }
  329.  
  330. processStandardSidebarView (instance, wrapper) {
  331. if (this.SettingsUpdated) {
  332. delete this.SettingsUpdated;
  333. this.setLanguage();
  334. BDFDB.removeEles(".translate-button-wrapper");
  335. BDFDB.WebModules.forceAllUpdates(this, "ChannelTextArea");
  336. }
  337. }
  338.  
  339. processChannelTextArea (instance, wrapper) {
  340. if (instance.props && instance.props.type && instance.props.type == "normal" && !instance.props.disabled && !wrapper.querySelector(".translate-button-wrapper") && BDFDB.getData("addTranslateButton", this, "settings")) {
  341. let textarea = wrapper.querySelector("textarea");
  342. if (textarea) {
  343. var buttoncontainer = wrapper.querySelector(BDFDB.dotCN.textareapickerbuttons);
  344. if (!buttoncontainer) return;
  345. var translateButton = BDFDB.htmlToElement(this.translateButtonMarkup);
  346. translateButton.addEventListener("click", () => {
  347. this.openTranslatePopout(translateButton);
  348. });
  349. translateButton.addEventListener("contextmenu", () => {
  350. this.translating = !this.translating;
  351. BDFDB.toggleClass(document.querySelectorAll(BDFDB.dotCNS.textareawrapchat + ".translate-button-wrapper"), BDFDB.disCN.textareabuttonactive, this.translating);
  352. });
  353. buttoncontainer.insertBefore(translateButton, buttoncontainer.firstElementChild);
  354. BDFDB.addClass(translateButton, instance.props.type);
  355. BDFDB.toggleClass(translateButton, BDFDB.disCN.textareabuttonactive, this.translating);
  356. BDFDB.addEventListener(this, textarea, "input", () => {
  357. if (this.doTranslate) {
  358. this.doTranslate = false;
  359. if (document.activeElement == textarea) {
  360. var text = textarea.value;
  361. textarea.focus();
  362. textarea.selectionStart = 0;
  363. textarea.selectionEnd = text.length;
  364. document.execCommand("insertText", false, "");
  365. this.translateText(text, "message", (translation, input, output) => {
  366. translation = !translation ? text : (BDFDB.getData("sendOriginalMessage", this, "settings") ? text + "\n\n" + translation : translation);
  367. textarea.focus();
  368. document.execCommand("insertText", false, translation + " ");
  369. BDFDB.triggerSend(textarea);
  370. });
  371. }
  372. }
  373. });
  374. BDFDB.addEventListener(this, textarea, "keydown", e => {
  375. if (textarea.value && this.translating && !e.shiftKey && e.which == 13 && !wrapper.querySelector(BDFDB.dotCN.autocomplete)) {
  376. this.doTranslate = true;
  377. textarea.dispatchEvent(new Event("input"));
  378. }
  379. });
  380. }
  381. }
  382. }
  383.  
  384. processMessage (instance, wrapper) {
  385. if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton) && BDFDB.getReactValue(instance, "props.message.author.id") != 1) {
  386. let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer);
  387. if (buttonwrap) {
  388. let optionPopoutButton = BDFDB.htmlToElement(`<div class="${BDFDB.disCN.optionpopoutbutton}"></div>`);
  389. optionPopoutButton.addEventListener("click", () => {BDFDB.createMessageOptionPopout(optionPopoutButton);});
  390. buttonwrap.appendChild(optionPopoutButton);
  391. }
  392. }
  393. }
  394.  
  395. processMessageOptionPopout (instance, wrapper) {
  396. if (instance.props.message && instance.props.channel && instance._reactInternalFiber.memoizedProps.target && !wrapper.querySelector(".personalpin-itembtn")) {
  397. let {messagediv, pos} = this.getMessageAndPos(instance._reactInternalFiber.memoizedProps.target);
  398. if (!messagediv || pos == -1) return;
  399. let popoutTranslateEntry = BDFDB.htmlToElement(BDFDB.containsClass(messagediv, "translated") ? this.popoutUntranslateEntryMarkup : this.popoutTranslateEntryMarkup);
  400. wrapper.appendChild(popoutTranslateEntry);
  401. popoutTranslateEntry.addEventListener("click", () => {
  402. this.translateMessage(instance.props.message, instance._reactInternalFiber.memoizedProps.target, instance.props.channel);
  403. instance.props.onClose();
  404. });
  405. }
  406. }
  407.  
  408. getMessageAndPos (target) {
  409. let messagediv = BDFDB.getParentEle(BDFDB.dotCN.message, target);
  410. let pos = messagediv ? Array.from(messagediv.parentElement.querySelectorAll(BDFDB.dotCN.message)).indexOf(messagediv) : -1;
  411. return {messagediv, pos};
  412. }
  413.  
  414. translateMessage (message, target, channel) {
  415. if (!message || !target) return;
  416. let {messagediv, pos} = this.getMessageAndPos(target);
  417. if (!messagediv || pos == -1) return;
  418. channel = channel ? channel : this.ChannelUtils.getChannel(message.channel_id);
  419. if (!messagediv.querySelector(BDFDB.dotCN.messageedited + ".translated")) {
  420. var markup = messagediv.querySelector(BDFDB.dotCN.messagemarkup);
  421. var fakemarkup = markup.cloneNode(true);
  422. var oldhtml = markup.innerHTML;
  423. let compactheader = fakemarkup.querySelector(BDFDB.dotCN.messageheadercompact);
  424. if (compactheader) compactheader.remove();
  425. this.translateText(fakemarkup.innerHTML, "context", (translation, input, output) => {
  426. if (translation) {
  427. markup.GoogleTranslateOriginalHTML = oldhtml;
  428. markup.innerHTML = (compactheader ? "<label></label>" : "") + translation.replace(/\n/g, "DevilBroBDFDBPlacerHolderN").replace(/\s/g, " ").replace(/DevilBroBDFDBPlacerHolderN/g, "\n").replace(/ *([<>]) */g, "$1");
  429. let translatestamp = BDFDB.htmlToElement(`<time class="${BDFDB.disCN.messageedited} translated">(${this.labels.translated_watermark_text})</time>`);
  430. translatestamp.addEventListener("mouseenter", () => {
  431. BDFDB.createTooltip(`<div>From: ${input.name}</div><div>To: ${output.name}</div>`, translatestamp, {html:true, type:"top", selector:"translation-tooltip"});
  432. });
  433. markup.appendChild(translatestamp);
  434. BDFDB.addClass(messagediv, "translated");
  435. if (compactheader) markup.insertBefore(compactheader, markup.firstElementChild);
  436. }
  437. });
  438. }
  439. else this.resetMessage(messagediv);
  440. }
  441.  
  442. resetMessage (messagediv) {
  443. BDFDB.removeEles(messagediv.querySelector(BDFDB.dotCN.messageedited + ".translated"));
  444. BDFDB.removeClass(messagediv, "translated");
  445. let markup = messagediv.querySelector(BDFDB.dotCN.messagemarkup);
  446. markup.innerHTML = markup.GoogleTranslateOriginalHTML;
  447. delete markup.GoogleTranslateOriginalHTML;
  448. }
  449.  
  450. translateText (text, type, callback) {
  451. var finishTranslation = (translation, exceptions, input, output, toast) => {
  452. if (translation) translation = this.addExceptions(translation, exceptions);
  453. clearInterval(toast.interval);
  454. toast.close();
  455. callback(translation, input, output);
  456. };
  457. var [newtext, exceptions, translate] = this.removeExceptions(text.trim(), type);
  458. var input = Object.assign({}, this.languages[this.getLanguageChoice("input", type)]);
  459. var output = Object.assign({}, this.languages[this.getLanguageChoice("output", type)]);
  460. var translation = "";
  461. if (translate) {
  462. var toast = BDFDB.showToast("Translating. Please wait", {timeout:0});
  463. toast.interval = setInterval(() => {
  464. toast.textContent = toast.textContent.indexOf(".....") > -1 ? "Translating. Please wait" : toast.textContent + ".";
  465. },500);
  466. if (input.id == "binary" || output.id == "binary" || input.id == "auto" && /^[0-1]*$/.test(newtext.replace(/\s/g, ""))) {
  467. if ((input.id == "binary" || input.id == "auto") && output.id != "binary") {
  468. input.name = "Binary";
  469. translation = this.binary2string(newtext);
  470. }
  471. else if (input.id != "binary" && output.id == "binary") {
  472. translation = this.string2binary(newtext);
  473. }
  474. else if ((input.id == "binary" || input.id == "auto") && output.id == "binary") {
  475. input.name = "binary";
  476. translation = newtext;
  477. }
  478. finishTranslation(translation, exceptions, input, output, toast);
  479. }
  480. else {
  481. require("request")(this.getGoogleTranslateApiURL(input.id, output.id, newtext), (error, response, result) => {
  482. if (!error && result) {
  483. result = JSON.parse(result);
  484. result[0].forEach((array) => {translation += array[0];});
  485. if (this.languages[result[2]]) input.name = this.languages[result[2]].name;
  486. finishTranslation(translation, exceptions, input, output, toast);
  487. }
  488. });
  489. }
  490. }
  491. else {
  492. translation = text;
  493. finishTranslation(translation, exceptions, input, output, toast);
  494. }
  495. }
  496.  
  497. addExceptions (string, exceptions) {
  498. for (let i in exceptions) string = string.replace("a" + i + "_______", exceptions[i].indexOf("!") == 0 ? exceptions[i].slice(1) : exceptions[i]);
  499. return string;
  500. }
  501.  
  502. removeExceptions (string, type) {
  503. var exceptions = {}, newString = [], count = 0;
  504. if (type == "context") {
  505. let text = [], i = 0;
  506. string.split("").forEach(chara => {
  507. if (chara == "<" && text[i]) i++;
  508. text[i] = text[i] ? text[i] + chara : chara;
  509. if (chara == ">") i++;
  510. });
  511. for (let j in text) {
  512. if (text[j].indexOf("<") == 0) {
  513. newString.push("a" + count + "_______");
  514. exceptions[count] = text[j];
  515. count++;
  516. }
  517. else newString.push(text[j]);
  518. }
  519. }
  520. else {
  521. string.split(" ").forEach(word => {
  522. if (word.indexOf("<@!") == 0 || word.indexOf(":") == 0 || word.indexOf("@") == 0 || word.indexOf("#") == 0 || (word.indexOf("!") == 0 && word.length > 1)) {
  523. newString.push("a" + count + "_______");
  524. exceptions[count] = word;
  525. count++;
  526. }
  527. else newString.push(word);
  528. });
  529. }
  530. return [newString.join(" "), exceptions, newString.length-count != 0];
  531. }
  532.  
  533. openTranslatePopout (button) {
  534. let container = document.querySelector(BDFDB.dotCN.popouts);
  535. if (!container || BDFDB.containsClass(button, "popout-open")) return;
  536. BDFDB.addClass(button, "popout-open");
  537. let translatepopout = BDFDB.htmlToElement(this.translatePopoutMarkup);
  538. container.appendChild(translatepopout);
  539. let buttonrects = BDFDB.getRects(button);
  540. translatepopout.style.setProperty("left", buttonrects.left + buttonrects.width + "px");
  541. translatepopout.style.setProperty("top", buttonrects.top - buttonrects.height/2 + "px")
  542.  
  543. BDFDB.addChildEventListener(translatepopout, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu("inChat", e);});
  544. BDFDB.addChildEventListener(translatepopout, "click", ".reverse-button", e => {
  545. let place = e.currentTarget.getAttribute("type").replace("output","");
  546. let input = this.getLanguageChoice("output", place);
  547. let output = this.getLanguageChoice("input", place);
  548. output = output == "auto" ? "en" : output;
  549. let inputselect = translatepopout.querySelector(BDFDB.dotCN.select + "[type='input" + place + "']");
  550. let outputselect = translatepopout.querySelector(BDFDB.dotCN.select + "[type='output" + place + "']");
  551. inputselect.setAttribute("value", input);
  552. inputselect.querySelector(BDFDB.dotCN.title).innerText = this.languages[input].name;
  553. outputselect.setAttribute("value", output);
  554. outputselect.querySelector(BDFDB.dotCN.title).innerText = this.languages[output].name;
  555. BDFDB.saveData("input" + place, input, this, "choices");
  556. BDFDB.saveData("output" + place, output, this, "choices");
  557. });
  558.  
  559. translatepopout.querySelectorAll(BDFDB.dotCN.select).forEach(selectWrap => {
  560. let language = this.getLanguageChoice(selectWrap.getAttribute("type"));
  561. selectWrap.setAttribute("value", language);
  562. selectWrap.querySelector(BDFDB.dotCN.title).innerText = this.languages[language].name;
  563. });
  564.  
  565. var translatecheckbox = translatepopout.querySelector("#translating-checkbox");
  566. translatecheckbox.checked = this.translating;
  567. translatecheckbox.addEventListener("click", () => {
  568. BDFDB.toggleClass(button, BDFDB.disCN.textareabuttonactive, translatecheckbox.checked);
  569. this.translating = translatecheckbox.checked;
  570. });
  571.  
  572. var removePopout = e => {
  573. if (!translatepopout.contains(e.target)) {
  574. document.removeEventListener("mousedown", removePopout);
  575. translatepopout.remove();
  576. setTimeout(() => {BDFDB.removeClass(button, "popout-open");},300);
  577. }
  578. };
  579. document.addEventListener("mousedown", removePopout);
  580.  
  581. BDFDB.initElements(translatepopout, this);
  582. }
  583.  
  584. openDropdownMenu (selector, e) {
  585. let selectControl = e.currentTarget;
  586. let selectWrap = selectControl.parentElement;
  587. let plugincard = selector == "inSettings" ? BDFDB.getParentEle("li", selectWrap) : document.createElement("div");
  588.  
  589. if (!plugincard || BDFDB.containsClass(selectWrap, BDFDB.disCN.selectisopen)) return;
  590.  
  591. BDFDB.addClass(selectWrap, BDFDB.disCN.selectisopen);
  592. plugincard.style.setProperty("overflow", "visible", "important");
  593.  
  594. var type = selectWrap.getAttribute("type");
  595. var selectMenu = this.createDropdownMenu(selectWrap.getAttribute("value"), type);
  596. BDFDB.addClass(selectMenu, selector);
  597. selectWrap.appendChild(selectMenu);
  598.  
  599. BDFDB.addChildEventListener(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => {
  600. var language = e2.currentTarget.getAttribute("value");
  601. selectWrap.setAttribute("value", language);
  602. selectControl.querySelector(BDFDB.dotCN.title).innerText = this.languages[language].name;
  603. BDFDB.saveData(type, language, this, "choices");
  604. });
  605.  
  606. var removeMenu = e2 => {
  607. if (e2.target.parentElement != selectMenu) {
  608. document.removeEventListener("mousedown", removeMenu);
  609. selectMenu.remove();
  610. plugincard.style.removeProperty("overflow");
  611. setTimeout(() => {BDFDB.removeClass(selectWrap, BDFDB.disCN.selectisopen);},100);
  612. }
  613. };
  614. document.addEventListener("mousedown", removeMenu);
  615. }
  616.  
  617. createDropdownMenu (choice, type) {
  618. var menuhtml = `<div class="${BDFDB.disCN.selectmenuouter}"><div class="${BDFDB.disCN.selectmenu}">`;
  619. for (var key in this.languages) {
  620. if (this.defaults.choices[type].direction == "Output" && key == "auto") continue;
  621. var isSelected = key == choice ? ` ${BDFDB.disCN.selectselected}` : ``;
  622. menuhtml += `<div value="${key}" class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.selectoption + isSelected}" style="flex: 1 1 auto; display:flex;"><div class="${BDFDB.disCNS.title + BDFDB.disCNS.medium + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.primary + BDFDB.disCN.weightnormal}" style="flex: 1 1 42%;">${this.languages[key].name}</div></div>`
  623. }
  624. menuhtml += `</div></div>`;
  625. return BDFDB.htmlToElement(menuhtml);
  626. }
  627.  
  628. string2binary (string) {
  629. var binary = "";
  630. for (var character of string) binary += parseInt(character.charCodeAt(0).toString(2)).toPrecision(8).split(".").reverse().join("").toString() + " ";
  631. return binary;
  632. }
  633.  
  634. binary2string (binary) {
  635. var string = "";
  636. binary = binary.replace(/\n/g, "00001010").replace(/\r/g, "00001101").replace(/\t/g, "00001001").replace(/\s/g, "");
  637. if (/^[0-1]*$/.test(binary)) {
  638. var eightdigits = "";
  639. var counter = 0;
  640. for (var digit of binary) {
  641. eightdigits += digit;
  642. counter++;
  643. if (counter > 7) {
  644. string += String.fromCharCode(parseInt(eightdigits,2).toString(10));
  645. eightdigits = "";
  646. counter = 0;
  647. }
  648. }
  649. }
  650. else BDFDB.showToast("Invalid binary format. Only use 0s and 1s.", {type:"error"});
  651. return string;
  652. }
  653.  
  654. getGoogleTranslateApiURL (input, output, text) {
  655. return "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" + input + "&tl=" + output + "&dt=t&ie=UTF-8&oe=UTF-8&q=" + encodeURIComponent(text);
  656. }
  657.  
  658. getGoogleTranslatePageURL (input, output, text) {
  659. return "https://translate.google.com/#" + input + "/" + output + "/" + encodeURIComponent(text);
  660. }
  661.  
  662. setLabelsByLanguage () {
  663. switch (BDFDB.getDiscordLanguage().id) {
  664. case "hr": //croatian
  665. return {
  666. context_messagetranslateoption_text: "Prijevod poruke",
  667. context_messageuntranslateoption_text: "Prijenos poruke",
  668. context_googletranslateoption_text: "Traži prijevod",
  669. popout_translateoption_text: "Prevesti",
  670. popout_untranslateoption_text: "Prevesti natrag",
  671. translated_watermark_text: "preveo"
  672. };
  673. case "da": //danish
  674. return {
  675. context_messagetranslateoption_text: "Oversæt Besked",
  676. context_messageuntranslateoption_text: "Oversæt Besked tilbage",
  677. context_googletranslateoption_text: "Søg oversættelse",
  678. popout_translateoption_text: "Oversætte",
  679. popout_untranslateoption_text: "Oversæt tilbage",
  680. translated_watermark_text: "oversat"
  681. };
  682. case "de": //german
  683. return {
  684. context_messagetranslateoption_text: "Nachricht übersetzen",
  685. context_messageuntranslateoption_text: "Nachricht unübersetzen",
  686. context_googletranslateoption_text: "Suche Übersetzung",
  687. popout_translateoption_text: "Übersetzen",
  688. popout_untranslateoption_text: "Unübersetzen",
  689. translated_watermark_text: "übersetzt"
  690. };
  691. case "es": //spanish
  692. return {
  693. context_messagetranslateoption_text: "Traducir mensaje",
  694. context_messageuntranslateoption_text: "Traducir mensaje de vuelta",
  695. context_googletranslateoption_text: "Buscar traducción",
  696. popout_translateoption_text: "Traducir",
  697. popout_untranslateoption_text: "Traducir de vuelta",
  698. translated_watermark_text: "traducido"
  699. };
  700. case "fr": //french
  701. return {
  702. context_messagetranslateoption_text: "Traduire le message",
  703. context_messageuntranslateoption_text: "Traduire le message en retour",
  704. context_googletranslateoption_text: "Rechercher une traduction",
  705. popout_translateoption_text: "Traduire",
  706. popout_untranslateoption_text: "Traduire en arrière",
  707. translated_watermark_text: "traduit"
  708. };
  709. case "it": //italian
  710. return {
  711. context_messagetranslateoption_text: "Tradurre il messaggio",
  712. context_messageuntranslateoption_text: "Tradurre il messaggio indietro",
  713. context_googletranslateoption_text: "Cerca la traduzione",
  714. popout_translateoption_text: "Traduci",
  715. popout_untranslateoption_text: "Traduci indietro",
  716. translated_watermark_text: "tradotto"
  717. };
  718. case "nl": //dutch
  719. return {
  720. context_messagetranslateoption_text: "Vertaal bericht",
  721. context_messageuntranslateoption_text: "Vertaal bericht terug",
  722. context_googletranslateoption_text: "Zoek vertaling",
  723. popout_translateoption_text: "Vertaal",
  724. popout_untranslateoption_text: "Vertaal terug",
  725. translated_watermark_text: "vertaalde"
  726. };
  727. case "no": //norwegian
  728. return {
  729. context_messagetranslateoption_text: "Oversett melding",
  730. context_messageuntranslateoption_text: "Oversett melding tilbake",
  731. context_googletranslateoption_text: "Søk oversettelse",
  732. popout_translateoption_text: "Oversett",
  733. popout_untranslateoption_text: "Oversett tilbake",
  734. translated_watermark_text: "oversatt"
  735. };
  736. case "pl": //polish
  737. return {
  738. context_messagetranslateoption_text: "Przetłumacz wiadomość",
  739. context_messageuntranslateoption_text: "Przetłumacz wiadomość z powrotem",
  740. context_googletranslateoption_text: "Wyszukaj tłumaczenie",
  741. popout_translateoption_text: "Przetłumacz",
  742. popout_untranslateoption_text: "Przetłumacz ponownie",
  743. translated_watermark_text: "przetłumaczony"
  744. };
  745. case "pt-BR": //portuguese (brazil)
  746. return {
  747. context_messagetranslateoption_text: "Traduzir mensagem",
  748. context_messageuntranslateoption_text: "Traduzir mensagem de volta",
  749. context_googletranslateoption_text: "Pesquisar tradução",
  750. popout_translateoption_text: "Traduzir",
  751. popout_untranslateoption_text: "Traduzir de volta",
  752. translated_watermark_text: "traduzido"
  753. };
  754. case "fi": //finnish
  755. return {
  756. context_messagetranslateoption_text: "Käännä viesti",
  757. context_messageuntranslateoption_text: "Käännä viesti takaisin",
  758. context_googletranslateoption_text: "Etsi käännös",
  759. popout_translateoption_text: "Kääntää",
  760. popout_untranslateoption_text: "Käännä takaisin",
  761. translated_watermark_text: "käännetty"
  762. };
  763. case "sv": //swedish
  764. return {
  765. context_messagetranslateoption_text: "Översätt meddelande",
  766. context_messageuntranslateoption_text: "Översätt meddelandet tillbaka",
  767. context_googletranslateoption_text: "Sök översättning",
  768. popout_translateoption_text: "Översätt",
  769. popout_untranslateoption_text: "Översätt tillbaka",
  770. translated_watermark_text: "översatt"
  771. };
  772. case "tr": //turkish
  773. return {
  774. context_messagetranslateoption_text: "Mesajı çevir",
  775. context_messageuntranslateoption_text: "İletiyi geri çevir",
  776. context_googletranslateoption_text: "Arama tercümesi",
  777. popout_translateoption_text: "Çevirmek",
  778. popout_untranslateoption_text: "Geri çevir",
  779. translated_watermark_text: "tercüme"
  780. };
  781. case "cs": //czech
  782. return {
  783. context_messagetranslateoption_text: "Přeposlat zprávu",
  784. context_messageuntranslateoption_text: "Přeposlat zprávu zpátky",
  785. context_googletranslateoption_text: "Hledat překlad",
  786. popout_translateoption_text: "Přeposlat",
  787. popout_untranslateoption_text: "Přeposlat zpět",
  788. translated_watermark_text: "přeloženo"
  789. };
  790. case "bg": //bulgarian
  791. return {
  792. context_messagetranslateoption_text: "Преведете на съобщението",
  793. context_messageuntranslateoption_text: "Преведете съобщението обратно",
  794. context_googletranslateoption_text: "Търсене на превод",
  795. popout_translateoption_text: "Превод",
  796. popout_untranslateoption_text: "Превод обратно",
  797. translated_watermark_text: "преведена"
  798. };
  799. case "ru": //russian
  800. return {
  801. context_messagetranslateoption_text: "Перевести сообщение",
  802. context_messageuntranslateoption_text: "Перевести сообщение обратно",
  803. context_googletranslateoption_text: "Поиск перевода",
  804. popout_translateoption_text: "Перевести",
  805. popout_untranslateoption_text: "Перевести обратно",
  806. translated_watermark_text: "переведенный"
  807. };
  808. case "uk": //ukrainian
  809. return {
  810. context_messagetranslateoption_text: "Перекласти повідомлення",
  811. context_messageuntranslateoption_text: "Перекласти повідомлення назад",
  812. context_googletranslateoption_text: "Пошук перекладу",
  813. popout_translateoption_text: "Перекласти",
  814. popout_untranslateoption_text: "Перекласти назад",
  815. translated_watermark_text: "перекладений"
  816. };
  817. case "ja": //japanese
  818. return {
  819. context_messagetranslateoption_text: "メッセージを翻訳する",
  820. context_messageuntranslateoption_text: "メッセージを翻訳する",
  821. context_googletranslateoption_text: "翻訳の検索",
  822. popout_translateoption_text: "翻訳",
  823. popout_untranslateoption_text: "翻訳する",
  824. translated_watermark_text: "翻訳された"
  825. };
  826. case "zh-TW": //chinese (traditional)
  827. return {
  828. context_messagetranslateoption_text: "翻譯消息",
  829. context_messageuntranslateoption_text: "翻譯消息",
  830. context_googletranslateoption_text: "搜索翻譯",
  831. popout_translateoption_text: "翻譯",
  832. popout_untranslateoption_text: "翻譯回來",
  833. translated_watermark_text: "翻譯"
  834. };
  835. case "ko": //korean
  836. return {
  837. context_messagetranslateoption_text: "메시지 번역",
  838. context_messageuntranslateoption_text: "메시지 번역 뒤로",
  839. context_googletranslateoption_text: "검색 번역",
  840. popout_translateoption_text: "다시",
  841. popout_untranslateoption_text: "다시 번역",
  842. translated_watermark_text: "번역 된"
  843. };
  844. default: //default: english
  845. return {
  846. context_messagetranslateoption_text: "Translate Message",
  847. context_messageuntranslateoption_text: "Untranslate Message",
  848. context_googletranslateoption_text: "Search translation",
  849. popout_translateoption_text: "Translate",
  850. popout_untranslateoption_text: "Untranslate",
  851. translated_watermark_text: "translated"
  852. };
  853. }
  854. }
  855. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement