Login Account

ARB Example Translated with doloc

Doloc offers a streamlined approach to localizing your Flutter application’s content. By utilizing its API, you can efficiently translate your ARB files into multiple languages. Here’s an example to illustrate the process:

Original ARB Files BEFORE localization

app_en.arb:

{
  "@@locale": "en",
  "greeting": "Ahoy there!",
  "description": "Innovation at your fingertips, shaping tomorrow today.",
  "footer": "Don't miss out, be a part of the future.",
  "@footer": {
    "description": "Text shown in the footer section"
  },
  "contact": "Let's get the ball rolling, we're just a message away!",
  "@contact": {
    "description": "Call to action for contacting support",
    "context": "User sign in process"
  },
  "welcomeMessage": "Hello, {username}!",
  "@welcomeMessage": {
    "placeholders": {
      "username": {
        "type": "String",
        "example": "John"
      }
    }
  }
}

app_de.arb:

{
  "@@locale": "de",
  "greeting": "Ahoi!",
  "description": "Innovation zum Greifen nah bei dir, heute schon das morgen gestalten."
}

Running the doloc curl command

To translate this file into German using doloc’s API, execute the following curl command (be sure to get your $API_TOKEN in your doloc account):

curl "https://api.doloc.io" -H "Authorization: Bearer $API_TOKEN" -F source="@app_en.arb" -F target="@app_de.arb" -o app_de.arb

Note: For further customization, refer to the options you can pass as query parameters in the URL! This allows you to tailor the experience to your needs.

ARB Files AFTER localization

After running the command, the translated ARB file will appear as follows:

app_de.arb

{
  "@@locale": "de",
  "greeting": "Ahoi!",
  "description": "Innovation zum Greifen nah bei dir, heute schon das morgen gestalten.",
  "footer": "Verpasse es nicht, sei ein Teil der Zukunft.",
  "@footer": {
    "description": "Text shown in the footer section"
  },
  "contact": "Lass uns ins Rollen kommen, wir sind nur eine Nachricht entfernt!",
  "@contact": {
    "description": "Call to action for contacting support",
    "context": "User sign in process"
  },
  "welcomeMessage": "Hallo, {username}!",
  "@welcomeMessage": {
    "placeholders": {
      "username": {
        "type": "String",
        "example": "John"
      }
    }
  }
}
All new texts are also translated according to existing translations. Notice how metadata and placeholders are preserved in the translated file.

This process demonstrates how doloc can seamlessly integrate into your Flutter development workflow, providing instant translations and accelerating your application’s localization.

Getting started with ARB localization

Ready to get started with doloc? It is only three steps:

  1. Register now!
  2. Create your personal $API_TOKEN
  3. Add the curl command (see above) to your dev workflow.

Make sure to check out our complete ARB Format Documentation.