From 10b85bd4dfb0c0971344a9f383941f5cd0db1163 Mon Sep 17 00:00:00 2001 From: Kateryna Oblakevych Date: Tue, 26 Mar 2024 07:55:40 +0200 Subject: [PATCH] fix: empty asterisks in translation --- .../cli/commands/functionality/TranslationsUtils.java | 2 ++ .../commands/functionality/TranslationsUtilsTest.java | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/com/crowdin/cli/commands/functionality/TranslationsUtils.java b/src/main/java/com/crowdin/cli/commands/functionality/TranslationsUtils.java index 0b614b533..b7ba296be 100644 --- a/src/main/java/com/crowdin/cli/commands/functionality/TranslationsUtils.java +++ b/src/main/java/com/crowdin/cli/commands/functionality/TranslationsUtils.java @@ -43,6 +43,8 @@ public static String replaceDoubleAsterisk(String sourcePattern, String translat } else { sourceFile = ""; } + } else if (Utils.noSepAtStart(s).length() > 0 && sourceFile.startsWith(Utils.noSepAtStart(s))) { + sourceFile = ""; } } } else if (sourceFile.contains(".")) { diff --git a/src/test/java/com/crowdin/cli/commands/functionality/TranslationsUtilsTest.java b/src/test/java/com/crowdin/cli/commands/functionality/TranslationsUtilsTest.java index a059ad488..1716e1be5 100644 --- a/src/test/java/com/crowdin/cli/commands/functionality/TranslationsUtilsTest.java +++ b/src/test/java/com/crowdin/cli/commands/functionality/TranslationsUtilsTest.java @@ -63,6 +63,16 @@ static Stream testReplaceDoubleAsterisk() { Utils.normalizePath("/%two_letters_code%/**/%original_file_name%"), Utils.normalizePath("en/here/file.po"), Utils.normalizePath("/%two_letters_code%/here/%original_file_name%")), + arguments( + Utils.normalizePath("/en/**/folder/*.po"), + Utils.normalizePath("/%two_letters_code%/**/%original_file_name%"), + Utils.normalizePath("en/folder/file.po"), + Utils.normalizePath("/%two_letters_code%/%original_file_name%")), + arguments( + Utils.normalizePath("/en/**/folder/*.po"), + Utils.normalizePath("/%two_letters_code%/**/folder/%original_file_name%"), + Utils.normalizePath("en/here/folder/file.po"), + Utils.normalizePath("/%two_letters_code%/here/folder/%original_file_name%")), arguments( Utils.normalizePath("/*/**/*.po"), Utils.normalizePath("/%two_letters_code%/**/%original_file_name%"),