aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/i18n.js
blob: 62e5bdb04e9ceb31893b109596b75f7622c25d21 (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
32
33
34
35
// ==========================================================================
// Plyr internationalization
// ==========================================================================

import utils from './utils';

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

        let string = utils.getDeep(config.i18n, key);

        if (utils.is.empty(string)) {
            return '';
        }

        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;