diff --git a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/util/Translator.kt b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/util/Translator.kt index 802da6c..96df92e 100644 --- a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/util/Translator.kt +++ b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/util/Translator.kt @@ -85,7 +85,7 @@ class Translator private constructor(private val iso: String) { // See how it impacts the remaining. var token: String = capture // StringEscapeUtils.unescapeHtml4(capture) - if (StringUtils.containsOnly(token, "\r\n\t -;:.'\"/<>\u00A00123456789€[]!?")) output.print(capture) else { + if (StringUtils.containsOnly(token, "\r\n\t -;:.'\"/<>\u00A00123456789€[]!")) output.print(capture) else { token = normalize(token) token = translate(token) output.print(token) // (StringEscapeUtils.escapeHtml4(token)) @@ -136,7 +136,7 @@ class Translator private constructor(private val iso: String) { get() = textAccessor[this] as String set(value: String) { textAccessor[this] = value } - private val saveMissingTranslations = WebappManager.getProperty("env") == "dev" + private val saveMissingTranslations = System.getProperty("pairgoth.webapp.env") == "dev" private val missingTranslations: MutableSet = ConcurrentSkipListSet() private fun reportMissingTranslation(enText: String) { @@ -148,12 +148,8 @@ class Translator private constructor(private val iso: String) { private val textAccessor = ASTText::class.java.getDeclaredField("ctext").apply { isAccessible = true } private val logger = LoggerFactory.getLogger("translation") private val translatedTemplates: MutableMap, Template> = ConcurrentHashMap, Template>() - private val punctuation = "[ \\r\\n\\t /–-]| |‐|«|»:," private val textExtractor = Pattern.compile( - "<[^>]+\\s(?:placeholder|title)=\"(?[^\"]*)\"[^>]*>|" + // text inside placeholder or title attribute - "(?<=>)(?:${punctuation})*(?[^<>]+?)(?:${punctuation})*(?=<|$)|" + // text between a tag and another tag or the end - "(?<=>|^)(?:${punctuation})*(?[^<>]+?)(?:${punctuation})*(?=<)|" + // text between a tag or the beginning and another tag - "^(?:${punctuation})*(?[^<>]+?)(?:${punctuation})*(?=$)", // text between beginning and end + "<[^>]+\\s(?:placeholder|title)=\"(?[^\"]*)\"[^>]*>|(?<=>)(?:[ \\r\\n\\t\u00A0/–-]| |‐)*(?[^<>]+?)(?:[ \\r\\n\\t\u00A0/–-]| |‐)*(?=<|$)|(?<=>|^)(?:[ \\r\\n\\t\u00A0/–-]| |‐)*(?[^<>]+?)(?:[ \\r\\n\\t\u00A0/–-]| |‐)*(?=<)|^(?:[ \\r\\n\\t /–-]| |‐)*(?[^<>]+?)(?:[ \\r\\n\\t /–-]| |‐)*(?=$)", Pattern.DOTALL ) private val ignoredTags = setOf("head", "script", "style")