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

com.mytaxi.apis.phrase.api.format.JavaPropertiesFormat 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: 1.0.6
Show newest version
package com.mytaxi.apis.phrase.api.format;

import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

/**
 * See https://phraseapp.com/docs/guides/formats/java-properties/
 */
public class JavaPropertiesFormat implements Format
{

    public static final String NAME = "properties";
    private final List options;


    private JavaPropertiesFormat(List options)
    {
        this.options = options;
    }


    @Override
    public String getName()
    {
        return NAME;
    }


    @Override
    public List getOptions()
    {
        return options;
    }


    public static Builder newBuilder()
    {
        return new Builder();
    }


    public static class Builder
    {
        private final List options = new ArrayList<>();


        public Builder setEscapeSingleQuotes(boolean escapeSingleQuotes)
        {
            return setOption("escape_single_quotes", "" + escapeSingleQuotes);
        }


        public Builder setOption(String name, String value)
        {
            String fullName = String.format("format_options[%s]", name);
            options.add(new BasicNameValuePair(fullName, value));
            return this;
        }


        public JavaPropertiesFormat build()
        {
            return new JavaPropertiesFormat(options);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy