Commit d06cda93 authored by Matija Obreza's avatar Matija Obreza
parent 9e1b3512
Pipeline #11878 failed with stage
in 15 seconds
......@@ -27,6 +27,15 @@ import java.util.Locale;
*/
public interface TransifexService {
public static enum TranslationMode {
DEFAULT,
TRANSLATOR,
REVIEWED,
ONLYTRANSLATED,
ONLYREVIEWED,
SOURCEASTRANSLATION
}
/**
* Checks if resource exists on Transifex
*
......@@ -52,7 +61,7 @@ public interface TransifexService {
* @return the translated resource
* @throws TransifexException the transifex exception
*/
String getTranslatedResource(String slug, Locale locale) throws TransifexException;
String getTranslatedResource(String slug, Locale locale, TranslationMode mode) throws TransifexException;
/**
* Create a new XHTML resource. Fails if resource exists.
......@@ -92,7 +101,7 @@ public interface TransifexService {
* @return the string
* @throws TransifexException the transifex exception
*/
String downloadTranslatedResource(String slug, Locale locale) throws TransifexException;
String downloadTranslatedResource(String slug, Locale locale, TranslationMode mode) throws TransifexException;
/**
* Ping service to test credentials
......
......@@ -204,7 +204,7 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean
* java.lang.String, java.util.Locale)
*/
@Override
public String getTranslatedResource(String slug, Locale locale)
public String getTranslatedResource(String slug, Locale locale, TranslationMode mode)
throws TransifexException {
HttpHeaders headers = basicAuthentication();
......@@ -212,9 +212,9 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean
try {
ResponseEntity<String> response = template.exchange(
transifexProjectUrl
+ "/resource/{slug}/translation/{language}",
+ "/resource/{slug}/translation/{language}?mode={mode}",
HttpMethod.GET, request, String.class, slug,
locale.getLanguage());
locale.getLanguage(), mode.toString().toLowerCase());
// FIXME Check response status. Proceed only on HTTP OK response.
if (LOG.isDebugEnabled()) {
......@@ -236,7 +236,7 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean
* (java.lang.String, java.util.Locale)
*/
@Override
public String downloadTranslatedResource(String slug, Locale locale)
public String downloadTranslatedResource(String slug, Locale locale, TranslationMode mode)
throws TransifexException {
HttpHeaders headers = basicAuthentication();
......@@ -244,9 +244,9 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean
try {
ResponseEntity<byte[]> response = template.exchange(
transifexProjectUrl
+ "/resource/{slug}/translation/{language}?file",
+ "/resource/{slug}/translation/{language}?mode={mode}&file",
HttpMethod.GET, request, byte[].class, slug,
locale.getLanguage());
locale.getLanguage(), mode.toString().toLowerCase());
// FIXME Check response status. Proceed only on HTTP OK response.
if (LOG.isDebugEnabled()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment