From 5b5a430114e490928cb7795e0c58be2f43b592ae Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 27 Sep 2016 13:33:03 -0700 Subject: [PATCH] Support i18n with multiple links We can now pass a variable number of hrefs into i18n_with_links rather than just one. --- js/views/install_view.js | 4 ++-- js/views/whisper_view.js | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/js/views/install_view.js b/js/views/install_view.js index 3cfdfd96..7816f4fc 100644 --- a/js/views/install_view.js +++ b/js/views/install_view.js @@ -15,9 +15,9 @@ installWelcome: i18n('installWelcome'), installTagline: i18n('installTagline'), installGetStartedButton: i18n('installGetStartedButton'), - installSignalLink: this.i18n_with_link('installSignalLinks', playStoreHref, appStoreHref), + installSignalLink: this.i18n_with_links('installSignalLinks', playStoreHref, appStoreHref), installIHaveSignalButton: i18n('installGotIt'), - installFollowUs: this.i18n_with_link('installFollowUs', twitterHref), + installFollowUs: this.i18n_with_links('installFollowUs', twitterHref), installAndroidInstructions: i18n('installAndroidInstructions'), installLinkingWithNumber: i18n('installLinkingWithNumber'), installComputerName: i18n('installComputerName'), diff --git a/js/views/whisper_view.js b/js/views/whisper_view.js index f9b3767e..bc03f73f 100644 --- a/js/views/whisper_view.js +++ b/js/views/whisper_view.js @@ -57,9 +57,12 @@ this.$el.closest('body').append(dialog.el); }.bind(this)); }, - i18n_with_link: function(message, href) { - var attrs = 'class="link" href="' + encodeURI(href) + '" target="_blank"'; - return i18n(message, attrs); + i18n_with_links: function() { + var args = Array.prototype.slice.call(arguments); + for (var i=1; i < args.length; ++i) { + args[i] = 'class="link" href="' + encodeURI(args[i]) + '" target="_blank"'; + } + return i18n(args[0], args.slice(1)); } },{ // Class attributes