Skip to content

Commit

Permalink
fix(ZNTA-2275): Make client glossary commands work for json
Browse files Browse the repository at this point in the history
  • Loading branch information
djansen-redhat committed Feb 21, 2018
1 parent 5bcc7a9 commit bc1402f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Expand Up @@ -68,9 +68,11 @@ public void run() throws Exception {
String fileType = StringUtils.isEmpty(getOpts().getFileType()) ? "csv"
: getOpts().getFileType();
if (!fileType.equalsIgnoreCase("po")
&& !fileType.equalsIgnoreCase("csv")) {
&& !fileType.equalsIgnoreCase("csv")
&& !fileType.equalsIgnoreCase("json")) {
throw new RuntimeException(
"Option '--file-type' is not valid. Please use 'csv' or 'po'");
"Option '--file-type' is not valid. " +
"Please use 'csv', 'json' or 'po'");
}

log.info("Server: {}", getOpts().getUrl());
Expand Down
Expand Up @@ -16,16 +16,18 @@ public class GlossaryPullOptionsImpl extends ConfigurableGlossaryOptionsImpl
private String fileType;
private String[] transLang;

@Option(name = "--file-type", metaVar = "(CSV or PO)",
@Option(name = "--file-type", metaVar = "(CSV, JSON or PO)",
usage = "File type to be downloaded.\n" +
"csv (default) - csv file format with comma separated values\n" +
"po - a zip file of po files on available locales")
"po - a zip file of po files on available locales\n" +
"json - structured json file format")
public void setFileType(String fileType) {
this.fileType = fileType;
}

@Option(name = "--trans-lang", metaVar = "LOCALE1,LOCALE2",
usage = "Translation languages to pull from Zanata.\nLeave empty for all available languages.")
usage = "Translation languages to pull from Zanata.\n" +
"Leave empty for all available languages.")
public void setTransLang(String transLang) {
this.transLang = transLang.split(",");
}
Expand Down
Expand Up @@ -35,6 +35,7 @@
import org.slf4j.LoggerFactory;
import org.zanata.adapter.glossary.AbstractGlossaryPushReader;
import org.zanata.adapter.glossary.GlossaryCSVReader;
import org.zanata.adapter.glossary.GlossaryJsonReader;
import org.zanata.adapter.glossary.GlossaryPoReader;
import org.zanata.client.commands.ConfigurableCommand;
import org.zanata.client.commands.OptionsUtil;
Expand Down Expand Up @@ -79,6 +80,7 @@ public GlossaryPushCommand(GlossaryPushOptions opts) {
glossaryReaders.put("po", new GlossaryPoReader(
srcLocaleId, transLocaleId));
glossaryReaders.put("csv", new GlossaryCSVReader(srcLocaleId));
glossaryReaders.put("json", new GlossaryJsonReader(srcLocaleId));
}

private AbstractGlossaryPushReader getReader(String fileExtension) {
Expand Down
Expand Up @@ -44,7 +44,7 @@
/**
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
public class GlossaryJsonReader {
public class GlossaryJsonReader extends AbstractGlossaryPushReader {
private final LocaleId srcLang;

private final static String TERM = "term";
Expand Down

0 comments on commit bc1402f

Please sign in to comment.