diff --git a/src/main/java/com/crowdin/cli/commands/actions/GlossaryListAction.java b/src/main/java/com/crowdin/cli/commands/actions/GlossaryListAction.java index 909b5739..9cecaec8 100644 --- a/src/main/java/com/crowdin/cli/commands/actions/GlossaryListAction.java +++ b/src/main/java/com/crowdin/cli/commands/actions/GlossaryListAction.java @@ -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; @@ -34,7 +35,7 @@ public void act(Outputter out, BaseProperties pb, ClientGlossary client) { try { List 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)); } diff --git a/src/main/java/com/crowdin/cli/utils/Utils.java b/src/main/java/com/crowdin/cli/utils/Utils.java index f1821a32..30ed2dec 100755 --- a/src/main/java/com/crowdin/cli/utils/Utils.java +++ b/src/main/java/com/crowdin/cli/utils/Utils.java @@ -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]+", " "); + } } diff --git a/src/main/resources/messages/messages.properties b/src/main/resources/messages/messages.properties index e71b367d..326f76af 100755 --- a/src/main/resources/messages/messages.properties +++ b/src/main/resources/messages/messages.properties @@ -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 @@ -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' diff --git a/src/test/java/com/crowdin/cli/utils/UtilsTest.java b/src/test/java/com/crowdin/cli/utils/UtilsTest.java index 50401f8a..fd4b0c57 100644 --- a/src/test/java/com/crowdin/cli/utils/UtilsTest.java +++ b/src/test/java/com/crowdin/cli/utils/UtilsTest.java @@ -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)); + } }