diff --git a/backend/data/src/main/kotlin/io/tolgee/service/machineTranslation/PluralTranslationUtil.kt b/backend/data/src/main/kotlin/io/tolgee/service/machineTranslation/PluralTranslationUtil.kt index 30eabd3f55..a18028ca58 100644 --- a/backend/data/src/main/kotlin/io/tolgee/service/machineTranslation/PluralTranslationUtil.kt +++ b/backend/data/src/main/kotlin/io/tolgee/service/machineTranslation/PluralTranslationUtil.kt @@ -64,9 +64,9 @@ class PluralTranslationUtil( companion object { const val REPLACE_NUMBER_PLACEHOLDER = "{%{REPLACE_NUMBER}%}" - private const val TOLGEE_TAG_OPEN = "" + private const val TOLGEE_TAG_OPEN = "" private const val TOLGEE_TAG_CLOSE = "" - val TOLGEE_TAG_REGEX = "$TOLGEE_TAG_OPEN.*?$TOLGEE_TAG_CLOSE".toRegex() + val TOLGEE_TAG_REGEX = "]*?\">.*?".toRegex() /** * Returns all target forms with examples from source diff --git a/backend/data/src/test/kotlin/io/tolgee/unit/util/PluralTranslationUtilTest.kt b/backend/data/src/test/kotlin/io/tolgee/unit/util/PluralTranslationUtilTest.kt index d84f4ea25b..ac75b840e5 100644 --- a/backend/data/src/test/kotlin/io/tolgee/unit/util/PluralTranslationUtilTest.kt +++ b/backend/data/src/test/kotlin/io/tolgee/unit/util/PluralTranslationUtilTest.kt @@ -18,14 +18,20 @@ class PluralTranslationUtilTest { result.toMap().assert.isEqualTo( mapOf( - "one" to "1 apple", - "few" to "2 apples", - "many" to "0.5 apples", - "other" to "10 apples", + "one" to "1 apple", + "few" to "2 apples", + "many" to "0.5 apples", + "other" to "10 apples", "=1" to "one apple", "=2" to "Two apples", - "=5" to "5 apples", + "=5" to "5 apples", ), ) } + + @Test + fun `strips translated x tags`() { + val text = "C'e 1 mela" + text.replace(PluralTranslationUtil.TOLGEE_TAG_REGEX, "#").assert.isEqualTo("C'e # mela") + } }