Skip to content

Commit

Permalink
fix: fixed outputs (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ authored May 28, 2024
1 parent df576ef commit 8716ee4
Show file tree
Hide file tree
Showing 24 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/crowdin/cli/commands/Actions.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ NewAction<PropertiesWithFiles, ProjectClient> listSources(
boolean deleteObsolete, String branchName, boolean noProgress, boolean treeView, boolean plainView);

NewAction<PropertiesWithFiles, ProjectClient> listTranslations(
boolean noProgress, boolean treeView, boolean isLocal, boolean plainView, boolean useServerSources, boolean withInContextLang);
boolean noProgress, boolean treeView, boolean isLocal, boolean plainView, boolean useServerSources, boolean withInContextLang, boolean isUpload);

NewAction<ProjectProperties, ProjectClient> listLanguages(BaseCli.LanguageCode code, boolean all, boolean noProgress, boolean plainView);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void act(Outputter out, ProjectProperties pb, ClientBundle client) {

for (String file: extractedPaths) {
String filePath = Utils.noSepAtStart(StringUtils.removeStart(file, baseTempDir.getAbsolutePath()));
out.println(OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.extracted_file"), filePath)));
out.println(OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.file_path"), filePath)));
}

if (!keepArchive) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public NewAction<PropertiesWithFiles, ProjectClient> listSources(

@Override
public NewAction<PropertiesWithFiles, ProjectClient> listTranslations(
boolean noProgress, boolean treeView, boolean isLocal, boolean plainView, boolean useServerSources, boolean withInContextLang
boolean noProgress, boolean treeView, boolean isLocal, boolean plainView, boolean useServerSources, boolean withInContextLang, boolean isUpload
) {
return new ListTranslationsAction(noProgress, treeView, isLocal, plainView, useServerSources, withInContextLang);
return new ListTranslationsAction(noProgress, treeView, isLocal, plainView, useServerSources, withInContextLang, isUpload);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) {
if (!plainView) {
out.println(OK.withIcon(
String.format(
RESOURCE_BUNDLE.getString("message.extracted_file"),
RESOURCE_BUNDLE.getString("message.file_path"),
StringUtils.removeStart(toFile.getAbsolutePath(), pb.getBasePath()))));
} else {
out.println(StringUtils.removeStart(toFile.getAbsolutePath(), pb.getBasePath()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void act(Outputter out, PropertiesWithFiles properties, ProjectClient cli

if (downloaded || dryrun) {
if (!plainView) {
out.println(OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.downloaded_file"), filePath)));
out.println(OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.file_path"), filePath)));
} else {
out.println(filePath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void act(Outputter out, ProjectProperties properties, ProjectClient clien

if (!plainView) {
out.println(OK.withIcon(String.format(
RESOURCE_BUNDLE.getString("message.translation_uploaded"), file.getPath())));
RESOURCE_BUNDLE.getString("message.uploading_file"), file.getPath())));
} else {
out.println(file.getPath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ class ListTranslationsAction implements NewAction<PropertiesWithFiles, ProjectCl
private boolean plainView;
private boolean useServerSources;
private boolean withInContextLang;
private boolean isUpload;

public ListTranslationsAction(boolean noProgress, boolean treeView, boolean isLocal, boolean plainView, boolean useServerSources, boolean withInContextLang) {
public ListTranslationsAction(boolean noProgress, boolean treeView, boolean isLocal, boolean plainView, boolean useServerSources, boolean withInContextLang, boolean isUpload) {
this.noProgress = noProgress;
this.treeView = treeView;
this.isLocal = isLocal;
this.plainView = plainView;
this.useServerSources = useServerSources;
this.withInContextLang = withInContextLang;
this.isUpload = isUpload;
}

@Override
Expand All @@ -54,7 +56,7 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) {
PlaceholderUtil placeholderUtil = new PlaceholderUtil(
project.getSupportedLanguages(), project.getProjectLanguages(!isLocal), pb.getBasePath());

(new DryrunTranslations(pb, project.getLanguageMapping(), placeholderUtil, project.getProjectLanguages(withInContextLang), false, files, useServerSources))
(new DryrunTranslations(pb, project.getLanguageMapping(), placeholderUtil, project.getProjectLanguages(withInContextLang), false, files, useServerSources, isUpload))
.run(out, treeView, plainView);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) {
}
if (!plainView) {
out.println(OK.withIcon(String.format(
RESOURCE_BUNDLE.getString("message.translation_uploaded"),
RESOURCE_BUNDLE.getString("message.uploading_file"),
StringUtils.removeStart(translationFile.getAbsolutePath(), pb.getBasePath()))));
} else {
out.println(StringUtils.removeStart(translationFile.getAbsolutePath(), pb.getBasePath()));
Expand Down Expand Up @@ -218,7 +218,7 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) {
}
if (!plainView) {
out.println(OK.withIcon(String.format(
RESOURCE_BUNDLE.getString("message.translation_uploaded"),
RESOURCE_BUNDLE.getString("message.uploading_file"),
StringUtils.removeStart(translationFile.getAbsolutePath(), pb.getBasePath()))));
} else {
out.println(StringUtils.removeStart(translationFile.getAbsolutePath(), pb.getBasePath()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static Branch getOrCreateBranch(Outputter out, String branchName, Project
request.setTitle(branchName);
Branch newBranch = client.addBranch(request);
if (!plainView) {
out.println(ExecutionStatus.OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.branch.list"), newBranch.getId(), newBranch.getName())));
out.println(ExecutionStatus.OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.branch"), branchName)));
}
project.addBranchToLocalList(newBranch);
return newBranch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract class Dryrun {
private String messageKey;

protected Dryrun() {
this("message.uploading_file");
this("message.file_path");
}

protected Dryrun(String messageKey) {
Expand All @@ -37,7 +37,7 @@ public void run(Outputter out, boolean treeView, boolean plainView) {
DrawTree.draw(files).forEach(out::println);
} else {
if (!plainView) {
files.forEach(file -> out.println(String.format(RESOURCE_BUNDLE.getString(messageKey), file)));
files.forEach(file -> out.println(OK.withIcon(String.format(RESOURCE_BUNDLE.getString(messageKey), file))));
} else {
files.forEach(out::println);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class DryrunObsoleteSources extends Dryrun {
private List<File> files;

public DryrunObsoleteSources(@NonNull PropertiesWithFiles pb, @NonNull PlaceholderUtil placeholderUtil, @NonNull Map<Long, Directory> directories, @NonNull List<File> files) {
super("message.obsolete_file");
super("message.delete_obsolete.obsolete_file_delete");
this.pb = pb;
this.placeholderUtil = placeholderUtil;
this.directories = directories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class DryrunSources extends Dryrun {
private PlaceholderUtil placeholderUtil;

public DryrunSources(PropertiesWithFiles pb, PlaceholderUtil placeholderUtil) {
super("message.file_path");
super("message.uploading_file");
this.pb = pb;
this.placeholderUtil = placeholderUtil;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ public class DryrunTranslations extends Dryrun {

public DryrunTranslations(
PropertiesWithFiles pb, LanguageMapping projectLanguageMapping, PlaceholderUtil placeholderUtil,
List<Language> languages, boolean filesMustExist, Map<String, File> projectSources, boolean useServerSources
List<Language> languages, boolean filesMustExist, Map<String, File> projectSources, boolean useServerSources, boolean isUpload
) {
super("message.file_path");

super(isUpload ? "message.uploading_file" : "message.file_path");
this.pb = pb;
this.placeholderUtil = placeholderUtil;
this.filesMustExist = filesMustExist;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ConfigTranslationsSubcommand extends ActCommandWithFiles {

@Override
protected NewAction<PropertiesWithFiles, ProjectClient> getAction(Actions actions) {
return actions.listTranslations(this.noProgress, this.treeView, false, this.plainView, false, true);
return actions.listTranslations(this.noProgress, this.treeView, false, this.plainView, false, true, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DownloadSubcommand extends ActCommandWithFiles {
@Override
protected NewAction<PropertiesWithFiles, ProjectClient> getAction(Actions actions) {
return (dryrun)
? actions.listTranslations(noProgress, treeView, false, plainView, all, true)
? actions.listTranslations(noProgress, treeView, false, plainView, all, true, false)
: actions.download(new FsFiles(), noProgress, languageIds, excludeLanguageIds, pseudo, branchName, ignoreMatch, isVerbose, plainView, all, keepArchive);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class UploadTranslationsSubcommand extends ActCommandWithFiles {
@Override
protected NewAction<PropertiesWithFiles, ProjectClient> getAction(Actions actions) {
return (dryrun)
? actions.listTranslations(noProgress, treeView, true, plainView, false, false)
? actions.listTranslations(noProgress, treeView, true, plainView, false, false, true)
: actions.uploadTranslations(noProgress, languageId, branch, importEqSuggestions, autoApproveImported, translateHidden, debug, plainView);
}

Expand Down
14 changes: 6 additions & 8 deletions src/main/resources/messages/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,6 @@ message.build_archive=Building ZIP archive with the latest translations
message.build_archive_pseudo=Building ZIP archive with the pseudo-localized translation files
message.building_translation=Building translation (%d%%)
message.building_reviewed_sources=Building reviewed sources (%d%%)
message.extracted_file=Extracted: '%s'
message.archive=Archive: '%s'
message.downloaded_files_omitted=Downloaded translations don't match the current project configuration. The translations for the following sources will be omitted (use --verbose to get the list of the omitted translations)\:
message.downloaded_files_omitted_without_sources=Due to missing respective sources, the following translations will be omitted\:
Expand All @@ -665,7 +664,6 @@ message.ask_is_enterprise=For Crowdin Enterprise
message.ask_auth_via_browser=Authorize via browser?
message.ask_organization_name=Your organization name
message.configuration_ok=@|green Your configuration file looks good|@
message.translation_uploaded=@|green Translation file '%s' has been uploaded|@
message.branch_deleted=@|green Branch '%s' deleted|@
message.branch_already_exists=Branch '%s' already exists in the project
message.branch_does_not_exist=Branch '%s' doesn't exist in the project
Expand All @@ -674,10 +672,9 @@ message.translation=Translated:
message.approval=Proofread:
message.language=@|yellow %s|@(@|yellow %s|@):
message.translation_progress=\tTranslated: %d%% (Words: %d/%d, Phrases: %d/%d)
message.approval_progress=\tApproved: %d%% (Words: %d/%d, Phrases: %d/%d)
message.approval_progress=\tProofread: %d%% (Words: %d/%d, Phrases: %d/%d)
message.already_uploaded=Skipping file '%s' because it is already uploading/uploaded
message.extracted_organization_name=Extracted organization name from provided url: %s
message.obsolete_file=Obsolete file '%s'
message.file_deleted=@|green File '%s' deleted|@
message.no_file_string_project=File management is not available for string-based projects

Expand All @@ -686,6 +683,7 @@ message.download_translations.preserve_hierarchy_warning=Because the 'preserve_h

message.language.list=@|yellow %s|@ @|green %s|@

message.branch=Branch '%s'
message.branch.list=@|yellow #%d|@ @|green %s|@
message.branch.merge=@|green Merged branch '%s' into '%s'|@
message.branch.merge_details=\tMerge summary: %s
Expand All @@ -706,11 +704,11 @@ message.source_string_list_not_found=No strings found
message.glossary.download_success=@|green '%s' downloaded successfully|@
message.glossary.list=@|yellow #%d|@ @|green %s|@ (@|red terms: %d|@)
message.glossary.list_term=\t@|yellow #%d|@ @|green %s|@: %s
message.glossary.import_success=@|green Imported in @|yellow #%s|@ @|green '%s'|@ glossary|@
message.glossary.import_success=Imported in @|yellow #%s|@ @|green '%s'|@ glossary

message.tm.download_success=@|green '%s' downloaded successfully|@
message.tm.list=@|yellow #%d|@ %s (@|green segments: %d|@)
message.tm.import_success=@|green Imported in @|yellow #%s|@ @|green '%s'|@ translation memory|@
message.tm.import_success=Imported in @|yellow #%s|@ @|green '%s'|@ translation memory
message.tm.list_empty=No translation memories found

message.screenshot.deleted=@|green Screenshot '%s' deleted successfully|@
Expand Down Expand Up @@ -745,9 +743,9 @@ message.label.list_empty=No labels found
message.label.already_exists=Label '%s' already exists in the project
message.label.deleted=@|green Label '%s' deleted successfully|@

message.delete_obsolete.obsolete_file_delete=Obsolete file '%s' was deleted
message.delete_obsolete.obsolete_file_delete='%s' file was deleted
message.delete_obsolete.obsolete_directory_delete=No obsolete files were found
message.delete_obsolete.no_obsolete_files_found=Obsolete directory '%s' was deleted
message.delete_obsolete.no_obsolete_files_found='%s' directory was deleted
message.delete_obsolete.no_obsolete_directories_found=No obsolete directories found

message.html_page.title=Crowdin CLI - Authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void testListSources() {

@Test
public void testListTranslations() {
assertNotNull(actions.listTranslations(false, false, false, false, false, false));
assertNotNull(actions.listTranslations(false, false, false, false, false, false, false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public void testDryRun() {
action.act(Outputter.getDefault(), pb, client);

String outMessage1 = OK.withIcon("Fetching project info");
String outMessage2 = OK.withIcon(String.format("@|green File 'common%sstrings.xml'|@", File.separator));
String outMessage2 = OK.withIcon(String.format("common%sstrings.xml", File.separator));

client.downloadFullProject(null);
client.downloadFile(101L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void testForServerInteraction() throws ResponseException {
.thenReturn(ProjectBuilder.emptyProject(Long.parseLong(pb.getProjectId()))
.addFile("first.po", "gettext", 101L, null, null).build());

NewAction<PropertiesWithFiles, ProjectClient> action = new ListTranslationsAction(false, false, false, false, false, false);
NewAction<PropertiesWithFiles, ProjectClient> action = new ListTranslationsAction(false, false, false, false, false, false, false);
action.act(Outputter.getDefault(), pb, client);

verify(client).downloadFullProject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ConfigTranslationsSubcommandTest extends PicocliTestUtils {
public void testListTranslations() {
this.execute(CommandNames.CONFIG, CommandNames.TRANSLATIONS);
verify(actionsMock)
.listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean());
.listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean());
this.check(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void testDownload() {
public void testDownloadDryrun() {
this.execute(CommandNames.DOWNLOAD, "--dryrun");
verify(actionsMock)
.listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean());
.listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean());
this.check(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void mockActions() {
.thenReturn(actionMock);
when(actionsMock.listSources(anyBoolean(), any(), anyBoolean(), anyBoolean(), anyBoolean()))
.thenReturn(actionMock);
when(actionsMock.listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean()))
when(actionsMock.listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean()))
.thenReturn(actionMock);
when(actionsMock.status(anyBoolean(), any(), any(), any(), any(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean()))
.thenReturn(actionMock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void testUploadTranslations() {
public void testUploadTranslationsDryrun() {
this.execute(CommandNames.UPLOAD, CommandNames.UPLOAD_TRANSLATIONS, "--dryrun");
verify(actionsMock)
.listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean());
.listTranslations(anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean());
this.check(true);
}
}

0 comments on commit 8716ee4

Please sign in to comment.