Translation

The interface of the web player can be fully translated by adding a locale to the locales folder in the player root. The locales included by default will depend on your territory, but the files can be edited if required, and will apply only to that station.

Directory structure

The player uses i18next as an internationalisation framework. The languages files are kept in the locales directory in the same directory as the HTML file. If you use the console generator these locale files will be included in your download. If you are not using the generator you will need to download the latest locale files. You can find them here: locales.zip. The subdirectories are named according to the ISO language code: e.g. de-CH for Swiss German. The language code must match the station language set in Radioplayer Cloud. If you need to host the locale files elsewhere, such as a CDN, then you can pass a localeRootUrl option to the player.

The translations are held within JSON files inside the locale directory. Currently there is one file per language, called translation.json. This contains an object with keys and values. The keys are the "tags" used to identify each string. The actual source text is found in the en locale. Switching to the dev locale will display the actual keys in the interface, which can help if you're unsure which tag applies to which part of the interface.

An example of the translated strings is shown below:

{
    "ARIA_SKIP_TO_LIVE": "Skip to live",
    "BUTTON_ANNOUNCEMENT": "OK",
    "BUTTON_CLOSE": "Close",
    "BUTTON_MENU": "Menu",
    "BUTTON_OFF": "Off",
    "BUTTON_ON": "On",
    "BUTTON_SAVE_SETTINGS": "Save settings",
    "BUTTON_YES_AGREE": "Yes, I agree",
    "COOKIEBANNER_ALWAYS_ON": "Always on"
}

When translating, care should be taken that the strings are not too long, as this may break the layout.

Non-text values

There are a small number of strings that do not represent text, but other localisable values. These are mostly territory-specific URLs, and should be set to the appropriate URL for the station's territory, or for a station's own URL.

Complex keys

There are also a small number of strings that have embedded links, formatting or values. These can be identified by values that include tags such as <1> or {{artistName}}. Please ensure that the values between the brackets are not changed.

For example:

{
    "SEARCH_NO_RESULTS_DESCRIPTION": "We can't find any stations or programmes relating to “{{ searchTerm }}“",
    "SEARCH_NO_RESULTS_HINT": "Please check your spelling - or try searching again, using a <1>station name</1>, a <4>programme name</4>, or a <7>place</7>."
}

..is translated as:

{
    "SEARCH_NO_RESULTS_DESCRIPTION": "Wir können keinen Sender oder Programm mit dem Suchbegriff “{{ searchTerm }}“ finden",
    "SEARCH_NO_RESULTS_HINT": "Bitte prüfen Sie Ihre Eingabe oder suchen Sie erneut nach einem <1>Sendernamen</1>, dem Namen eines <4>Programms</4> oder einem <7>Ort</7>"
}

Setting the language for a station

Normally, the language will be set in Radioplayer Cloud. Depending on your region, this may be hard-coded. The language code should exactly match the name of the locale code. This setting is loaded at console boot time. Alternatively, you can override the language by passing a "lang" to the console in the configuration options. If no language setting is available, the fallback is en, so ensure that this locale is present in the locales directory.

Using locize

Radioplayer uses locize for handling translation files. These translations are for full territories, and do not hold station-specific translations. If you are responsible for a region's translation you should be given access to locize to manage your translations.