Fetching translations

Last updated: September 11, 2024Author: 

Translation Hosting is a content-delivery network (CDN) for your translations. It's enables you to safely deliver translations anywhere in the world with superfast access speed. It's available in all pricing plans including the Community plan.

Parameters

To fetch the basic translations, you need to provide only your project token and environment key in the URL. Other parameters are optional and can be used to get translations for a specific language, namespace or customerId.

  • projectToken - your project token,
  • languageKey - language key from the 'Languages' tab, e.g.: en, pl, de,
  • environment - environment key, e.g.: _latest or _production,
  • namespace - namespace, e.g.: common, home, auth,
  • customerId - customerId used for customer-specific translations, e.g.: ikea.

Get all translations

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/_index

Example response

{
  "de": {
    "SALE": "Verkauf",
    "ADDRESS": "Adresse"
  },
  "fr": {
    "SALE": "soldes",
    "ADDRESS": "adresse"
  }
}

Get translations by language key

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/{languageKey}

Example response

{
  "SALE": "Verkauf",
  "ADDRESS": "Adresse"
}

Get languages

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/_languages

Example response

[
   {
      "key": "de",
      "name": "Deutsch",
      "isDefault": false,
      "icon": "de"
   },
   {
      "key": "en",
      "name": "English",
      "isDefault": false,
      "icon": "gb"
   },
   {
      "key": "es",
      "name": "Español",
      "isDefault": false,
      "icon": "es"
   }
]

See blog post about hosted country flags and learn how to use icon values to show flags in your app.

Get translations by language key and namespace

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/{languageKey}/{namespace}

Example response

{
  "SALE": "Verkauf",
  "ADDRESS": "Adresse"
}

Get translations by language key, namespace and customerId

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/{languageKey}_{customerId}/{namespace}

Example response

{
  "SALE": "Verkauf",
  "ADDRESS": "Adresse"
}

Get customers

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/_customers

Example response

[
   {
      "key": "ikea",
      "name": "IKEA"
   },
   {
      "key": "adidas",
      "name": "Adidas"
   }
]

Get customer-specific translations

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/{languageKey}_{customerId}

Example response

{
  "SALE": "Verkauf",
  "ADDRESS": "Adresse"
}

Error responses

At the moment, the only error response you can get is 404 when requested translation is not found, and the response body will look like this:

{
  "status": 404,
  "msg": "Hosting resource not found"
}
Was this helpful?