├── Images └── Close.png ├── readme-images ├── new-mail.PNG ├── addin-list.PNG ├── text-selected.PNG ├── browse-manifest.PNG ├── outlook-on-web.PNG ├── text-translated.PNG ├── o365-manage-addins.PNG └── outlook-manage-addins.PNG ├── AppCompose ├── Home │ ├── Home.css │ ├── Home.html │ └── Home.js ├── App.css ├── FunctionFile │ ├── Home.html │ └── Translator.js ├── TranslateHelper.js └── App.js ├── Outlook-Add-in-Commands-Translator.yml ├── LICENSE ├── TranslateAppManifest.xml ├── Content └── Office.css └── README.md /Images/Close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Outlook-Add-in-Commands-Translator/HEAD/Images/Close.png -------------------------------------------------------------------------------- /readme-images/new-mail.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Outlook-Add-in-Commands-Translator/HEAD/readme-images/new-mail.PNG -------------------------------------------------------------------------------- /readme-images/addin-list.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Outlook-Add-in-Commands-Translator/HEAD/readme-images/addin-list.PNG -------------------------------------------------------------------------------- /readme-images/text-selected.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Outlook-Add-in-Commands-Translator/HEAD/readme-images/text-selected.PNG -------------------------------------------------------------------------------- /readme-images/browse-manifest.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Outlook-Add-in-Commands-Translator/HEAD/readme-images/browse-manifest.PNG -------------------------------------------------------------------------------- /readme-images/outlook-on-web.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Outlook-Add-in-Commands-Translator/HEAD/readme-images/outlook-on-web.PNG -------------------------------------------------------------------------------- /readme-images/text-translated.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Outlook-Add-in-Commands-Translator/HEAD/readme-images/text-translated.PNG -------------------------------------------------------------------------------- /readme-images/o365-manage-addins.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Outlook-Add-in-Commands-Translator/HEAD/readme-images/o365-manage-addins.PNG -------------------------------------------------------------------------------- /readme-images/outlook-manage-addins.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Outlook-Add-in-Commands-Translator/HEAD/readme-images/outlook-manage-addins.PNG -------------------------------------------------------------------------------- /AppCompose/Home/Home.css: -------------------------------------------------------------------------------- 1 | /* Page-specific styling */ 2 | 3 | /* Formatting for the sample buttons */ 4 | 5 | #set-subject { 6 | width: 100px; 7 | margin-right: 5px; 8 | } 9 | 10 | #get-subject { 11 | width: 100px; 12 | } 13 | 14 | #add-to-recipients { 15 | width: 205px; 16 | } 17 | -------------------------------------------------------------------------------- /Outlook-Add-in-Commands-Translator.yml: -------------------------------------------------------------------------------- 1 | ### YamlMime:Sample 2 | sample: 3 | - name: Outlook-Add-in-Commands-Translator 4 | path: '' 5 | description: The Translator add-in uses the commands model for Outlook add-ins to add a button to the ribbon in the new message form. 6 | readme: '' 7 | generateZip: False 8 | isLive: True 9 | technologies: 10 | - Add-ins 11 | azureDeploy: '' 12 | author: '' 13 | platforms: [] 14 | languages: 15 | - JavaScript 16 | extensions: 17 | type: samples 18 | products: 19 | - Outlook 20 | scenarios: [] 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Microsoft 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /AppCompose/App.css: -------------------------------------------------------------------------------- 1 | /* Common app styling */ 2 | 3 | #content-header { 4 | background: #2a8dd4; 5 | color: #fff; 6 | position: absolute; 7 | top: 0; 8 | left: 0; 9 | width: 100%; 10 | height: 80px; /* Fixed header height */ 11 | overflow: hidden; /* Disable scrollbars for header */ 12 | } 13 | 14 | #content-main { 15 | background: #fff; 16 | position: fixed; 17 | top: 80px; /* Same value as #content-header's height */ 18 | left: 0; 19 | right: 0; 20 | bottom: 0; 21 | overflow: auto; /* Enable scrollbars within main content section */ 22 | } 23 | 24 | .padding { 25 | padding: 15px; 26 | } 27 | 28 | #notification-message { 29 | background-color: #818285; 30 | color: #fff; 31 | position: absolute; 32 | width: 100%; 33 | min-height: 80px; 34 | right: 0; 35 | z-index: 100; 36 | bottom: 0; 37 | display: none; /* Hidden until invoked */ 38 | } 39 | 40 | #notification-message #notification-message-header { 41 | font-size: medium; 42 | margin-bottom: 10px; 43 | } 44 | 45 | #notification-message #notification-message-close { 46 | background-image: url("../Images/Close.png"); 47 | background-repeat: no-repeat; 48 | width: 24px; 49 | height: 24px; 50 | position: absolute; 51 | right: 5px; 52 | top: 5px; 53 | cursor: pointer; 54 | } 55 | -------------------------------------------------------------------------------- /AppCompose/FunctionFile/Home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /AppCompose/TranslateHelper.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 2 | 3 | // Helper function to generate an API request 4 | // URL to the Yandex translator service 5 | function generateRequestUrl(text) { 6 | // Split the selected data into individual lines 7 | var tempLines = text.split(/\r\n|\r|\n/g); 8 | var lines = []; 9 | 10 | // Add non-empty lines to the data to translate 11 | for (var i = 0; i < tempLines.length; i++) 12 | if (tempLines[i] != "") 13 | lines.push(tempLines[i]); 14 | 15 | // Add each line as a 'text' query parameter 16 | var encodedText = ""; 17 | for (var i = 0; i < (lines.length) ; i++) { 18 | encodedText += "&text=" + encodeURI(lines[i].replace(/ /g, "+")); 19 | } 20 | 21 | // API Key for the yandex service 22 | // Get one at https://translate.yandex.com/developers 23 | var apiKey = "YOUR API KEY HERE"; 24 | 25 | return "https://translate.yandex.net/api/v1.5/tr.json/translate?key=" + apiKey + "&lang=en-ru" + encodedText; 26 | } 27 | 28 | // MIT License: 29 | 30 | // Permission is hereby granted, free of charge, to any person obtaining 31 | // a copy of this software and associated documentation files (the 32 | // ""Software""), to deal in the Software without restriction, including 33 | // without limitation the rights to use, copy, modify, merge, publish, 34 | // distribute, sublicense, and/or sell copies of the Software, and to 35 | // permit persons to whom the Software is furnished to do so, subject to 36 | // the following conditions: 37 | 38 | // The above copyright notice and this permission notice shall be 39 | // included in all copies or substantial portions of the Software. 40 | 41 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, 42 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 43 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 44 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 45 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 46 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 47 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /AppCompose/App.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 2 | 3 | /* Common app functionality */ 4 | 5 | var app = (function () { 6 | "use strict"; 7 | 8 | var app = {}; 9 | 10 | // Common initialization function (to be called from each page) 11 | app.initialize = function () { 12 | $('body').append( 13 | '
' + 14 | '
' + 15 | '
' + 16 | '
' + 17 | '
' + 18 | '
' + 19 | '
'); 20 | 21 | $('#notification-message-close').click(function () { 22 | $('#notification-message').hide(); 23 | }); 24 | 25 | 26 | // After initialization, expose a common notification function 27 | app.showNotification = function (header, text) { 28 | $('#notification-message-header').text(header); 29 | $('#notification-message-body').text(text); 30 | $('#notification-message').slideDown('fast'); 31 | }; 32 | }; 33 | 34 | return app; 35 | })(); 36 | 37 | // MIT License: 38 | 39 | // Permission is hereby granted, free of charge, to any person obtaining 40 | // a copy of this software and associated documentation files (the 41 | // ""Software""), to deal in the Software without restriction, including 42 | // without limitation the rights to use, copy, modify, merge, publish, 43 | // distribute, sublicense, and/or sell copies of the Software, and to 44 | // permit persons to whom the Software is furnished to do so, subject to 45 | // the following conditions: 46 | 47 | // The above copyright notice and this permission notice shall be 48 | // included in all copies or substantial portions of the Software. 49 | 50 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, 51 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 52 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 53 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 54 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 55 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 56 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /AppCompose/Home/Home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |

Translator

30 |
31 |
32 |
33 |
34 | 35 | 36 |

37 | Find more samples online... 38 |

39 |
40 |
41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /AppCompose/Home/Home.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 2 | 3 | /// 4 | 5 | (function () { 6 | 'use strict'; 7 | 8 | // The initialize function must be run each time a new page is loaded 9 | Office.initialize = function (reason) { 10 | $(document).ready(function () { 11 | app.initialize(); 12 | 13 | $('#translate').click(translateSelection); 14 | }); 15 | }; 16 | 17 | function translateSelection() { 18 | Office.context.mailbox.item.getSelectedDataAsync("text", function (ar) { 19 | 20 | // Make sure there is a selection 21 | if (ar === undefined || ar === null || 22 | ar.value === undefined || ar.value === null || 23 | ar.value.data === undefined || ar.value.data === null) { 24 | // Display an error message 25 | app.showNotification("No text selected!", "Please select text to translate and try again."); 26 | return; 27 | } 28 | 29 | // Generate the API call URL 30 | var requestUrl = generateRequestUrl(ar.value.data); 31 | 32 | $.ajax({ 33 | url: requestUrl, 34 | jsonp: "callback", 35 | dataType: "jsonp", 36 | success: function (response) { 37 | var translatedText = response.text; 38 | var textToWrite = ""; 39 | 40 | // The response is an array of one or more translated lines. 41 | // Append them together with
tags. 42 | for (var i = 0; i < translatedText.length; i++) 43 | textToWrite += translatedText[i] + "

"; 44 | 45 | // Replace the selected text with the translated version 46 | Office.context.mailbox.item.setSelectedDataAsync(textToWrite, { coercionType: "html" }, function(asyncResult){ 47 | app.showNotification("Success", "Translated successfully"); 48 | }); 49 | } 50 | }); 51 | }); 52 | } 53 | })(); 54 | 55 | // MIT License: 56 | 57 | // Permission is hereby granted, free of charge, to any person obtaining 58 | // a copy of this software and associated documentation files (the 59 | // ""Software""), to deal in the Software without restriction, including 60 | // without limitation the rights to use, copy, modify, merge, publish, 61 | // distribute, sublicense, and/or sell copies of the Software, and to 62 | // permit persons to whom the Software is furnished to do so, subject to 63 | // the following conditions: 64 | 65 | // The above copyright notice and this permission notice shall be 66 | // included in all copies or substantial portions of the Software. 67 | 68 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, 69 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 70 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 71 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 72 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 73 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 74 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /AppCompose/FunctionFile/Translator.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file. 2 | 3 | Office.initialize = function () { 4 | } 5 | 6 | function translate(event) { 7 | Office.context.mailbox.item.getSelectedDataAsync("text", function (ar) { 8 | 9 | // Make sure there is a selection 10 | if (ar === undefined || ar === null || 11 | ar.value === undefined || ar.value === null || 12 | ar.value.data === undefined || ar.value.data === null) { 13 | // Display an error message 14 | Office.context.mailbox.item.notificationMessages.addAsync("noSelectionError", { 15 | type: "errorMessage", 16 | message: "No text selected! Please select text to translate and try again." 17 | }); 18 | 19 | // Signal that we are done. 20 | event.completed(); 21 | return; 22 | } 23 | 24 | try { 25 | // Generate the API call URL 26 | var requestUrl = generateRequestUrl(ar.value.data); 27 | 28 | $.ajax({ 29 | url: requestUrl, 30 | jsonp: "callback", 31 | dataType: "jsonp", 32 | success: function (response) { 33 | var translatedText = response.text; 34 | var textToWrite = ""; 35 | 36 | // The response is an array of one or more translated lines. 37 | // Append them together with
tags. 38 | for (var i = 0; i < translatedText.length; i++) 39 | textToWrite += translatedText[i] + "
"; 40 | 41 | // Replace the selected text with the translated version 42 | Office.context.mailbox.item.setSelectedDataAsync(textToWrite, { coercionType: "html" }, function (asyncResult) { 43 | Office.context.mailbox.item.notificationMessages.addAsync("success", { 44 | type: "informationalMessage", 45 | icon: "icon1_16x16", 46 | message: "Translated successfully", 47 | persistent: false 48 | }); 49 | 50 | // Signal that we are done. 51 | event.completed(); 52 | }); 53 | } 54 | }); 55 | } 56 | catch (err) { 57 | Office.context.mailbox.item.notificationMessages.addAsync("translateError", { 58 | type: "errorMessage", 59 | message: "ERROR translating message: " + err.message 60 | }); 61 | 62 | // Signal that we are done. 63 | event.completed(); 64 | } 65 | }); 66 | } 67 | 68 | // MIT License: 69 | 70 | // Permission is hereby granted, free of charge, to any person obtaining 71 | // a copy of this software and associated documentation files (the 72 | // ""Software""), to deal in the Software without restriction, including 73 | // without limitation the rights to use, copy, modify, merge, publish, 74 | // distribute, sublicense, and/or sell copies of the Software, and to 75 | // permit persons to whom the Software is furnished to do so, subject to 76 | // the following conditions: 77 | 78 | // The above copyright notice and this permission notice shall be 79 | // included in all copies or substantial portions of the Software. 80 | 81 | // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, 82 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 83 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 84 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 85 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 86 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 87 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /TranslateAppManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 8fbdd69c-2cfb-4a6e-aec4-cc316ed4e5e0 10 | 1.0.0.0 11 | Microsoft Outlook Dev Center 12 | en-US 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
31 |
32 | ReadWriteItem 33 | 34 | false 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |