Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
add merge type option to Maven client (Fixes issue 28)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Apr 13, 2011
1 parent 94c6b01 commit ca63a8b
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 3 deletions.
Expand Up @@ -20,6 +20,7 @@ public class UploadPoTask extends ConfigurableProjectTask implements PublicanPus
private boolean importPo;
private boolean copyTrans = true;
private boolean validate;
private String mergeType = "auto";

public static void main(String[] args)
{
Expand Down Expand Up @@ -111,6 +112,12 @@ public String getSourceLang()
{
return sourceLang;
}

@Override
public String getMergeType()
{
return mergeType;
}


}
Expand Up @@ -72,6 +72,7 @@ public void run() throws Exception
log.info("Username: {}", opts.getUsername());
log.info("Source language: {}", opts.getSourceLang());
log.info("Copy previous translations: {}", opts.getCopyTrans());
log.info("Merge type: {}", opts.getMergeType());
if (opts.getImportPo())
{
log.info("Importing source and target documents");
Expand Down Expand Up @@ -226,7 +227,7 @@ else if (opts.isInteractiveMode())
JaxbUtil.validateXml(targetDoc, jc);
}
log.info("pushing target document [name={} client-locale={}] to server [locale={}]", new Object[] { srcDoc.getName(), locale.getLocalLocale(), locale.getLocale() });
ClientResponse<String> putTransResponse = translationResources.putTranslations(docUri, new LocaleId(locale.getLocale()), targetDoc, extensions);
ClientResponse<String> putTransResponse = translationResources.putTranslations(docUri, new LocaleId(locale.getLocale()), targetDoc, extensions, opts.getMergeType());
ClientUtility.checkResult(putTransResponse, uri);
}
}
Expand Down
Expand Up @@ -10,4 +10,5 @@ public interface PublicanPushOptions extends ConfigurableProjectOptions
public boolean getImportPo();
public boolean getCopyTrans();
public boolean getValidate();
public String getMergeType();
}
Expand Up @@ -19,6 +19,7 @@ public class PublicanPushOptionsImpl extends ConfigurableProjectOptionsImpl impl
private boolean importPo;
private boolean copyTrans = true;
private boolean validate;
private String mergeType = "auto";

public PublicanPushOptionsImpl()
{
Expand Down Expand Up @@ -117,5 +118,11 @@ public String getSourceLang()
{
return sourceLang;
}

@Override
public String getMergeType()
{
return mergeType;
}

}
Expand Up @@ -94,7 +94,7 @@ private void publicanPush(boolean importPo, boolean mapLocale) throws Exception
expectedLocale = new LocaleId("ja");
else
expectedLocale = new LocaleId("ja-JP");
EasyMock.expect(mockTranslationResources.putTranslations(eq("RPM"), eq(expectedLocale), (TranslationsResource) notNull(), eq(extensionSet))).andReturn(mockOKResponse);
EasyMock.expect(mockTranslationResources.putTranslations(eq("RPM"), eq(expectedLocale), (TranslationsResource) notNull(), eq(extensionSet), eq("auto"))).andReturn(mockOKResponse);
}
FliesClientRequestFactory mockRequestFactory = EasyMock.createNiceMock(FliesClientRequestFactory.class);

Expand Down
Expand Up @@ -53,7 +53,7 @@ public PublicanPushCommand initCommand()
private String sourceLang = "en-US";

/**
* Import translations from local PO files to the server, overwriting or erasing
* Import/merge translations from local PO files to the server, overwriting or erasing
* existing translations (DANGER!)
*
* @parameter expression="${zanata.importPo}"
Expand All @@ -73,6 +73,13 @@ public PublicanPushCommand initCommand()
*/
private boolean validate;

/**
* Merge type: "auto" (default) or "import" (DANGER!).
*
* @parameter expression="${zanata.merge}" default-value="auto"
*/
private String merge;

@Override
public File getSrcDir()
{
Expand Down Expand Up @@ -107,5 +114,11 @@ public boolean getValidate()
{
return validate;
}

@Override
public String getMergeType()
{
return merge;
}

}
Expand Up @@ -67,5 +67,9 @@ public interface ITranslationResources
@PUT
@Path("{id}/translations/{locale}")
public ClientResponse<String> putTranslations(@PathParam("id") String idNoSlash, @PathParam("locale") LocaleId locale, TranslationsResource messageBody, @QueryParam("ext") StringSet extensions);

@PUT
@Path("{id}/translations/{locale}")
public ClientResponse<String> putTranslations(@PathParam("id") String idNoSlash, @PathParam("locale") LocaleId locale, TranslationsResource messageBody, @QueryParam("ext") StringSet extensions, @QueryParam("merge") String mergeType);

}

0 comments on commit ca63a8b

Please sign in to comment.