Introduction

OpenVeo translations are grouped by dictionaries (JSON files in i18n directory). Actually the server is capable of returning a dictionary by its name and language. Nothing more. The OpenVeo back end is translated on the client side application (AngularJS).

Dictionaries

Dictionaries are all stored in i18n directory. Dictionary file name is composed of the name of the dictionary followed by the language code :

[DICTIONARY_NAME]-[LANGUAGE_CODE].json

With :

  • [DICTIONARY_NAME] the name of the dictionary
  • [LANGUAGE_CODE] the language code

e.g. my-dictionary-en_ca.json (will contain translations of dictionary "my-dictionary" for Canadian english)
e.g. my-dictionary-fr.json (will contain translations of dictionary "my-dictionary" for French)

If the dictionary must be accessible only by users authenticated to the back end, you must add the prefix : admin-.

e.g. admin-my-dictionary-en_ca.json

Get a public dictionary

From client side, you can request a dictionary using /getDictionary/:dictionary/:code

e.g. /getDictionary/my-dictionary/en_ca

Get a back end dictionary

From client side, you can request a back end dictionary (requiring an authenticated user) using /be/getDictionary/:dictionary/:code

e.g. /be/getDictionary/my-dictionary/en_ca

Nb : Your dictionary file will be admin-my-dictionary-en_ca.json

You can use the back end AngularJS API (module ov.i18n) to help you manipulate dictionaries.

Override a translation

If you create, in your plugin, a dictionary with the same as an already existing dictionary, it will be merged. For example, if OpenVeo core defines a dictionary called login-en.json with the following translations :

{
  "LOGIN" : {
    "PAGE_TITLE" : "Openveo - Sign In",
    "LOGIN" : "User",
    "LOGIN_DESCRIPTION" : "Enter user name",
    "PASSWORD" : "Password",
    "PASSWORD_DESCRIPTION" : "Enter password",
    "SUBMIT" : "Submit",
    "ERROR" : "Wrong user and / or password"
  }
}

If you create a dictionary with the same name in your plugin (i18n/login-en.json) with the following translations :

{
  "LOGIN" : {
    "PAGE_TITLE" : "My page title",
    "ANOTHER_TRANSLATION" : "My new translation"
  }
}

Calling /getDictionary/login/en will return :

{
  "LOGIN" : {
    "PAGE_TITLE" : "My page title",
    "LOGIN" : "User",
    "LOGIN_DESCRIPTION" : "Enter user name",
    "PASSWORD" : "Password",
    "PASSWORD_DESCRIPTION" : "Enter password",
    "SUBMIT" : "Submit",
    "ERROR" : "Wrong user and / or password",
    "ANOTHER_TRANSLATION" : "My new translation"
  }
}