39 lines
965 B
JavaScript
39 lines
965 B
JavaScript
window.i18n = {
|
|
locale: null,
|
|
|
|
translate: function(key, options) {
|
|
key = String(key)
|
|
if (!options || typeof(options) !== 'object') {
|
|
options = {}
|
|
}
|
|
|
|
var no_translation = '[no translation for key: ' + key + ']'
|
|
|
|
var locale = String(window.i18n.locale)
|
|
var translations = window.i18n.translations[locale]
|
|
if (typeof(translations) === 'undefined') return no_translation
|
|
|
|
var translation = String(translations[key])
|
|
if (typeof(translation) === 'undefined') return no_translation
|
|
|
|
// TODO: apply options
|
|
|
|
return translation
|
|
},
|
|
|
|
translations: {
|
|
en: {
|
|
Meanings: 'Meanings',
|
|
Commentary: 'Commentary',
|
|
Inflections: 'Inflections',
|
|
'Usage examples': 'Usage examples',
|
|
},
|
|
ru: {
|
|
Meanings: 'Значения',
|
|
Commentary: 'Комментарий',
|
|
Inflections: 'Формы слова',
|
|
'Usage examples': 'Примеры употребления',
|
|
},
|
|
},
|
|
}
|