diff --git a/docs/I18N.md b/docs/I18N.md index fb3fd88a96dc46157c1468f26d10038675a87252..9ce0037acb746a5c90b2cdc3c05462d21185c657 100644 --- a/docs/I18N.md +++ b/docs/I18N.md @@ -11,13 +11,12 @@ Any copy, label, or error message that will be shown to users **should** be wrap These strings must be evaluated in the scope of a request, so we know which locale the user has. -In JavaScript or EJS templates use `gettext` or `ngettext`. If you need to do string interpolation, use the -[strargs](http://jsgettext.berlios.de/doc/html/Gettext.html#strargs__string__argument_array_) -function, which is kind of like node.js' util.format, except crappier. +In JavaScript or EJS templates use `gettext` or `ngettext`. If you need to do string interpolation, use the +[format](../lib/i18n.js) function, which is kind of like node.js' util.format, except crappier. Using `_` is more idiomatic, but conflicts with `underscore.js` on the client side JS and EJS files. -Technically, you can alias gettext to _ and use util.format, etc in node.js code... but for development consistency, +Technically, you can alias gettext to _ and use util.format, etc in node.js code... but for development consistency, we should keep EJS templates looking similar, regardless of if they are evaluated client or server-side. ## Variables @@ -28,6 +27,7 @@ The request object and the response's template context have the following variab * lang_dir - rtl or ltr (BIDI language support) * locale - OS level locale code * gettext, ngettext - Gettext functions + * format - for string interpolation ## Debugging diff --git a/lib/browserid/prove_template.ejs b/lib/browserid/prove_template.ejs index 489e30fc5916a98370f63c5467a1672b16181176..5cba2343a75abbed57c5aacceaa9c787dfde7465 100644 --- a/lib/browserid/prove_template.ejs +++ b/lib/browserid/prove_template.ejs @@ -1,10 +1,10 @@ <%= gettext( - strargs('Thanks for verifying your email address. This message is being sent to you to complete your sign-in to %1.', site)) %> - + format('Thanks for verifying your email address. This message is being sent to you to complete your sign-in to %s.', [site])) %> + <%= gettext('Finish registration by clicking this link:') %> <%= link %> - + <%= gettext('If you are NOT trying to sign into this site, just ignore this email.') %> - + <%= gettext('Thanks,') %> <%= gettext('BrowserID') %> <%= gettext('(A better way to sign in)') %> diff --git a/lib/email.js b/lib/email.js index 277db8a11770017e02beb7ba8d21decb82393899..541f1315647a2d20ed26c62c51ef3ee9cce54e43 100644 --- a/lib/email.js +++ b/lib/email.js @@ -48,7 +48,7 @@ exports.setInterceptor = function(callback) { function doSend(landing_page, email, site, secret, langContext) { var url = config.get('URL') + "/" + landing_page + "?token=" + encodeURIComponent(secret), _ = langContext.gettext, - strargs = langContext.strargs; + format = langContext.format; if (interceptor) { interceptor(email, site, secret); @@ -57,12 +57,12 @@ function doSend(landing_page, email, site, secret, langContext) { console.log("\nVERIFICATION URL:\n" + url + "\n"); } else { // TODO(aok) extract_po.sh isn't seeing this string if it's below in object literal - var subject = strargs(_("Complete Login to %1 using BrowserID"), site); + var subject = format(_("Complete Login to %s using BrowserID"), [site]); emailer.send_mail({ sender: "BrowserID@browserid.org", to: email, subject: subject, - body: template({ link: url, site: site, gettext: _, strargs: strargs }) + body: template({ link: url, site: site, gettext: _, format: format }) }, function(err, success){ if(!success) { logger.error("error sending email: " + err); diff --git a/lib/i18n.js b/lib/i18n.js index 32daab9f5cbcdba38e838d13751fcad2b82f4292..cfe804c6b894cc1407a84a6e66d48f3c4154728d 100644 --- a/lib/i18n.js +++ b/lib/i18n.js @@ -75,15 +75,14 @@ exports.abide = function (options) { mo_path = path.join(__dirname, '..', options.locale_directory, locale, 'LC_MESSAGES', 'messages.mo'); - resp.local('strargs', strargs); - req.strargs = strargs; + resp.local('format', format); + req.format = format; if (path.existsSync(mo_path)) { gt.addTextdomain(locale, fs.readFileSync(mo_path)); // Per request ??? gt.textdomain(locale); - console.info("Putting " + options.gettext_alias); resp.local(options.gettext_alias, gt.gettext.bind(gt)); req.gettext = gt.gettext.bind(gt); resp.local(options.ngettext_alias, gt.ngettext.bind(gt)); @@ -180,8 +179,19 @@ exports.localeFrom = localeFrom = function (language) { }; /** - * TODO: replace with util.format like function + * format provides string interpolation on the client and server side. + * It can be used with either an object for named variables, or an array + * of values for positional replacement. + * + * Named Example: + * format("%(salutation)s %(place)s", {salutation: "Hello", place: "World"}, true); + * Positional Example: + * format("%s %s", ["Hello", "World"]); */ -exports.strargs = strargs = function (str, args) { - return str; -}; \ No newline at end of file +exports.format = format = function (fmt, obj, named) { + if (named) { + return fmt.replace(/%\(\w+\)s/g, function(match){return String(obj[match.slice(2,-2)])}); + } else { + return fmt.replace(/%s/g, function(match){return String(obj.shift())}); + } +}; diff --git a/lib/wsapi/stage_user.js b/lib/wsapi/stage_user.js index d6a22119b046f34ba4ebe543e65510c9720c7406..3c7785da13ac586732419c6de508d67f4e4243f7 100644 --- a/lib/wsapi/stage_user.js +++ b/lib/wsapi/stage_user.js @@ -27,7 +27,7 @@ exports.process = function(req, resp) { lang: req.lang, locale: req.locale, ngettext: req.ngettext, - strargs: req.strargs + format: req.format }; // staging a user logs you out. wsapi.clearAuthenticatedUser(req.session); @@ -42,7 +42,7 @@ exports.process = function(req, resp) { try { // upon success, stage_user returns a secret (that'll get baked into a url // and given to the user), on failure it throws - db.stageUser(req.body.email, function(secret) { + db.stageUser(req.body.email, function(secret) { // store the email being registered in the session data if (!req.session) req.session = {}; @@ -53,7 +53,7 @@ exports.process = function(req, resp) { resp.json({ success: true }); - // let's now kick out a verification email! + // let's now kick out a verification email! email.sendNewUserEmail(req.body.email, req.body.site, secret, langContext); }); } catch(e) { diff --git a/resources/static/dialog/views/authenticate.ejs b/resources/static/dialog/views/authenticate.ejs index c81ebd344e2b166f57b2536c8465fb1fe34a8421..819dba72bf66acf38a8ff48103b8d4fcbb4ffe08 100644 --- a/resources/static/dialog/views/authenticate.ejs +++ b/resources/static/dialog/views/authenticate.ejs @@ -27,8 +27,7 @@ </li> <li id="hint_section" class="start"> - <p><%= strargs(gettext('Enter your email address to sign in to <strong>%1</strong>'), - [sitename]) %></p> + <p><%= format(gettext('Enter your email address to sign in to <strong>%s</strong>'), [sitename]) %></p> </li> <li id="create_text_section" class="newuser"> diff --git a/resources/static/dialog/views/confirm_email.ejs b/resources/static/dialog/views/confirm_email.ejs index 16b7934ea4b2ffba886db12e3374e1fb35530c69..09be4ae836a547c4fbc4c729f0b1f70e11f820b8 100644 --- a/resources/static/dialog/views/confirm_email.ejs +++ b/resources/static/dialog/views/confirm_email.ejs @@ -3,7 +3,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. */ %> <h2><%= gettext('Check your email!') %></h2> - <p><%= strargs(gettext('We sent a confirmation email to <strong>%1</strong>'), email) %></p> + <p><%= format(gettext('We sent a confirmation email to <strong>%s</strong>'), [email]) %></p> <p><% gettext('To finish signing in just click the verify link we sent to your email address.') %></p><br /> <p><% gettext('If this is a mistake, just ignore the sent email and <a href="#" class="cancelVerify" id="back">use another email address</a>.') %></p> - diff --git a/resources/static/i18n/db_LB/client.json b/resources/static/i18n/db_LB/client.json index 7e05ff2231e32ccc7836b9415f1df35bc0b29135..e218693a87fdae08d93c6aacdc213b95da9abc26 100644 --- a/resources/static/i18n/db_LB/client.json +++ b/resources/static/i18n/db_LB/client.json @@ -2,7 +2,7 @@ var json_locale_data = { "client" : { "" : { "MIME-Version" : " 1.0", - "POT-Creation-Date" : " 2012-01-11 16:41-0800", + "POT-Creation-Date" : " 2012-01-18 16:46-0800", "Last-Translator" : " FULL NAME <EMAIL@ADDRESS>", "Content-Type" : " text/plain; charset=UTF-8", "PO-Revision-Date" : " YEAR-MO-DA HO:MI+ZONE", @@ -19,9 +19,9 @@ var json_locale_data = { null, "‮uÇxʇ" ], - "add" : [ + "Enter your email address to sign in to <strong>%s</strong>" : [ null, - "" + "‮ƎuʇÇɹ ÊŽonɹ ÇɯÉıʅ ÉppɹÇss ʇo sıƃu ıu ʇo <strong>%s</strong>" ], "This email looks new, so let's get you set up." : [ null, @@ -31,10 +31,6 @@ var json_locale_data = { null, "â€®âŠ¥É¥Ç ÇɯÉıʅ ɟıÇÊ…p ıs ɹÇbnıɹÇp·" ], - "New email address" : [ - null, - "" - ], "verify email" : [ null, "‮ʌÇɹıɟʎ ÇɯÉıʅ" @@ -47,9 +43,9 @@ var json_locale_data = { null, "‮ԀÉssÊoɹp" ], - "You already own that address!" : [ + "We sent a confirmation email to <strong>%s</strong>" : [ null, - "" + "‮ï¼Ç sÇuʇ É É”ouɟıɹɯÉʇıou ÇɯÉıʅ ʇo <strong>%s</strong>" ], "To finish signing in just click the verify link we sent to your email address." : [ null, @@ -67,13 +63,9 @@ var json_locale_data = { null, "‮ƎɯÉıʅ" ], - "We sent a confirmation email to <strong>%1</strong>" : [ - null, - "‮ï¼Ç sÇuʇ É É”ouɟıɹɯÉʇıou ÇɯÉıʅ ʇo <strong>%1</strong>" - ], "sign in" : [ null, - "‮sıƃu ıu" + "\"‮sıƃu ıu" ], "The account cannot be logged in with this username and password." : [ null, @@ -91,25 +83,17 @@ var json_locale_data = { null, "‮ï¼ÇÊ…É”oÉ¯Ç Ê‡o ÔɹoÊsÇɹIᗡ¡" ], - "If this is a mistake, just ignore the sent email and <a href=\"#\" class=\"cancelVerify\" id=\"back\">use another email address</a>." : [ - null, - "‮IÉŸ ʇɥıs ıs É É¯Ä±sʇÉʞǴ ɾnsʇ ıƃuoÉ¹Ç Ê‡É¥Ç sÇuʇ ÇɯÉıʅ Éup <a href=\"#\" class=\"cancelVerify\" id=\"back\">‮nsÇ ÉuoʇɥÇɹ ÇɯÉıʅ ÉppɹÇss</a>‮·" - ], "We just sent an email to that address! If you really want to send another, wait a minute or two and try again." : [ null, "‮ï¼Ç ɾnsʇ sÇuʇ Éu ÇɯÉıʅ ʇo ʇɥÉʇ ÉppɹÇss¡ IÉŸ ÊŽon ɹÇÉÊ…Ê…ÊŽ ÊÉuʇ ʇo sÇup ÉuoʇɥÇɹ´ ÊÉıʇ É É¯Ä±unÊ‡Ç oɹ ʇÊo Éup ʇɹʎ ÉƃÉıu·" ], - "Check your email!" : [ - null, - "‮ↃɥÇɔʞ ÊŽonɹ ÇɯÉıʅ¡" - ], - "Enter your email address to sign in to <strong>%1</strong>" : [ + "If this is a mistake, just ignore the sent email and <a href=\"#\" class=\"cancelVerify\" id=\"back\">use another email address</a>." : [ null, - "‮ƎuʇÇɹ ÊŽonɹ ÇɯÉıʅ ÉppɹÇss ʇo sıƃu ıu ʇo <strong>%1</strong>" + "‮IÉŸ ʇɥıs ıs É É¯Ä±sʇÉʞǴ ɾnsʇ ıƃuoÉ¹Ç Ê‡É¥Ç sÇuʇ ÇɯÉıʅ Éup <a href=\"#\" class=\"cancelVerify\" id=\"back\">‮nsÇ ÉuoʇɥÇɹ ÇɯÉıʅ ÉppɹÇss</a>‮·" ], - "cancel" : [ + "Check your email!" : [ null, - "" + "‮ↃɥÇɔʞ ÊŽonɹ ÇɯÉıʅ¡" ], "The password field is required." : [ null, diff --git a/resources/static/i18n/db_LB/messages.json b/resources/static/i18n/db_LB/messages.json index ab47005a8e8fdef9d1ffd5c6af82eafffc8a16fe..bbeff06c16dd896bb3cf022d49ee6acefb2ade19 100644 --- a/resources/static/i18n/db_LB/messages.json +++ b/resources/static/i18n/db_LB/messages.json @@ -6,7 +6,7 @@ var json_locale_data = { ], "" : { "MIME-Version" : " 1.0", - "POT-Creation-Date" : " 2012-01-11 16:41-0800", + "POT-Creation-Date" : " 2012-01-18 16:46-0800", "Last-Translator" : " FULL NAME <EMAIL@ADDRESS>", "Content-Type" : " text/plain; charset=UTF-8", "PO-Revision-Date" : " YEAR-MO-DA HO:MI+ZONE", @@ -15,14 +15,14 @@ var json_locale_data = { "Project-Id-Version" : " PACKAGE VERSION", "Report-Msgid-Bugs-To" : " " }, - "Verification password is required." : [ - null, - "‮ɅÇɹıɟıɔÉʇıou dÉssÊoɹp ıs ɹÇbnıɹÇp·" - ], "BrowserID" : [ null, "‮ÔɹoÊsÇɹIá—¡" ], + "Verification password is required." : [ + null, + "‮ɅÇɹıɟıɔÉʇıou dÉssÊoɹp ıs ɹÇbnıɹÇp·" + ], "Finish signing into: " : [ null, "‮ℲıuısÉ¥ sıƃuıuƃ ıuʇo: " @@ -55,13 +55,9 @@ var json_locale_data = { null, "‮ԀÉssÊoɹp ɯnsʇ qÇ qÇʇÊÇÇu 8‮ Éup 80‮ ɔɥÉɹÉɔʇÇɹs Ê…ouƃ·" ], - "Complete Login to %1 using BrowserID" : [ - null, - "‮ↃoɯdÊ…ÇÊ‡Ç â…‚oƃıu ʇo %1‮ nsıuƃ ÔɹoÊsÇɹIá—¡" - ], "(A better way to sign in)" : [ null, - "‮(∀ qÇʇʇÇɹ ÊÉÊŽ ʇo sıƃu ıu)" + "\"‮(∀ qÇʇʇÇɹ ÊÉÊŽ ʇo sıƃu ıu)" ], "Finish registration by clicking this link:" : [ null, @@ -95,30 +91,34 @@ var json_locale_data = { null, "<strong class=\"email\">‮⅄onɹ ÉppɹÇss</strong>‮ É¥És qÇÇu ÊŒÇɹıɟıÇp¡" ], - "Browser ID" : [ - null, - "‮ÔɹoÊsÇɹ Iá—¡" - ], "Finish" : [ null, "‮ℲıuısÉ¥" ], - "There was a problem with your signup link. Has this address already been registered?" : [ + "Browser ID" : [ null, - "‮⊥ɥÇÉ¹Ç ÊÉs É dɹoqÊ…Çɯ Êıʇɥ ÊŽonɹ sıƃund ʅıuʞ· HÉs ʇɥıs ÉppɹÇss ÉʅɹÇÉpÊŽ qÇÇu ɹÇƃısʇÇɹÇp?" + "‮ÔɹoÊsÇɹ Iá—¡" ], - "Password is required." : [ + "There was a problem with your signup link. Has this address already been registered?" : [ null, - "‮ԀÉssÊoɹp ıs ɹÇbnıɹÇp·" + "‮⊥ɥÇÉ¹Ç ÊÉs É dɹoqÊ…Çɯ Êıʇɥ ÊŽonɹ sıƃund ʅıuʞ· HÉs ʇɥıs ÉppɹÇss ÉʅɹÇÉpÊŽ qÇÇu ɹÇƃısʇÇɹÇp?" ], "Passwords do not match." : [ null, "‮ԀÉssÊoɹps po uoʇ ɯÉʇɔɥ·" ], + "Password is required." : [ + null, + "‮ԀÉssÊoɹp ıs ɹÇbnıɹÇp·" + ], "New Password" : [ null, "‮NÇÊ Ô€ÉssÊoɹp" ], + "Complete Login to %s using BrowserID" : [ + null, + "‮ↃoɯdÊ…ÇÊ‡Ç â…‚oƃıu ʇo %s‮ nsıuƃ ÔɹoÊsÇɹIá—¡" + ], "Repeat Password" : [ null, "‮ᴚÇdÇÉʇ Ô€ÉssÊoɹp" diff --git a/resources/static/i18n/en_US/client.json b/resources/static/i18n/en_US/client.json index d6d05dd3a3fd4b3b4fcc74e574bf8e056a356d27..59cbb44687cec93e31aca0c3811121f86f3e0c7c 100644 --- a/resources/static/i18n/en_US/client.json +++ b/resources/static/i18n/en_US/client.json @@ -3,7 +3,7 @@ var json_locale_data = { "" : { "Plural-Forms" : " nplurals=2; plural=(n != 1);", "MIME-Version" : " 1.0", - "POT-Creation-Date" : " 2012-01-11 16:41-0800", + "POT-Creation-Date" : " 2012-01-18 16:46-0800", "Last-Translator" : " Austin King <ozten@mozilla.com>", "Content-Type" : " text/plain; charset=UTF-8", "PO-Revision-Date" : " 2012-01-10 17:32-0800", @@ -20,9 +20,9 @@ var json_locale_data = { null, "next" ], - "add" : [ + "Enter your email address to sign in to <strong>%s</strong>" : [ null, - "" + "Enter your email address to sign in to <strong>%s</strong>" ], "This email looks new, so let's get you set up." : [ null, @@ -32,10 +32,6 @@ var json_locale_data = { null, "The email field is required." ], - "New email address" : [ - null, - "" - ], "verify email" : [ null, "verify email" @@ -48,9 +44,9 @@ var json_locale_data = { null, "Password" ], - "You already own that address!" : [ + "We sent a confirmation email to <strong>%s</strong>" : [ null, - "" + "Enter your email address to sign in to <strong>%s</strong>" ], "To finish signing in just click the verify link we sent to your email address." : [ null, @@ -68,10 +64,6 @@ var json_locale_data = { null, "Email" ], - "We sent a confirmation email to <strong>%1</strong>" : [ - null, - "Enter your email address to sign in to <strong>%1</strong>" - ], "sign in" : [ null, "Sign in using" @@ -92,23 +84,15 @@ var json_locale_data = { null, "Welcome to BrowserID!" ], - "If this is a mistake, just ignore the sent email and <a href=\"#\" class=\"cancelVerify\" id=\"back\">use another email address</a>." : [ - null, - "" - ], "We just sent an email to that address! If you really want to send another, wait a minute or two and try again." : [ null, "We just sent an email to that address! If you really want to send another, wait a minute or two and try again." ], - "Check your email!" : [ + "If this is a mistake, just ignore the sent email and <a href=\"#\" class=\"cancelVerify\" id=\"back\">use another email address</a>." : [ null, "" ], - "Enter your email address to sign in to <strong>%1</strong>" : [ - null, - "Enter your email address to sign in to <strong>%1</strong>" - ], - "cancel" : [ + "Check your email!" : [ null, "" ], diff --git a/resources/static/i18n/en_US/messages.json b/resources/static/i18n/en_US/messages.json index 68d69585ca090475e62344c57aed39699da71df1..2a1e0a76a2c1abba73922edd79e093defb630c3f 100644 --- a/resources/static/i18n/en_US/messages.json +++ b/resources/static/i18n/en_US/messages.json @@ -6,7 +6,7 @@ var json_locale_data = { ], "" : { "MIME-Version" : " 1.0", - "POT-Creation-Date" : " 2012-01-11 16:41-0800", + "POT-Creation-Date" : " 2012-01-18 16:46-0800", "Last-Translator" : " FULL NAME <EMAIL@ADDRESS>", "Content-Type" : " text/plain; charset=UTF-8", "PO-Revision-Date" : " YEAR-MO-DA HO:MI+ZONE", @@ -15,11 +15,11 @@ var json_locale_data = { "Project-Id-Version" : " PACKAGE VERSION", "Report-Msgid-Bugs-To" : " " }, - "Verification password is required." : [ + "BrowserID" : [ null, "" ], - "BrowserID" : [ + "Verification password is required." : [ null, "" ], @@ -55,10 +55,6 @@ var json_locale_data = { null, "" ], - "Complete Login to %1 using BrowserID" : [ - null, - "" - ], "(A better way to sign in)" : [ null, "" @@ -95,11 +91,11 @@ var json_locale_data = { null, "" ], - "Browser ID" : [ + "Finish" : [ null, "" ], - "Finish" : [ + "Browser ID" : [ null, "" ], @@ -107,11 +103,11 @@ var json_locale_data = { null, "" ], - "Password is required." : [ + "Passwords do not match." : [ null, "" ], - "Passwords do not match." : [ + "Password is required." : [ null, "" ], @@ -119,6 +115,10 @@ var json_locale_data = { null, "" ], + "Complete Login to %s using BrowserID" : [ + null, + "" + ], "Repeat Password" : [ null, "" diff --git a/resources/static/i18n/pl/messages.json b/resources/static/i18n/pl/messages.json deleted file mode 100644 index abe4b65eb15125456c405265b88ec3ea320a5067..0000000000000000000000000000000000000000 --- a/resources/static/i18n/pl/messages.json +++ /dev/null @@ -1,188 +0,0 @@ -var json_locale_data = { - "messages" : { - "Error encountered trying to complete registration." : [ - null, - "" - ], - "" : { - "MIME-Version" : " 1.0", - "POT-Creation-Date" : " 2012-01-11 15:36-0800", - "Last-Translator" : " FULL NAME <EMAIL@ADDRESS>", - "Content-Type" : " text/plain; charset=UTF-8", - "PO-Revision-Date" : " YEAR-MO-DA HO:MI+ZONE", - "Language-Team" : " LANGUAGE <LL@li.org>", - "Content-Transfer-Encoding" : " 8bit", - "Project-Id-Version" : " PACKAGE VERSION", - "Report-Msgid-Bugs-To" : " " - }, - "next" : [ - null, - "nastÄ™pny" - ], - "Verification password is required." : [ - null, - "Pole jest wymagane hasÅ‚o." - ], - "BrowserID" : [ - null, - "ID PrzeglÄ…darka" - ], - "Finish signing into: " : [ - null, - "" - ], - "Your Email" : [ - null, - "E-mail" - ], - "Sign in using" : [ - null, - "Zaloguj siÄ™ za pomocÄ…" - ], - "forgot your password?" : [ - null, - "zapomniaÅ‚eÅ› hasÅ‚a?" - ], - "Error comunicating with server." : [ - null, - "" - ], - "This field must be an email address." : [ - null, - "To pole musi być adres e-mail." - ], - "Last step!" : [ - null, - "" - ], - "BrowserID is the fast and secure way to sign in — <a target=\"_blank\" href=\"/about\">learn more</a>" : [ - null, - "ID PrzeglÄ…darka jest szybki i bezpieczny sposób, aby siÄ™ zalogować &mdash <a target=\"_blank\" href=\"/about\">Dowiedz siÄ™ wiÄ™cej</a>" - ], - "select email" : [ - null, - "wybierz e-mail" - ], - "Your new address is set up and you should now be signed in. You may now close this window and go back to" : [ - null, - "" - ], - "Verify Password" : [ - null, - "hasÅ‚o" - ], - "Password must be between 8 and 80 characters long." : [ - null, - "" - ], - "Enter your email address to sign in to <strong>%1</strong>" : [ - null, - "Wpisz swój adres e-mail, aby zalogować siÄ™ do <strong>%1</strong>" - ], - "Complete Login to %1 using BrowserID" : [ - null, - "" - ], - "(A better way to sign in)" : [ - null, - "" - ], - "Finish registration by clicking this link:" : [ - null, - "" - ], - "Thanks," : [ - null, - "" - ], - "Communicating with server" : [ - null, - "" - ], - "The email field is required." : [ - null, - "Pole e-mail jest wymagane." - ], - "verify email" : [ - null, - "sprawdzić e-mail" - ], - "Enter a Password" : [ - null, - "hasÅ‚o" - ], - "Error encountered while attempting to confirm your address. Have you previously verified this address?" : [ - null, - "" - ], - "Thank you for signing up with <strong>BrowserID</strong>. You can now use your <strong>BrowserID</strong> account to <em>Sign In</em> or <em>Sign Up</em> to websites all across the web!" : [ - null, - "" - ], - "Email Verification" : [ - null, - "" - ], - "<strong class=\"email\">Your address</strong> has been verified!" : [ - null, - "" - ], - "Browser ID" : [ - null, - "ID PrzeglÄ…darka" - ], - "Finish" : [ - null, - "" - ], - "This email looks new, so let's get you set up." : [ - null, - "Ten e-mail wyglÄ…da nowy, wiÄ™c przejdźmy skonfigurować." - ], - "There was a problem with your signup link. Has this address already been registered?" : [ - null, - "" - ], - "The account cannot be logged in with this username and password." : [ - null, - "Konto nie może siÄ™ zalogować w tym login i hasÅ‚o." - ], - "Password is required." : [ - null, - "Pole jest wymagane hasÅ‚o." - ], - "Passwords do not match." : [ - null, - "" - ], - "#~ \"We just sent an email to that address! If you really want to send \"#~ \"another, wait a minute or two and try again.\"" : [ - null, - "#~ \"Po prostu wysÅ‚aÅ‚ e-maila na ten adres! JeÅ›li naprawdÄ™ chcesz wysÅ‚ać \"#~ \"innym, poczekać minutÄ™ lub dwie i spróbuj ponownie\"" - ], - "New Password" : [ - null, - "hasÅ‚o" - ], - "Welcome to BrowserID!" : [ - null, - "Witamy BrowserID!" - ], - "Repeat Password" : [ - null, - "hasÅ‚o" - ], - "Just a moment while we talk with the server." : [ - null, - "" - ], - "Email Address" : [ - null, - "" - ], - "If you are NOT trying to sign into this site, just ignore this email." : [ - null, - "" - ] - } -} -; diff --git a/resources/static/shared/gettext.js b/resources/static/shared/gettext.js index eebbc703d4980b7933913cf459b9e685f865001b..d93f1d5b59e21ba44cbd6903b514e8e17a953cc5 100644 --- a/resources/static/shared/gettext.js +++ b/resources/static/shared/gettext.js @@ -7,14 +7,23 @@ function Gettext(params) { gettext: function (msgid) { if (json_locale_data && json_locale_data["client"]) { var dict = json_locale_data["client"]; - if (dict[msgid]) { - return dict[msgid]; + if (dict[msgid] && dict[msgid].length >= 2) { + return dict[msgid][1]; } } return msgid; }, - strargs: function (fmt, args) { - return fmt; + // See lib/i18n.js format docs + format: function (fmt, obj, named) { + if (! fmt.replace) { + console.log("format called with", fmt); + return fmt; + } + if (named) { + return fmt.replace(/%\(\w+\)s/g, function(match){return String(obj[match.slice(2,-2)])}); + } else { + return fmt.replace(/%s/g, function(match){return String(obj.shift())}); + } } }; }; \ No newline at end of file diff --git a/resources/static/shared/renderer.js b/resources/static/shared/renderer.js index deb32ebd1625ca6a59cad54f128590d4ecb48edf..1c6acdd6012d794dfb98dda8cf690a9e837c64c1 100644 --- a/resources/static/shared/renderer.js +++ b/resources/static/shared/renderer.js @@ -33,7 +33,7 @@ BrowserID.Renderer = (function() { }; var gt = new Gettext(params); vars['gettext'] = gt.gettext.bind(gt); - vars['strargs'] = gt.strargs.bind(gt); + vars['format'] = gt.format.bind(gt); } var template = templateCache[templateName]; diff --git a/resources/views/dialog.ejs b/resources/views/dialog.ejs index 9da4582cbc7e8927cb0e6655a62345e60108011a..4bf7faa1d6b8c67b3bc89eb3fb9cbecafc4705fa 100644 --- a/resources/views/dialog.ejs +++ b/resources/views/dialog.ejs @@ -1,7 +1,6 @@ <!-- 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/. --> - <section id="formWrap"> <form novalidate> <div id="favicon"> diff --git a/resources/views/dialog_layout.ejs b/resources/views/dialog_layout.ejs index 8ba81bfad6bce9802e1e2337216a7205adaca2e0..fb376bf3e5558ae34610ad61b288b04b6d64cce2 100644 --- a/resources/views/dialog_layout.ejs +++ b/resources/views/dialog_layout.ejs @@ -2,6 +2,7 @@ <!-- 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 LANG="<%= lang %>" dir="<%= lang_dir %>"> <head> <meta charset="utf-8">