aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/i18n.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2018-03-27 10:36:08 +1100
committerSam Potts <sam@potts.es>2018-03-27 10:36:08 +1100
commit9c1bc6ab08e4fe68565a12f76b58684f4c6a8354 (patch)
treef36ad0d9fbd5591038bba52822bad9c21121636d /src/js/i18n.js
parent3d2ba8c00942075ae387a09ab5aade1f680142c7 (diff)
downloadplyr-9c1bc6ab08e4fe68565a12f76b58684f4c6a8354.tar.lz
plyr-9c1bc6ab08e4fe68565a12f76b58684f4c6a8354.tar.xz
plyr-9c1bc6ab08e4fe68565a12f76b58684f4c6a8354.zip
Fixes for fast forward and issues with event.preventDefault()
Diffstat (limited to 'src/js/i18n.js')
-rw-r--r--src/js/i18n.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/js/i18n.js b/src/js/i18n.js
new file mode 100644
index 00000000..58c3e7cf
--- /dev/null
+++ b/src/js/i18n.js
@@ -0,0 +1,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;