diff --git a/cli/src/main/java/com/box/l10n/mojito/cli/command/DropExportCommand.java b/cli/src/main/java/com/box/l10n/mojito/cli/command/DropExportCommand.java index bc41b7f3da..3006fbd1d3 100644 --- a/cli/src/main/java/com/box/l10n/mojito/cli/command/DropExportCommand.java +++ b/cli/src/main/java/com/box/l10n/mojito/cli/command/DropExportCommand.java @@ -168,7 +168,7 @@ private boolean shouldCreateDrop(Repository repository) throws CommandException RepositoryStatistic repoStat = repository.getRepositoryStatistic(); if (repoStat != null) { for (RepositoryLocaleStatistic repoLocaleStat : repoStat.getRepositoryLocaleStatistics()) { - if (bcp47TagsForTranslation.contains(repoLocaleStat.getLocale().getBcp47Tag()) && repoLocaleStat.getForTranslationCount() > 0L) { + if (bcp47TagsForTranslation.contains(repoLocaleStat.getLocale().getBcp47Tag()) && repoLocaleStat.getForTranslationWordCount() > 0L) { createDrop = true; break; } diff --git a/cli/src/test/java/com/box/l10n/mojito/cli/command/DropExportCommandTest.java b/cli/src/test/java/com/box/l10n/mojito/cli/command/DropExportCommandTest.java index 7e85273ac9..6536fa12e0 100644 --- a/cli/src/test/java/com/box/l10n/mojito/cli/command/DropExportCommandTest.java +++ b/cli/src/test/java/com/box/l10n/mojito/cli/command/DropExportCommandTest.java @@ -81,6 +81,27 @@ public void exportFullyTranslated() throws Exception { assertEquals("A Drop should not have been added", findAllBefore.getTotalElements(), findAllAfter.getTotalElements()); } + @Test + public void exportZeroWords() throws Exception { + + Repository repository = createTestRepoUsingRepoService(); + + getL10nJCommander().run("push", "-r", repository.getName(), + "-s", getInputResourcesTestDir("source").getAbsolutePath()); + + // there should be a single string for translation, but with 0 words in it + waitForRepositoryToHaveStringsForTranslations(repository.getId()); + + Page findAllBefore = dropClient.getDrops(repository.getId(), null, null, null); + + getL10nJCommander().run("drop-export", "-r", repository.getName()); + + Page findAllAfter = dropClient.getDrops(repository.getId(), null, null, null); + + // drop export command should not trigger an export when there are 0 words for translation + assertEquals("A Drop should not have been added", findAllBefore.getTotalElements(), findAllAfter.getTotalElements()); + } + @Test public void exportSelectFullyTranslatedLocales() throws Exception { diff --git a/cli/src/test/resources/com/box/l10n/mojito/cli/command/DropExportCommandTest/exportZeroWords/input/source/source-xliff.xliff b/cli/src/test/resources/com/box/l10n/mojito/cli/command/DropExportCommandTest/exportZeroWords/input/source/source-xliff.xliff new file mode 100644 index 0000000000..871bb72cfa --- /dev/null +++ b/cli/src/test/resources/com/box/l10n/mojito/cli/command/DropExportCommandTest/exportZeroWords/input/source/source-xliff.xliff @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/restclient/src/main/java/com/box/l10n/mojito/rest/entity/RepositoryLocaleStatistic.java b/restclient/src/main/java/com/box/l10n/mojito/rest/entity/RepositoryLocaleStatistic.java index de6915a77b..515f63bef4 100644 --- a/restclient/src/main/java/com/box/l10n/mojito/rest/entity/RepositoryLocaleStatistic.java +++ b/restclient/src/main/java/com/box/l10n/mojito/rest/entity/RepositoryLocaleStatistic.java @@ -9,6 +9,8 @@ public class RepositoryLocaleStatistic { private Locale locale; private Long forTranslationCount = 0L; + private Long forTranslationWordCount = 0L; + public Locale getLocale() { return locale; } @@ -25,4 +27,12 @@ public void setForTranslationCount(Long forTranslationCount) { this.forTranslationCount = forTranslationCount; } + public Long getForTranslationWordCount() { + return forTranslationWordCount; + } + + public void setForTranslationWordCount(Long forTranslationWordCount) { + this.forTranslationWordCount = forTranslationWordCount; + } + }