<commit_before>module("Internationalisation");

(function(){

var checkChildElements = function(element, page, template){
    if (element.firstChild) { // check for children elements
        var child = element.firstChild;
        while (child) { // check child elements
            if (child.nodeType === 8 && child.parentNode.nodeName.toLowerCase() === "div") { // if comment node is in a div its probably a javascript template
                var trimPathTemplate = document.createElement('div');
                trimPathTemplate.innerHTML = child.data.replace('\[\"','').replace('\[\"','');
                checkChildElements(trimPathTemplate, page, true);
            }
            if (child.nodeType === 1) { // if html element
                var tagText = $(child).clone().find("*").remove().end().text();

                // check title and alt attributes, and text within the tag
                // there is an issue getting tag attributes from javascript templates if it contains double quotes within template brackets, these will fail the unit test
                var titleText = $(child).attr("title");
                var valueText = $(child).attr("value");
                var altText = $(child).attr("alt");
                var alpha = new RegExp("^(.*)[a-zA-z](.*)+$");
                var regex = new RegExp("__MSG__(.*?)__");
                var templateRegex = new RegExp("^(.*?)(\\$*){(.*?)}(.*?)+$");
                var templateStartAlphaRegex = new RegExp("^([a-zA-z]+)(\\$*){(.*?)}+$");
                var templateMiddleAlphaRegex = new RegExp("^(\\$*){(.*?)}([a-zA-z]+)(\\$*){(.*?)}+$");
                var templateEndAlphaRegex = new RegExp("^(\\$*){(.*?)}([a-zA-z])+$");

                if (tagText) {
                    tagTextTest = tagText.replace(/\s+/g,'');
                    if (regex.test(tagTextTest) && tagTextTest.length > 0) {
                        //ok(true, "Page: " + page + ", String: " + tagText);
                    } else if (templateRegex.test(tagTextTest) && !(regex.test(tagTextTest) || templateStartAlphaRegex.test(tagTextTest) || templateEndAlphaRegex.test(tagTextTest) || templateMiddleAlphaRegex.test(tagTextTest)) && tagTextTest.length > 0 && template){
                        //ok(true, "Page: " + page + ", String: " + tagText);<commit_msg>SAKIII-1551 added ability for internationalisation unit test to check javascript templates in the html files<commit_after>module("Internationalisation");

(function(){

var checkChildElements = function(element, page, template){
    if (element.firstChild) { // check for children elements
        var child = element.firstChild;
        while (child) { // check child elements
            if (child.nodeType === 8 && child.parentNode.nodeName.toLowerCase() === "div") { // if comment node is in a div its probably a javascript template
                var trimPathTemplate = document.createElement('div');
                trimPathTemplate.innerHTML = child.data;
                checkChildElements(trimPathTemplate, page, true);
            }
            if (child.nodeType === 1) { // if html element
                var tagText = $(child).clone().find("*").remove().end().text();

                // check title and alt attributes, and text within the tag
                // there is an issue getting tag attributes from javascript templates if it contains double quotes within template brackets, these will fail the unit test
                var titleText = $(child).attr("title");
                var valueText = $(child).attr("value");
                var altText = $(child).attr("alt");
                var alpha = new RegExp("^(.*)[a-zA-z](.*)+$");
                var regex = new RegExp("__MSG__(.*?)__");
                var templateRegex = new RegExp("^(.*?)(\\$*){(.*?)}(.*?)+$");
                var templateStartAlphaRegex = new RegExp("^([a-zA-z]+)(\\$*){(.*?)}+$");
                var templateMiddleAlphaRegex = new RegExp("^(\\$*){(.*?)}([a-zA-z]+)(\\$*){(.*?)}+$");
                var templateEndAlphaRegex = new RegExp("^(\\$*){(.*?)}([a-zA-z])+$");

                if (tagText) {
                    tagTextTest = tagText.replace(/\s+/g,'');
                    if (regex.test(tagTextTest) && tagTextTest.length > 0) {
                        //ok(true, "Page: " + page + ", String: " + tagText);
                    } else if (templateRegex.test(tagTextTest) && !(regex.test(tagTextTest) || templateStartAlphaRegex.test(tagTextTest) || templateEndAlphaRegex.test(tagTextTest) || templateMiddleAlphaRegex.test(tagTextTest)) && tagTextTest.length > 0 && template){
                        //ok(true, "Page: " + page + ", String: " + tagText);
{'fraction_non_alphanumeric': 0.17405266538214514, 'fraction_numerical': 0.002569043031470777, 'mean_word_length': 2.2808988764044944, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2549507', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1231, 'n_words': 313}