aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/i18n.js
blob: 58c3e7cf2b2e3d17c248b92bb6231165aeccafde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// ==========================================================================
// Plyr internationalization
// ==========================================================================

import utils from './utils';

const i18n = {
    get(key = '', config = {}) {
        if (utils.is.empty(key) || utils.is.empty(config) || !Object.keys(config.i18n).includes(key)) {
            return '';
        }

        let string = config.i18n[key];

        const replace = {
            '{seektime}': config.seekTime,
            '{title}': config.title,
        };

        Object.entries(replace).forEach(([
            key,
            value,
        ]) => {
            string = utils.replaceAll(string, key, value);
        });

        return string;
    },
};

export default i18n;