From 297f297d181b694446e04f653da694660e9971b4 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Mon, 13 Aug 2018 21:39:16 +1000 Subject: Moved i18n to utils --- src/js/captions.js | 2 +- src/js/controls.js | 2 +- src/js/i18n.js | 34 ---------------------------------- src/js/plugins/ads.js | 2 +- src/js/ui.js | 2 +- src/js/utils/i18n.js | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 38 insertions(+), 38 deletions(-) delete mode 100644 src/js/i18n.js create mode 100644 src/js/utils/i18n.js diff --git a/src/js/captions.js b/src/js/captions.js index f31b5305..ae4642aa 100644 --- a/src/js/captions.js +++ b/src/js/captions.js @@ -4,7 +4,6 @@ // ========================================================================== import controls from './controls'; -import i18n from './i18n'; import support from './support'; import { dedupe } from './utils/arrays'; import browser from './utils/browser'; @@ -18,6 +17,7 @@ import { } from './utils/elements'; import { on, triggerEvent } from './utils/events'; import fetch from './utils/fetch'; +import i18n from './utils/i18n'; import is from './utils/is'; import { getHTML } from './utils/strings'; import { parseUrl } from './utils/urls'; diff --git a/src/js/controls.js b/src/js/controls.js index 6265f2aa..a9957be9 100644 --- a/src/js/controls.js +++ b/src/js/controls.js @@ -5,13 +5,13 @@ import captions from './captions'; import html5 from './html5'; -import i18n from './i18n'; import support from './support'; import { repaint, transitionEndEvent } from './utils/animation'; import { dedupe } from './utils/arrays'; import browser from './utils/browser'; import { createElement, emptyElement, getAttributesFromSelector, getElement, getElements, hasClass, matches, removeElement, setAttributes, setFocus, toggleClass, toggleHidden } from './utils/elements'; import { off, on } from './utils/events'; +import i18n from './utils/i18n'; import is from './utils/is'; import loadSprite from './utils/loadSprite'; import { extend } from './utils/objects'; diff --git a/src/js/i18n.js b/src/js/i18n.js deleted file mode 100644 index 5b0ebbab..00000000 --- a/src/js/i18n.js +++ /dev/null @@ -1,34 +0,0 @@ -// ========================================================================== -// Plyr internationalization -// ========================================================================== - -import is from './utils/is'; -import { getDeep } from './utils/objects'; -import { replaceAll } from './utils/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; diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js index 8b1aac8c..375fdc13 100644 --- a/src/js/plugins/ads.js +++ b/src/js/plugins/ads.js @@ -6,9 +6,9 @@ /* global google */ -import i18n from '../i18n'; import { createElement } from '../utils/elements'; import { triggerEvent } from '../utils/events'; +import i18n from '../utils/i18n'; import is from '../utils/is'; import loadScript from '../utils/loadScript'; import { formatTime } from '../utils/time'; diff --git a/src/js/ui.js b/src/js/ui.js index 34fe7e82..f0c898bf 100644 --- a/src/js/ui.js +++ b/src/js/ui.js @@ -4,11 +4,11 @@ import captions from './captions'; import controls from './controls'; -import i18n from './i18n'; import support from './support'; import browser from './utils/browser'; import { getElement, toggleClass } from './utils/elements'; import { ready, triggerEvent } from './utils/events'; +import i18n from './utils/i18n'; import is from './utils/is'; import loadImage from './utils/loadImage'; diff --git a/src/js/utils/i18n.js b/src/js/utils/i18n.js new file mode 100644 index 00000000..f71e1a42 --- /dev/null +++ b/src/js/utils/i18n.js @@ -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; -- cgit v1.2.3