Skip to content

Commit

Permalink
fix: translation pattern creation on windows (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
yzerk committed Jun 26, 2023
1 parent 9be90fc commit c4ad0af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static String replaceDoubleAsterisk(String sourcePattern, String translat
String[] sourceNodes = sourcePattern.split("\\*\\*");
for (int i = 0; i < sourceNodes.length; i++) {
if (sourceFile.contains(sourceNodes[i])) {
sourceFile = StringUtils.substring(sourceFile, sourceFile.indexOf(Utils.regexPath(sourceNodes[i])), sourceFile.length() - 1)
sourceFile = StringUtils.substring(sourceFile, sourceFile.indexOf(sourceNodes[i]), sourceFile.length() - 1)
.replaceFirst(Utils.regexPath(sourceNodes[i]), "");
} else if (sourceNodes.length - 1 == i) {
if (sourceNodes[i].contains(Utils.PATH_SEPARATOR)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class TranslationsUtilsTest {

@ParameterizedTest
@MethodSource
@DisabledOnOs(OS.WINDOWS)
public void testReplaceDoubleAsterisk(String sourcePattern, String translationPattern, String sourceFile, String expected) {
String result = TranslationsUtils.replaceDoubleAsterisk(sourcePattern, translationPattern, sourceFile);
assertEquals(expected, result,
Expand Down Expand Up @@ -68,7 +67,12 @@ static Stream<Arguments> testReplaceDoubleAsterisk() {
Utils.normalizePath("/*/**/*.po"),
Utils.normalizePath("/%two_letters_code%/**/%original_file_name%"),
Utils.normalizePath("hmm/here/file.po"),
Utils.normalizePath("/%two_letters_code%/hmm/here/%original_file_name%"))
Utils.normalizePath("/%two_letters_code%/hmm/here/%original_file_name%")),
arguments(
Utils.normalizePath("/english/**/*.yml"),
Utils.normalizePath("/%language%/**/%file_name%_l_%language%.%file_extension%"),
Utils.normalizePath("english/folder/messages_l_english.yml"),
Utils.normalizePath("/%language%/folder/%file_name%_l_%language%.%file_extension%"))
);
}

Expand Down

0 comments on commit c4ad0af

Please sign in to comment.