All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.freenow.apis.phrase.api.locale.PhraseLocaleMapper Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 3.0.0
Show newest version
package com.freenow.apis.phrase.api.locale;

import com.freenow.apis.phrase.api.locale.dto.PhraseLocaleDTO;
import com.freenow.apis.phrase.domainobject.locale.PhraseBranch;
import com.freenow.apis.phrase.domainobject.locale.PhraseLocale;
import com.freenow.apis.phrase.domainobject.locale.PhraseProject;

import java.util.ArrayList;
import java.util.List;

public class PhraseLocaleMapper
{
    public static PhraseProject makePhraseProject(String projectId, List branches)
    {
        return PhraseProject.newBuilder()
            .withProjectId(projectId)
            .withBranches(branches)
            .build();
    }


    public static PhraseBranch makePhraseBranch(String branch, PhraseLocaleDTO[] requestedLocales)
    {
        return PhraseBranch.newBuilder()
            .withBranchName(branch)
            .withLocales(makePhraseLocales(requestedLocales))
            .build();
    }


    public static PhraseLocale makePhraseLocale(PhraseLocaleDTO localeDTO)
    {
        return PhraseLocale.newBuilder().withId(localeDTO.getId()).withName(localeDTO.getName()).withCode(localeDTO.getCode()).build();
    }


    private static List makePhraseLocales(PhraseLocaleDTO[] requestedLocales)
    {
        List locales = new ArrayList<>(requestedLocales.length);
        for (PhraseLocaleDTO localeDTO : requestedLocales)
        {
            locales.add(makePhraseLocale(localeDTO));
        }
        return locales;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy