Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: translation pattern creation on windows #604

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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