Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
bug967046 Localize Email
Browse files Browse the repository at this point in the history
  • Loading branch information
alicoding committed Apr 22, 2014
1 parent 1a3883b commit c7a94f5
Show file tree
Hide file tree
Showing 8 changed files with 289 additions and 37 deletions.
34 changes: 29 additions & 5 deletions index.js
Expand Up @@ -4,7 +4,25 @@ var AWS = require("aws-sdk"),
new nunjucks.FileSystemLoader(__dirname + "/templates/"),
{ autoescape: true }
),
premailer = require('premailer-api');
premailer = require('premailer-api'),
i18n = require('webmaker-i18n'),
path = require('path');

// Setup locales with i18n
i18n.middleware({
supported_languages: ['*'],
default_lang: "en-US",
translation_directory: path.resolve(__dirname, "locale")
});

nunjucksEnv.addFilter("instantiate", function (input) {
var tmpl = new nunjucks.Template(input);
return tmpl.render(this.getVariables());
});

function isLanguageSupport(locale) {
return i18n.getSupportLanguages().indexOf(locale) !== -1;
};

module.exports = function(options) {
if (!options.key) {
Expand All @@ -27,8 +45,11 @@ module.exports = function(options) {

return {
sendCreateEventEmail: function(options, callback) {
options.locale = isLanguageSupport(options.locale) ? options.locale : "en-US";
var html = templates.createEventEmail.render({
fullName: options.fullName
fullName: options.fullName,
gettext: i18n.getStrings(options.locale),
locale: options.locale
});

premailer.prepare({
Expand All @@ -45,7 +66,7 @@ module.exports = function(options) {
},
Message: {
Subject: {
Data: "Next steps for your event",
Data: i18n.gettext("Next steps for your event", options.locale),
Charset: "utf8"
},
Body: {
Expand All @@ -63,8 +84,11 @@ module.exports = function(options) {
});
},
sendWelcomeEmail: function(options, callback) {
options.locale = isLanguageSupport(options.locale) ? options.locale : "en-US";
var html = templates.welcomeEmail.render({
fullName: options.fullName
fullName: options.fullName,
gettext: i18n.getStrings(options.locale),
locale: options.locale
});

premailer.prepare({
Expand All @@ -81,7 +105,7 @@ module.exports = function(options) {
},
Message: {
Subject: {
Data: "Welcome to Webmaker. Let's get you started.",
Data: i18n.gettext("emailTitle", options.locale),
Charset: "utf8"
},
Body: {
Expand Down
70 changes: 70 additions & 0 deletions locale/en_US/create_events.json
@@ -0,0 +1,70 @@
{
"Next steps for your event": {
"message": "Next steps for your event",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"heyFullName": {
"message": "Hey {{ fullName }},",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"p1ThanksForRegistering": {
"message": "Thank you for registering your event on our global map and joining our community around the world hosting Maker Party’s. We're excited to teach and learn the web with you! The key to a successful event is planning, so we've put together a checklist to help you along the way:",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"beforeYourEvent": {
"message": "Before your event",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"visitOurGetInvolved": {
"message": "Visit our <a href=\"https://wiki.mozilla.org/Maker_Party/Get_involved\">Get Involved</a> page for everything you need to throw your party.",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"startPlanningUsingThese": {
"message": "Start planning using these helpful <a href=\"https://webmaker.org/{{locale}}/event-guides\">event guides</a>.",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"requestGear": {
"message": "Request a free <a href=\"https://intlstore.mozilla.org/makerparty/\">Maker Party gear pack</a> that includes stickers, t-shirts and banners.",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"duringYourEvent": {
"message": "During your event",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"rememberToDocument": {
"message": "Remember to document everything with photos, videos, quotes and whatever else might be helpful to sharing the event afterwards.",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"shareTheDetails": {
"message": "Share the details of your party on Twitter with the <a href=\"https://twitter.com/search?q=%23teachtheweb\">#teachtheweb</a> hashtag or the <a href=\"https://twitter.com/webmaker\">@webmaker</a> handle. We will be watching!",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"afterYourEvent": {
"message": "After your event",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"helpUsImprove": {
"message": "Help us improve events by sending us links to your pictures, blogs, makes, and most importantly; your feedback to <a href=\"mailto:makerparty@mozilla.org\">makerparty@mozilla.org</a>.",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"takeWhatYouHaveLearned": {
"message": "Take what you’ve learned and teach others by becoming a <a href=\"https://blog.webmaker.org/mentor\">mentor</a>.",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"hostAnotherEvent": {
"message": "<a href=\"https://webmaker.org/{{locale}}/events/\">Host another event</a>!",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"ifYouHaveQuestion": {
"message": "If you have questions, ideas for collaboration or information you'd like to share with us, don't hesitate to reach out. We also have this helpful <a href=\"https://wiki.mozilla.org/Maker_Party/FAQs\">FAQ</a> that might be a good place to start.",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"cheersAmiraEvent": {
"message": "Cheers!<br>Amira",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"unsubscribe": {
"message": "If you do not wish to receive any more emails from Mozilla Webmaker you can change your <a href=\"https://login.webmaker.org/{{locale}}/account\">email preferences</a>.",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
}
}
46 changes: 46 additions & 0 deletions locale/en_US/welcome.json
@@ -0,0 +1,46 @@
{
"WelcomeToWebMaker": {
"message": "Welcome to Webmaker!",
"description": "Please see this sample in Thimble page https://aali.makes.org/thimble/MTY3MzMzMDY4OA==/email-localization"
},
"emailTitle": {
"message": "Welcome to Webmaker. Let's get you started.",
"description": "Please see this sample in Thimble page https://aali.makes.org/thimble/MTY3MzMzMDY4OA==/email-localization"
},
"heyFullName": {
"message": "Hey {{ fullName }},",
"description": "Please see this sample in Thimble page https://aali.makes.org/thimble/MTY3MzMzMDY4OA==/email-localization"
},
"p1WelcomeToMozillaWebmaker": {
"message": "Welcome to Mozilla Webmaker! Thank you for joining us to explore, play and create together to build a web that's open and made by everyone.",
"description": "Please see this sample in Thimble page https://aali.makes.org/thimble/MTY3MzMzMDY4OA==/email-localization"
},
"p2YouCanGetStartedRightNow": {
"message": "You can get started right now with these free tools:",
"description": "Please see this sample in Thimble page https://aali.makes.org/thimble/MTY3MzMzMDY4OA==/email-localization"
},
"li1GogglesItem": {
"message": "<em><a href=\"https://goggles.webmaker.org/{{locale}}\" target=\"_blank\" title=\"X-Ray Goggles\">X-Ray Goggles</a></em> allow you to <strong>see the code behind any webpage</strong> and remix elements with a single click, swapping in your own text and images.",
"description": "Please see this sample in Thimble page https://aali.makes.org/thimble/MTY3MzMzMDY4OA==/email-localization"
},
"li2ThimbleItem": {
"message": "<em><a href=\"https://thimble.webmaker.org/{{locale}}\" target=\"_blank\" title=\"Thimble\">Thimble</a></em>, an easy-to-use HTML and CSS editor, lets you <strong>learn code by writing it directly in your browser</strong> to create your own webpage.",
"description": "Please see this sample in Thimble page https://aali.makes.org/thimble/MTY3MzMzMDY4OA==/email-localization"
},
"li3PopcornItem": {
"message": "<em><a href=\"https://popcorn.webmaker.org/{{locale}}\" target=\"_blank\" title=\"Popcorn Maker\">Popcorn Maker</a></em> helps you <strong>combine content from across the web</strong> like GIFs, music, photos and videos into cool mashups that you can annotate and share.",
"description": "Please see this sample in Thimble page https://aali.makes.org/thimble/MTY3MzMzMDY4OA==/email-localization"
},
"lastParagraph": {
"message": "I'm so glad you've joined the Webmaker community. If you have questions, feel free to email me or tweet @webmaker. I'm looking forward to seeing what you make on the web!",
"description": "Please see this sample in Thimble page https://aali.makes.org/thimble/MTY3MzMzMDY4OA==/email-localization"
},
"cheersAmira": {
"message": "Cheers,<br>Amira<br>Webmaker Community Manager",
"description": "Please see this sample in Thimble page https://aali.makes.org/thimble/MTY3MzMzMDY4OA==/email-localization"
},
"unsubscribe": {
"message": "If you do not wish to receive any more emails from Mozilla Webmaker you can change your <a href=\"https://login.webmaker.org/{{locale}}/account\">email preferences</a>.",
"description": "Please see this sample in Thimble page https://aali.makes.org/thimble/MTY3MzMzMDY4OA==/email-localization"
}
}
70 changes: 70 additions & 0 deletions locale/th_TH/create_events.json
@@ -0,0 +1,70 @@
{
"Next steps for your event": {
"message": "ขั้นตอนต่อไปสำหรับกิจกรรมของคุณ",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"heyFullName": {
"message": "สวัสดี {{ fullName }},",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"p1ThanksForRegistering": {
"message": "ขอบคุณที่ลงทะเบียนของคุณกับแผนที่กิจกรรมทั่วโลกและเข้าร่วมชุมชนทั่วโลกของเราที่มีการจัดตั้งปาร์ตี้การสร้าง เราตื่นเต้นที่จะสอนและเรียนรู้เกี่ยวกับเว็บพร้อมไปกับคุณ! ปัจจัยสำคัญในการสร้างกิจกรรมที่ประสบความสำเร็จคือการวางแผน ดังนั้นเราได้สร้างข้อมูลในการเตรียมพร้อมให้กับคุณ:",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"beforeYourEvent": {
"message": "ก่อนกิจกรรมของคุณ",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"visitOurGetInvolved": {
"message": "เข้าไปเยี่ยม<a href=\"https://wiki.mozilla.org/Maker_Party/Get_involved\">เพจของการเข้าร่วม</a>สำหรับสิ่งที่คุณควรที่จะรู้สำหรับการจัดตั้งปาร์ตี้",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"startPlanningUsingThese": {
"message": "เริ่มการวางแผนโดยใช้ข้อมูลที่มีประโยชน์เหล่านี้จาก<a href=\"https://webmaker.org/{{locale}}/event-guides\">แผนการสร้างกิจกรรม</a>",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"requestGear": {
"message": "ขอ<a href=\"https://intlstore.mozilla.org/makerparty/\">เครื่องมือปาร์ตี้การสร้าง</a>ฟรีที่มีสติกเกอร์ เสื้อ และแบนเนอร์ให้",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"duringYourEvent": {
"message": "ระหว่างกิจกรรมของคุณ",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"rememberToDocument": {
"message": "อย่าลืมจดข้อมูลทุกอย่างด้วยรูป วีดีโอ และคำพูดต่างๆที่ช่วยในการกิจกรรมเพื่อแบ่งปันหลังจากกิจกรรม",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"shareTheDetails": {
"message": "แบ่งปันข้อมูลของปาร์ตี้คุณผ่าน Twitter โดยใช้ <a href=\"https://twitter.com/search?q=%23teachtheweb\">#teachtheweb</a> hashtag หรือ <a href=\"https://twitter.com/webmaker\">@webmaker</a> เราจะคอยติดตาม!",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"afterYourEvent": {
"message": "หลังจากกิจกรรมของคุณ",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"helpUsImprove": {
"message": "ช่วยเราพัฒนากิจกรรมโดยส่งลิ้งค์ไปยังรูป บล็อค หรือสิ่งที่สร้างของคุณ และที่สำคัญที่สุดคำแนะนำของคุณมาที่ <a href=\"mailto:makerparty@mozilla.org\">makerparty@mozilla.org</a>",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"takeWhatYouHaveLearned": {
"message": "นำสิ่งที่คุณเรียนรู้และนำมาสอนคนอื่นโดยเป็น<a href=\"https://blog.webmaker.org/mentor\">ที่ปรึกษา</a>.",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"hostAnotherEvent": {
"message": "<a href=\"https://webmaker.org/{{locale}}/events/\">จัดอีกกิจกรรม</a>!",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"ifYouHaveQuestion": {
"message": "ถ้าหากคุณมีคำถาม หรือไอเดียสำหรับการทำงานร่วมกัน หรือข้อมูลที่คุณอยากแบ่งปันกับเรา อย่าลืมติดต่อเรา เรามี <a href=\"https://wiki.mozilla.org/Maker_Party/FAQs\">FAQ</a> ที่มีประโยชน์และอาจจะเป็นจุดเริ่มต้นที่ดี",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"cheersAmiraEvent": {
"message": "ด้วยความยินดี!<br>Amira",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
},
"unsubscribe": {
"message": "ถ้าหากคุณไม่ต้องการที่จะรับอีเมล์ข่าวสารจาก Mozilla Webmaker อีก คุณสามารถเข้าไปเปลี่ยน<a href=\"https://login.webmaker.org/{{locale}}/account\">การรับอีเมลข่าวสารในการตั้งค่า</a>.",
"description": "https://aali.makes.org/thimble/MTc0MDQzOTU1Mg==/webmaker-events-email-localization"
}
}

0 comments on commit c7a94f5

Please sign in to comment.