diff --git a/README.md b/README.md index d40f266..72b739d 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,10 @@ To activate playlist functionality, set one of the following attributes: * `list-local`: A string containing a playlist definition. An arbitrary number of players can be placed on the same page. + + +## Internationalization + +The player defaults to English as its UI language. If the containing HTML +document has a `lang` attribute, it is used to set the UI language in the +player. Currently only supports English (`en`) and Swedish (`sv`). diff --git a/multiplayer.js b/multiplayer.js index 8405e0d..8ff5abd 100644 --- a/multiplayer.js +++ b/multiplayer.js @@ -1072,15 +1072,19 @@ input[type="range"]::-ms-track { /* * Get the appropriate translation of key for the language * stored in this._lang. - * - * Since the keys are in english, the key is simply returned if - * this._lang is 'en'. */ i18n(key) { + // Since the keys are in english, the key is simply returned if + // this._lang is 'en'. if(this._lang == 'en') { return key; } + // If we don't have a translation for the language, use english + if(!(this._lang in this._i18n)) { + return key; + } + return this._i18n[this._lang][key]; }