diff --git a/add-on/_locales/en/messages.json b/add-on/_locales/en/messages.json index ea937c2b9..e4312b611 100644 --- a/add-on/_locales/en/messages.json +++ b/add-on/_locales/en/messages.json @@ -470,7 +470,7 @@ } }, "page_landingWelcome_renderWelcome_copy_discover": { - "message": "Discover what you can do with Companion and dive into the distributed web with IPFS!", + "message": "Discover what you <0>can do with Companion and dive into the distributed web with IPFS!", "description": "Ready message copy (page_landingWelcome_renderWelcome_copy_discover)" }, "page_landingWelcome_installSteps_title": { @@ -478,7 +478,7 @@ "description": "Install steps title (page_landingWelcome_installSteps_title)" }, "page_landingWelcome_installSteps_copy_install": { - "message": "If you haven't installed IPFS please do so with these instructions.", + "message": "If you haven't installed IPFS please do so <0>with these instructions.", "description": "Install steps copy (page_landingWelcome_installSteps_copy_install)" }, "page_landingWelcome_installSteps_copy_run": { @@ -490,7 +490,7 @@ "description": "Resources title (page_landingWelcome_renderResources_title_new_ipfs)" }, "page_landingWelcome_renderResources_copy_new_ipfs": { - "message": "Read the documentation to learn about the basic concepts and working with IPFS.", + "message": "Read the <0>documentation to learn about the basic <1>concepts and working with IPFS.", "description": "Resources copy (page_landingWelcome_renderResources_copy_new_ipfs)" }, "page_landingWelcome_renderResources_title_discover": { @@ -498,7 +498,7 @@ "description": "Resources title (page_landingWelcome_renderResources_title_discover)" }, "page_landingWelcome_renderResources_copy_discover": { - "message": "Find useful resources for using IPFS and building things on top of it.", + "message": "Find <0>useful resources for using IPFS and <1>building things on top of it.", "description": "Resources copy (page_landingWelcome_renderResources_copy_discover)" }, "page_landingWelcome_renderResources_title_got_questions": { @@ -506,7 +506,7 @@ "description": "Resources title (page_landingWelcome_renderResources_title_got_questions)" }, "page_landingWelcome_renderResources_copy_got_questions": { - "message": "Visit the Discussion and Support Forum.", + "message": "Visit the <0>Discussion and Support Forum.", "description": "Resources copy (page_landingWelcome_renderResources_copy_got_questions)" }, "page_landingWelcome_renderResources_title_want_to_help": { @@ -514,7 +514,7 @@ "description": "Resources title (page_landingWelcome_renderResources_title_want_to_help)" }, "page_landingWelcome_renderResources_copy_want_to_help": { - "message": "Join the IPFS Community! Contribute with code, documentation, translations or help by supporting other users.", + "message": "Join the <0>IPFS Community! Contribute with <1>code, <2>documentation, <3>translations or help by <4>supporting other users.", "description": "Resources copy (page_landingWelcome_renderResources_copy_want_to_help)" }, "page_landingWelcome_renderVideos_alpha_demo": { diff --git a/add-on/src/utils/i18n.js b/add-on/src/utils/i18n.js index 6a3023c21..1a8b033bb 100644 --- a/add-on/src/utils/i18n.js +++ b/add-on/src/utils/i18n.js @@ -11,16 +11,19 @@ const browser = require('webextension-polyfill') * @return {html} An HTML node with the translated string with anchors. */ const renderTranslatedLink = (message, links, attributes) => { - const regex = /(.+?)<\/a>/mg + const regexLink = /<\d>(.+?)<\/\d>/mg + const regexIndex = /<(\d)>/mg const str = browser.i18n.getMessage(message) - let match = regex.exec(str) - let output = str - let i = 0 - while (match !== null) { - output = output.replace(match[0], `${match[1]}`) - match = regex.exec(str) - i++ + + let matchLink = regexLink.exec(str) + while (matchLink !== null) { + let matchIndex = regexIndex.exec(matchLink[0]) + while (matchIndex !== null) { + output = output.replace(matchLink[0], `${matchLink[1]}`) + matchIndex = regexIndex.exec(str) + } + matchLink = regexLink.exec(str) } const template = document.createElement('template')