Bug 1518076 - Use localised strings in WeTransfer settings page. r=philipp
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 10 Jan 2019 10:17:26 +1300
changeset 34151 2959a4850c6e6fe010cfebec8b8d3dd08a896b5a
parent 34150 19ea5e83ca7286c2ffc684a61b7b7961a742b9e5
child 34152 14387ecf405c969076dc3251b6944fce4655d204
push id389
push userclokep@gmail.com
push dateMon, 18 Mar 2019 19:01:53 +0000
reviewersphilipp
bugs1518076
Bug 1518076 - Use localised strings in WeTransfer settings page. r=philipp
mail/components/cloudfile/wetransfer/_locales/en/messages.json
mail/components/cloudfile/wetransfer/content/moments.html
mail/components/cloudfile/wetransfer/content/moments.js
--- a/mail/components/cloudfile/wetransfer/_locales/en/messages.json
+++ b/mail/components/cloudfile/wetransfer/_locales/en/messages.json
@@ -2,10 +2,16 @@
   "extensionDescription": {
     "message": "Share your attachments via WeTransfer"
   },
   "extensionName": {
     "message": "FileLink for WeTransfer"
   },
   "serviceName": {
     "message": "WeTransfer"
+  },
+  "moments_privacyPolicy": {
+    "message": "Privacy Policy"
+  },
+  "moments_tagline": {
+    "message": "WeTransfer is the simplest way to send your files around the world."
   }
 }
--- a/mail/components/cloudfile/wetransfer/content/moments.html
+++ b/mail/components/cloudfile/wetransfer/content/moments.html
@@ -1,20 +1,20 @@
 <!DOCTYPE html>
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <html>
   <head>
-    <script src="moments.js"></script>
+    <script src="moments.js" defer=""></script>
     <meta charset="UTF-8">
     <link rel="stylesheet" type="text/css" href="moments.css"/>
   </head>
   <body>
-    <h1>WeTransfer is the simplest way to send your files around the world.</h1>
-    <a class="text-link" href="https://wetransfer.com/legal/terms" target="_blank">Privacy Policy</a>
+    <h1 data-message="moments_tagline"></h1>
+    <a class="text-link" href="https://wetransfer.com/legal/terms" target="_blank" data-message="moments_privacyPolicy"></a>
     <a id="story" href="#" target="_blank">
       <img id="background"></img>
       <div id="title"></div>
     </a>
   </body>
 </html>
--- a/mail/components/cloudfile/wetransfer/content/moments.js
+++ b/mail/components/cloudfile/wetransfer/content/moments.js
@@ -1,13 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 (async () => {
+  for (let element of document.querySelectorAll("[data-message]")) {
+    element.textContent = browser.i18n.getMessage(element.dataset.message);
+  }
+
   let resp = await fetch("https://backgrounds.wetransfer.net/moment/list.json");
   let items = await resp.json();
   let item = items[Math.floor(Math.random() * items.length)];
   if (item.url.startsWith("https:") && item.file.startsWith("https:")) {
     document.getElementById("background").src = item.file;
     document.getElementById("story").href = item.url;
     document.getElementById("title").textContent = item.title;
   }