com.mytaxi.apis.phrase.api.translation.DefaultPhraseTranslationAPI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of phrase-java-client Show documentation
Show all versions of phrase-java-client Show documentation
This projects contains of services to handle the translations from [PhraseApp API
v2](http://docs.phraseapp.com/api/v2/). It's supposed to expose Phrase translations as POJO or as File within the java world.
package com.mytaxi.apis.phrase.api.translation;
import com.google.common.base.Preconditions;
import com.mytaxi.apis.phrase.api.GenericPhraseAPI;
import com.mytaxi.apis.phrase.api.translation.dto.PhraseTranslationDTO;
import com.mytaxi.apis.phrase.domainobject.translation.PhraseTranslation;
import com.mytaxi.apis.phrase.exception.PhraseAppApiException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.http.client.utils.URIBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
/**
* Created by m.winkelmann on 05.11.15.
*/
public class DefaultPhraseTranslationAPI extends GenericPhraseAPI implements PhraseTranslationAPI
{
private static final Logger LOG = LoggerFactory.getLogger(DefaultPhraseTranslationAPI.class);
// ---- configuration -----
private static final String PLACEHOLDER_PROJECT_ID = "{projectid}";
private static final String PLACEHOLDER_LOCALE_ID = "{localeid}";
private static final String PHRASE_TRANSLATIONS_PATH = "/api/v2/projects/{projectid}/locales/{localeid}/translations";
protected DefaultPhraseTranslationAPI(final RestTemplate restTemplate, final String authToken)
{
super(restTemplate, authToken);
}
public DefaultPhraseTranslationAPI(final String authToken)
{
super(createRestTemplateWithConverter(), authToken);
}
@Override
public List listTranslations(String projectId, String localeId) throws PhraseAppApiException
{
Preconditions.checkNotNull(projectId, "ProjectId must not be null.");
Preconditions.checkNotNull(localeId, "LocaleId must not be null.");
LOG.trace("Start to retrieve translations for projectId: {} and localeId: {}", projectId, localeId);
PhraseTranslationDTO[] requestedTranslations = null;
try
{
String requestPath = createRequestPath(projectId, localeId);
LOG.trace("Call requestPath: {} to get locales from phrase.", requestPath);
final URIBuilder builder = createUriBuilder(requestPath);
HttpEntity
© 2015 - 2025 Weber Informatics LLC | Privacy Policy