Moved i18n to utils

This commit is contained in:
Sam Potts
2018-08-13 21:39:16 +10:00
parent 059205c378
commit 297f297d18
5 changed files with 7 additions and 7 deletions

34
src/js/utils/i18n.js Normal file
View File

@ -0,0 +1,34 @@
// ==========================================================================
// Plyr internationalization
// ==========================================================================
import is from './is';
import { getDeep } from './objects';
import { replaceAll } from './strings';
const i18n = {
get(key = '', config = {}) {
if (is.empty(key) || is.empty(config)) {
return '';
}
let string = getDeep(config.i18n, key);
if (is.empty(string)) {
return '';
}
const replace = {
'{seektime}': config.seekTime,
'{title}': config.title,
};
Object.entries(replace).forEach(([key, value]) => {
string = replaceAll(string, key, value);
});
return string;
},
};
export default i18n;