Skip to content

Commit

Permalink
fix: fix output
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ committed May 24, 2024
1 parent b74e4af commit 939c7aa
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 17 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 @@ -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 @@ -25,8 +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(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
1 change: 0 additions & 1 deletion 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 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 @@ -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 939c7aa

Please sign in to comment.