Skip to content

Commit

Permalink
feat: fixed verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ committed Mar 18, 2024
1 parent 33546dd commit fd437f3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;

import static com.crowdin.cli.BaseCli.RESOURCE_BUNDLE;
import static com.crowdin.cli.utils.Utils.toSingleLineString;
import static com.crowdin.cli.utils.console.ExecutionStatus.OK;
import static com.crowdin.cli.utils.console.ExecutionStatus.WARNING;

Expand All @@ -34,7 +35,7 @@ public void act(Outputter out, BaseProperties pb, ClientGlossary client) {
try {
List<Term> terms = client.listTerms(glossary.getId());
for (Term term : terms) {
String description = (term.getDescription() != null) ? term.getDescription() : "";
String description = toSingleLineString((term.getDescription() != null) ? term.getDescription() : "");
out.println(String.format(
RESOURCE_BUNDLE.getString("message.glossary.list_term"), term.getId(), term.getText(), description));
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/crowdin/cli/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,8 @@ public static String encodeURL(@NonNull String toEncode) {
throw new RuntimeException(e);
}
}

public static String toSingleLineString(String str) {
return str.replaceAll("[\r\n]+", " ");
}
}
3 changes: 0 additions & 3 deletions src/main/resources/messages/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ error.glossary.build_glossary=Failed to build the glossary
error.glossary.not_found_by_name=Couldn't find glossary by the specified name
error.glossary.no_identifiers=Specify glossary name or ID
error.glossary.wrong_format=Supported formats: tbx, csv, xlsx
error.glossary.no_id_and_no_name='--id' or '--name' should be specified to identify glossary
error.glossary.scheme_and_wrong_format=Scheme is used only for CSV or XLS/XLSX files
error.glossary.scheme_is_required=Scheme is required for CSV or XLS/XLSX files
error.glossary.first_line_contains_header_and_wrong_format='--first-line-contains-header' is used only for CSV or XLS/XLSX files
Expand All @@ -504,8 +503,6 @@ error.status.only_one_allowed=Only one of the following options can be used at a

error.tm.build_tm=Failed to build the translation memory
error.tm.wrong_format=Supported formats: tmx, csv, xlsx
error.tm.id_and_name='--id' and '--name' can't be specified simultaneously to identify translation memory
error.tm.no_id_and_no_name='--id' or '--name' should be specified to identify translation memory
error.tm.scheme_is_required=Scheme is required for CSV or XLS/XLSX files
error.tm.first_line_contains_header_and_wrong_format='--first-line-contains-header' is used only for CSV or XLS/XLSX files
error.tm.target_language_id_is_null='--target-language-id' must be specified along with '--source-language-id'
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/com/crowdin/cli/utils/UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,16 @@ public void testProxyCredentials() {
public void testEncodeURL() {
assertEquals("Hello+World", Utils.encodeURL("Hello World"));
}

@Test
public void testToSingleLineString() {
assertEquals("", Utils.toSingleLineString(""));
assertEquals("TesT", Utils.toSingleLineString("TesT"));
String multiline = "line 1" +
System.lineSeparator() +
"line 2" +
System.lineSeparator() +
"line 3";
assertEquals("line 1 line 2 line 3", Utils.toSingleLineString(multiline));
}
}

0 comments on commit fd437f3

Please sign in to comment.