Search in sources :

Example 1 with PoTermUpdate

use of org.activityinfo.i18n.tools.po.PoTermUpdate in project activityinfo by bedatadriven.

the class PoEditorSource method updateTerms.

/**
 * Updates the translation source, adding any missing terms and their default
 * translations.
 *
 * @param terms
 */
public void updateTerms(List<ResourceClassTerm> terms, boolean sync) throws IOException {
    List<PoTermUpdate> updates = Lists.newArrayList();
    for (ResourceClassTerm term : terms) {
        updates.add(new PoTermUpdate(term.getKey(), term.getDefaultTranslation()));
    }
    PoEditorClient client = new PoEditorClient(apiToken);
    PoUploadResponse response = client.upload(projectId, updates, sync);
    PoUploadResponse.Details details = response.getDetails();
    System.out.println(String.format("Terms:       %5d  Added: %5d  Deleted: %d", details.getTerms().getParsed(), details.getTerms().getAdded(), details.getTerms().getDeleted()));
    System.out.println(String.format("Definitions: %5d  Added: %5d  Updated: %d", details.getDefinitions().getParsed(), details.getDefinitions().getAdded(), details.getDefinitions().getUpdated()));
}
Also used : ResourceClassTerm(org.activityinfo.i18n.tools.model.ResourceClassTerm) PoUploadResponse(org.activityinfo.i18n.tools.po.PoUploadResponse) PoTermUpdate(org.activityinfo.i18n.tools.po.PoTermUpdate) PoEditorClient(org.activityinfo.i18n.tools.po.PoEditorClient)

Aggregations

ResourceClassTerm (org.activityinfo.i18n.tools.model.ResourceClassTerm)1 PoEditorClient (org.activityinfo.i18n.tools.po.PoEditorClient)1 PoTermUpdate (org.activityinfo.i18n.tools.po.PoTermUpdate)1 PoUploadResponse (org.activityinfo.i18n.tools.po.PoUploadResponse)1