Custom Translations

Translations allow you to customise messages on your webstore so that you can make it relevant to your customers. If most of your customers don't speak English then it may be difficult for them to navigate around your webstore therefore we'd recommend creating custom translations to make it easier for them. Alternatively, you may want to alter some of the messages on your webstore - this can also be done using translations. Please note: not all areas of the webstore are translated, for a fully customised translation, we would recommend you use a custom template for full control over your store languages.

How Translations Work

Translations are read from what's known as a translation file which contains a JSON object. Within the JSON object is a translations object which contains key value pairs where the key is the English message/string that you'd like to translate and the value is the translated string. The JSON object also contains a meta object which includes a locale property, a pluralrule property, and a name property. An example translation file is shown below.

{
  "meta": {
    "locale": "fr_FR",
    "pluralrule": "plural=(n > 1)",
    "name": "French"
  },
  "translations": {
    "Welcome": "Salut"
  }
}

Meta Objects

  1. locale - The base locale that you want to override. In this example it is set to fr_FR as we want our webstore to be in French as well as using our custom translations further down.

  2. pluralrule - The plural rule describes how plurals should be handled. See the plurals section below for further information.

  3. name - The name of the translation file, this is only displayed in the control panel and is not public facing.

How Plurals Are Handled

The pluralrule in the meta object determines how we should handle plurals. In most cases you will want to copy the pluralrule from a standard translation file. For example, if you're using the fr_FR locale then you should download the standard fr_FR translation file from the control panel and copy that plural rule. ​

For a full list of plural rules please click here.

Creating A Custom Translation File

We recommend copying the example above into a new file for your custom translation file. This will act as a template allowing you to tweak and add necessary values. You'll most likely want to change the locale as it's currently set to French, if you'd like English then change it to en_GB or en_US accordingly.

Once you've set the base locale you can modify the plural rule and change the translation file's name. After this, you can begin to add your custom translations by adding to the translations object. In the example below we have created a few different translations.

{
  "meta": {
    "locale": "en_GB",
    "pluralrule": "plural=(n > 1)",
    "name": "English Custom"
  },
  "translations": {
    "Welcome": "Hey",
    "Thank you for your purchase": "Thanks for supporting us",
    "Gift this package": "Gift this to a friend" 
  }
}

For a list of translatable strings, you'll want to download a standard translations file, we recommend downloading the en_US one (click here).

Placeholders

In some translatable strings there will be placeholders, these are denoted by a colon before the word, for example :username. The example below shows the :username placeholder being used in a translation.

":username has been banned from this webstore": ":username is banned"

Last updated