From cb2a7a5b0450626303720c6bb9a4b4bfeed407d0 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 10 May 2018 10:48:59 +0200 Subject: [PATCH] Made translation of templates easier --- assets/js/common/page.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/assets/js/common/page.js b/assets/js/common/page.js index 868bbd07..d16f4d45 100644 --- a/assets/js/common/page.js +++ b/assets/js/common/page.js @@ -339,10 +339,25 @@ ComunicWeb.common.page = { } } + //Apply required translations + while(templateContent.includes("[[")){ + + //Get the full template inclusion + var source = templateContent.match(/\[\[.*\]\]/i)[0]; + + //Determine lang key + var key = source.replace("[[", "").replace("]]", ""); + var translation = lang(key); + + //Apply lang + while(templateContent.includes(source)) + templateContent = templateContent.replace(source, translation); + } + //Apply template source targetElem.innerHTML = templateContent; - //Make a link live + //Make links live var aElems = targetElem.getElementsByTagName("a"); for(num in aElems){