Commit d06cda93 authored by Matija Obreza's avatar Matija Obreza
Browse files
parent 9e1b3512
...@@ -27,6 +27,15 @@ import java.util.Locale; ...@@ -27,6 +27,15 @@ import java.util.Locale;
*/ */
public interface TransifexService { public interface TransifexService {
public static enum TranslationMode {
DEFAULT,
TRANSLATOR,
REVIEWED,
ONLYTRANSLATED,
ONLYREVIEWED,
SOURCEASTRANSLATION
}
/** /**
* Checks if resource exists on Transifex * Checks if resource exists on Transifex
* *
...@@ -52,7 +61,7 @@ public interface TransifexService { ...@@ -52,7 +61,7 @@ public interface TransifexService {
* @return the translated resource * @return the translated resource
* @throws TransifexException the transifex exception * @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. * Create a new XHTML resource. Fails if resource exists.
...@@ -92,7 +101,7 @@ public interface TransifexService { ...@@ -92,7 +101,7 @@ public interface TransifexService {
* @return the string * @return the string
* @throws TransifexException the transifex exception * @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 * Ping service to test credentials
......
...@@ -204,7 +204,7 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean ...@@ -204,7 +204,7 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean
* java.lang.String, java.util.Locale) * java.lang.String, java.util.Locale)
*/ */
@Override @Override
public String getTranslatedResource(String slug, Locale locale) public String getTranslatedResource(String slug, Locale locale, TranslationMode mode)
throws TransifexException { throws TransifexException {
HttpHeaders headers = basicAuthentication(); HttpHeaders headers = basicAuthentication();
...@@ -212,9 +212,9 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean ...@@ -212,9 +212,9 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean
try { try {
ResponseEntity<String> response = template.exchange( ResponseEntity<String> response = template.exchange(
transifexProjectUrl transifexProjectUrl
+ "/resource/{slug}/translation/{language}", + "/resource/{slug}/translation/{language}?mode={mode}",
HttpMethod.GET, request, String.class, slug, HttpMethod.GET, request, String.class, slug,
locale.getLanguage()); locale.getLanguage(), mode.toString().toLowerCase());
// FIXME Check response status. Proceed only on HTTP OK response. // FIXME Check response status. Proceed only on HTTP OK response.
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
...@@ -236,7 +236,7 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean ...@@ -236,7 +236,7 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean
* (java.lang.String, java.util.Locale) * (java.lang.String, java.util.Locale)
*/ */
@Override @Override
public String downloadTranslatedResource(String slug, Locale locale) public String downloadTranslatedResource(String slug, Locale locale, TranslationMode mode)
throws TransifexException { throws TransifexException {
HttpHeaders headers = basicAuthentication(); HttpHeaders headers = basicAuthentication();
...@@ -244,9 +244,9 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean ...@@ -244,9 +244,9 @@ public class TransifexServiceImpl implements TransifexService, InitializingBean
try { try {
ResponseEntity<byte[]> response = template.exchange( ResponseEntity<byte[]> response = template.exchange(
transifexProjectUrl transifexProjectUrl
+ "/resource/{slug}/translation/{language}?file", + "/resource/{slug}/translation/{language}?mode={mode}&file",
HttpMethod.GET, request, byte[].class, slug, HttpMethod.GET, request, byte[].class, slug,
locale.getLanguage()); locale.getLanguage(), mode.toString().toLowerCase());
// FIXME Check response status. Proceed only on HTTP OK response. // FIXME Check response status. Proceed only on HTTP OK response.
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
......
Supports Markdown
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