Crowdin API Java SDK

Uma biblioteca de Java para acessar a API do Crowdin. O Crowdin fornece API RESTful com XML ou JSON via HTTP ao usar métodos GET e POST. Com a ajuda deste SDK, podes facilitar o trabalho com todos os métodos de API do Crowdin no teu projeto de Java, tais como, adicionar e atualizar ficheiros, transferir traduções ou integração de localização com o teu processo de desenvolvimento.

Pré-requisitos

  • Java JDK 7 ou mais recente
  • Gradle

Início Rápido

  1. Clone the repo
    git clone https://github.com/crowdin/crowdin-java-sdk.git
  2. Atualiza as dependências do projeto ao usar o gradle
  3. Build the project to get jar file:
    gradle buildJavaSdkJar
  4. Adiciona este ficheiro no teu projeto

Fazer a Primeira Chamada

Uma vez concluída a instalação, poderás fazer a primeira chamada:

  1. Create variables for API key, project identifier, account key, base url and save their values. Get more information how to get your project API key.
    public static final String  BASE_URL = "https://api.crowdin.com/api/";
    public static final String  PROJECT_IDENTIFIER = "your-project-identifier";
    public static final String  PROJECT_KEY = "your-project-key";
    public static final String  ACCOUNT_KEY = "your-account-key";
  2. Create a Credentials object with proper configurations
    Credentials credentials = new Credentials(BASE_URL, PROJECT_IDENTIFIER, PROJECT_KEY, ACCOUNT_KEY);
  3. Create a CrowdinApiParametersBuilder object and set parameters necessary for chosen method (See the list of Crowdin API methods and their parameters)
    CrowdinApiParametersBuilder parameters = new CrowdinApiParametersBuilder();
    parameters.json();
  4. Create CrowdinApiClient object and choose the necessary API method
    CrowdinApiClient crwdn = new Crwdn();
    crwdn.getInfo(credentials, parameters);
    For output the response's entity:
    System.out.println(crwdn.getInfo(credentials, parameters).getEntity(String.class));
  5. Run the code using IDE or command line. It should return something like this:
    {
      "languages":[...],
      "files":[...],
      "details":{
        "source_language":{
          "name":"Ukrainian",
          "code":"uk"
        },
        "name":"crowdin2",
        "identifier":"crowdin2",
        "created":"2016-11-09 07:20:33",
        "description":"",
        "join_policy":"private",
        "last_build":"2016-12-07 10:00:27",
        "last_activity":"2016-12-16 08:53:32",
        "participants_count":"1",
        "total_strings_count":"24",
        "total_words_count":"24",
        "duplicate_strings_count":22,
        "duplicate_words_count":22,
        "invite_url":{
          "translator":"https:\/\/crowdin.com\/project\/crowdin2\/invite?d=b555o4i6o6f5h5b3m4c333453",
          "proofreader":"https:\/\/crowdin.com\/project\/crowdin2\/invite?d=755565j6b6f5h5b3m4c3455323"
        }
      }
    }

Need help working with Crowdin API Java SDK or have any questions? Contact Support Team.

Este artigo foi útil?