summaryrefslogtreecommitdiff
path: root/app/javascript/i18n.js
blob: 318edfe1f4df66f9e4cd6e0c19e30a87a7efaf39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import translations from 'i18n.json'; /* eslint-disable-line import/no-unresolved */

export default class {
  translate(key) {
    return this.constructor.translate(key);
  }

  static translate(key) {
    return translations[this.locale][key];
  }

  static get locale() {
    const html = document.querySelector('html');
    return html.getAttribute('lang') || 'en';
  }
}