stremiok 2.3.3 → 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +6 -5
  3. package/config.xml +1 -1
  4. package/css/style.css +5 -0
  5. package/index.html +42 -39
  6. package/js/app.js +7 -3
  7. package/js/downloads.js +16 -16
  8. package/js/epg.js +2 -3
  9. package/js/hubpreview.js +1 -1
  10. package/js/i18n.js +108 -0
  11. package/js/iptv.js +13 -13
  12. package/js/jellyfin.js +62 -29
  13. package/js/lang/ar.js +1941 -0
  14. package/js/lang/de.js +1941 -0
  15. package/js/lang/es.js +1941 -0
  16. package/js/lang/fi.js +1941 -0
  17. package/js/lang/fr.js +1941 -0
  18. package/js/lang/he.js +1941 -0
  19. package/js/lang/hi.js +1941 -0
  20. package/js/lang/it.js +1941 -0
  21. package/js/lang/ja.js +1941 -0
  22. package/js/lang/ko.js +1941 -0
  23. package/js/lang/languages.js +21 -0
  24. package/js/lang/pl.js +1941 -0
  25. package/js/lang/pt-BR.js +1941 -0
  26. package/js/lang/ru.js +1941 -0
  27. package/js/lang/tr.js +1941 -0
  28. package/js/lang/zh-CN.js +1941 -0
  29. package/js/local.js +9 -9
  30. package/js/netfolders.js +13 -13
  31. package/js/player-audio.js +17 -17
  32. package/js/player-controls.js +100 -100
  33. package/js/player-core.js +60 -57
  34. package/js/player-lang.js +22 -22
  35. package/js/player-quality.js +15 -15
  36. package/js/player-store.js +25 -18
  37. package/js/player-subs.js +69 -69
  38. package/js/plex.js +69 -21
  39. package/js/stremio-account.js +17 -12
  40. package/js/stremio-sync.js +641 -0
  41. package/js/stremio.js +79 -76
  42. package/js/stvod.js +4 -4
  43. package/js/trakt.js +23 -23
  44. package/js/tvapps.js +4 -4
  45. package/js/util.js +39 -27
  46. package/js/view-core.js +109 -92
  47. package/js/view-detail.js +135 -126
  48. package/js/view-discover.js +27 -27
  49. package/js/view-guide.js +13 -13
  50. package/js/view-home.js +148 -120
  51. package/js/view-search.js +25 -25
  52. package/js/view-settings.js +735 -643
  53. package/js/xtvod.js +2 -2
  54. package/js/youtube.js +17 -17
  55. package/js/ytplay.js +11 -6
  56. package/package.json +1 -1
  57. package/tizenbrew.html +1 -1
package/js/trakt.js CHANGED
@@ -111,7 +111,7 @@ var Trakt = (function () {
111
111
  function lostSignIn() { // (401 / 403, or the token can't be renewed: nothing more is sent until you connect again)
112
112
  if (!isConnected()) { return; }
113
113
  if (!needsReconnect()) { setSyncState({ reconnect: true }); }
114
- if (!_toldReconnect) { _toldReconnect = true; U.toast('Trakt needs reconnecting: Settings › Content › Integrations', 6000); U.log('trakt', 'Trakt sign-in no longer works: reconnect in Settings'); }
114
+ if (!_toldReconnect) { _toldReconnect = true; U.toast(U.t('Trakt needs reconnecting: Settings › Content › Integrations'), 6000); U.log('trakt', 'Trakt sign-in no longer works: reconnect in Settings'); }
115
115
  }
116
116
 
117
117
  // Renew the access token when it's near expiry. A renewal Trakt refuses means the sign-in
@@ -156,19 +156,19 @@ var Trakt = (function () {
156
156
  cb = cb || {};
157
157
  var canceled = false, timer = null, g0 = _gen;
158
158
  var c = getCreds();
159
- if (!c.id) { if (cb.onError) { cb.onError('Enter your Trakt Client ID first.'); } return function () {}; }
159
+ if (!c.id) { if (cb.onError) { cb.onError(U.t('Enter your Trakt Client ID first.')); } return function () {}; }
160
160
 
161
161
  req('POST', '/oauth/device/code', { client_id: c.id }, false).then(function (r) {
162
162
  if (canceled) { return; }
163
163
  var d = r.data || {};
164
- if (!d.device_code) { if (cb.onError) { cb.onError('Trakt did not return a device code.'); } return; }
164
+ if (!d.device_code) { if (cb.onError) { cb.onError(U.t('Trakt did not return a device code.')); } return; }
165
165
  if (cb.onCode) { cb.onCode(d.user_code, d.verification_url || 'https://trakt.tv/activate'); }
166
166
  var interval = (d.interval || 5) * 1000;
167
167
  var deadline = Date.now() + ((d.expires_in || 600) * 1000);
168
168
 
169
169
  function pollOnce() {
170
170
  if (canceled) { return; }
171
- if (Date.now() > deadline) { if (cb.onError) { cb.onError('Code expired — try again.'); } return; }
171
+ if (Date.now() > deadline) { if (cb.onError) { cb.onError(U.t('Code expired — try again.')); } return; }
172
172
  req('POST', '/oauth/device/token', client({ code: d.device_code }), false)
173
173
  .then(function (tr) {
174
174
  if (canceled || !current(g0)) { return; }
@@ -188,15 +188,15 @@ var Trakt = (function () {
188
188
  var s = err && err.status;
189
189
  if (s === 400) { timer = setTimeout(pollOnce, interval); return; } // authorization pending
190
190
  if (s === 429) { timer = setTimeout(pollOnce, interval + 1000); return; } // slow down
191
- if (s === 418) { if (cb.onError) { cb.onError('Sign-in was denied.'); } return; }
192
- if (s === 410) { if (cb.onError) { cb.onError('Code expired — try again.'); } return; }
193
- if (s === 409) { if (cb.onError) { cb.onError('Code already used.'); } return; }
191
+ if (s === 418) { if (cb.onError) { cb.onError(U.t('Sign-in was denied.')); } return; }
192
+ if (s === 410) { if (cb.onError) { cb.onError(U.t('Code expired — try again.')); } return; }
193
+ if (s === 409) { if (cb.onError) { cb.onError(U.t('Code already used.')); } return; }
194
194
  if (cb.onPending) { cb.onPending(); }
195
195
  timer = setTimeout(pollOnce, interval);
196
196
  });
197
197
  }
198
198
  timer = setTimeout(pollOnce, interval);
199
- }, function () { if (cb.onError) { cb.onError('Could not reach Trakt (or CORS blocked on desktop).'); } });
199
+ }, function () { if (cb.onError) { cb.onError(U.t('Could not reach Trakt (or CORS blocked on desktop).')); } });
200
200
 
201
201
  return function cancel() { canceled = true; if (timer) { clearTimeout(timer); } };
202
202
  }
@@ -507,16 +507,16 @@ var Trakt = (function () {
507
507
  }
508
508
  return Promise.resolve(list.map(function (x) {
509
509
  return { id: x.imdb, type: x.type, name: x.title || x.imdb, poster: poster(x.imdb), posterShape: 'poster',
510
- releaseInfo: x.year ? '' + x.year : '', description: x.next ? 'Up next: ' + x.next : '' };
510
+ releaseInfo: x.year ? '' + x.year : '', description: x.next ? U.t('Up next: {ep}', { ep: x.next }) : '' };
511
511
  }));
512
512
  }
513
513
  function synthAddon() {
514
514
  return {
515
515
  __local: true, __impl: { catalog: synthCatalog }, url: 'local:trakt', base: 'local:trakt',
516
516
  manifest: { id: 'org.stremiok.trakt', name: 'Trakt', version: '1.0.0', types: ['movie', 'series'], resources: ['catalog'],
517
- catalogs: [{ type: 'series', id: 'trakt_upnext', name: 'Up next', extra: [{ name: 'skip' }] },
518
- { type: 'movie', id: 'trakt_watchlist_movies', name: 'Watchlist', extra: [{ name: 'skip' }] },
519
- { type: 'series', id: 'trakt_watchlist_shows', name: 'Watchlist', extra: [{ name: 'skip' }] }] }
517
+ catalogs: [{ type: 'series', id: 'trakt_upnext', name: U.t('Up next'), extra: [{ name: 'skip' }] },
518
+ { type: 'movie', id: 'trakt_watchlist_movies', name: U.t('Watchlist'), extra: [{ name: 'skip' }] },
519
+ { type: 'series', id: 'trakt_watchlist_shows', name: U.t('Watchlist'), extra: [{ name: 'skip' }] }] }
520
520
  };
521
521
  }
522
522
 
@@ -535,7 +535,7 @@ var Trakt = (function () {
535
535
  (U.store.get(UPNEXT_KEY, []) || []).forEach(function (u) {
536
536
  if (!u || !u.imdb || paused[u.imdb]) { return; }
537
537
  var e = { id: u.imdb + ':' + u.season + ':' + u.episode, type: 'series', parent: u.imdb,
538
- name: (u.title || 'Show') + ' S' + u.season + 'E' + u.episode, poster: poster(u.imdb),
538
+ name: (u.title || U.t('Show')) + ' S' + u.season + 'E' + u.episode, poster: poster(u.imdb),
539
539
  position: 0, duration: 0, updated: u.at || 0, _trakt: true, upNext: u.epTitle || '' };
540
540
  if (kept(e)) { list.push(e); }
541
541
  });
@@ -563,13 +563,13 @@ var Trakt = (function () {
563
563
  if (it.type === 'movie' && it.movie) {
564
564
  var mi = imdbOf(it.movie.ids);
565
565
  if (!mi) { return; }
566
- out.push({ id: mi, type: 'movie', name: str(it.movie.title, 200) || 'Movie', poster: poster(mi),
566
+ out.push({ id: mi, type: 'movie', name: str(it.movie.title, 200) || U.t('Movie'), poster: poster(mi),
567
567
  position: prog, duration: 100, updated: updated, _trakt: true });
568
568
  } else if (it.type === 'episode' && it.show && it.episode) {
569
569
  var si = imdbOf(it.show.ids), sn = num(it.episode.season, 1000), en = num(it.episode.number, 10000);
570
570
  if (!si || sn === null || en === null) { return; }
571
571
  out.push({ id: si + ':' + sn + ':' + en, type: 'series',
572
- name: (str(it.show.title, 200) || 'Show') + ' S' + sn + 'E' + en,
572
+ name: (str(it.show.title, 200) || U.t('Show')) + ' S' + sn + 'E' + en,
573
573
  poster: poster(si), position: prog, duration: 100, updated: updated, _trakt: true });
574
574
  }
575
575
  });
@@ -644,12 +644,12 @@ var Trakt = (function () {
644
644
  function saveOutbox(b) {
645
645
  if (b.length > OUTBOX_MAX) {
646
646
  U.log('trakt', (b.length - OUTBOX_MAX) + ' older change(s) dropped, not sent to Trakt: more than ' + OUTBOX_MAX + ' waiting');
647
- if (!_toldFull) { _toldFull = true; U.toast('Trakt: too many changes waiting, the oldest were dropped', 6000); }
647
+ if (!_toldFull) { _toldFull = true; U.toast(U.t('Trakt: too many changes waiting, the oldest were dropped'), 6000); }
648
648
  b = b.slice(-OUTBOX_MAX);
649
649
  }
650
650
  if (U.store.set(OUTBOX_KEY, b) === false) {
651
651
  U.log('trakt', 'The changes waiting for Trakt couldn’t be saved on the TV (its storage is full): they’re lost if StremioK closes');
652
- if (!_toldUnsaved) { _toldUnsaved = true; U.toast('Trakt: the changes waiting couldn’t be saved on the TV (storage full)', 6000); }
652
+ if (!_toldUnsaved) { _toldUnsaved = true; U.toast(U.t('Trakt: the changes waiting couldn’t be saved on the TV (storage full)'), 6000); }
653
653
  }
654
654
  }
655
655
  function newId() { return Date.now().toString(36) + Math.floor(Math.random() * 1e6).toString(36); }
@@ -695,15 +695,15 @@ var Trakt = (function () {
695
695
  var soonest = Math.min.apply(null, waiting.map(function (x) { return x.next || 0; }));
696
696
  flushSoon(Math.max(1000, soonest - Date.now()));
697
697
  }
698
- function what(x) { return x.kind === 'add' ? 'watched' : x.kind === 'remove' ? 'not watched' : x.kind === 'stop' ? 'watched (finished)' : x.kind === 'rate' ? 'rated ' + x.rating : x.kind === 'unrate' ? 'rating removed' : 'where you stopped'; }
698
+ function what(x) { return x.kind === 'add' ? U.t('watched') : x.kind === 'remove' ? U.t('not watched') : x.kind === 'stop' ? U.t('watched (finished)') : x.kind === 'rate' ? U.t('rated {n}', { n: x.rating }) : x.kind === 'unrate' ? U.t('rating removed') : U.t('where you stopped'); }
699
699
  // The change's title: its name when it has one, else its IMDb id (and episode), or how many.
700
700
  function titleOf(x) {
701
701
  var keys = x.keys || [];
702
702
  if (x.name) { return x.name; }
703
- if (keys.length > 1) { return keys.length + ' titles / episodes'; }
703
+ if (keys.length > 1) { return U.t('{n} titles / episodes', { n: keys.length }); }
704
704
  var m = ('' + (keys[0] || '')).match(/^(?:movie|series):(tt\d+)(?::(\d+):(\d+))?$/);
705
705
  var s = ('' + (keys[0] || '')).match(/^season:(tt\d+):(\d+)$/);
706
- if (s) { return s[1] + ' Season ' + s[2]; }
706
+ if (s) { return U.t('{show} Season {n}', { show: s[1], n: s[2] }); }
707
707
  return m ? m[1] + (m[2] ? ' S' + m[2] + 'E' + m[3] : '') : '';
708
708
  }
709
709
  function describe(x) { var t = titleOf(x); return what(x) + (t ? ', ' + t : ''); }
@@ -742,8 +742,8 @@ var Trakt = (function () {
742
742
  // that isn't is retried, not taken as done).
743
743
  function ackProblem(r) {
744
744
  var d = r && r.data;
745
- if (r && r.bad) { return 'an answer that isn’t Trakt’s JSON'; }
746
- if (!d || typeof d !== 'object' || Array.isArray(d)) { return 'an unexpected answer'; }
745
+ if (r && r.bad) { return U.t('an answer that isn’t Trakt’s JSON'); }
746
+ if (!d || typeof d !== 'object' || Array.isArray(d)) { return U.t('an unexpected answer'); }
747
747
  return '';
748
748
  }
749
749
  function update(due, fn) {
@@ -791,7 +791,7 @@ var Trakt = (function () {
791
791
  var refused = st >= 400 && st < 500 && st !== 408 && st !== 429;
792
792
  if (refused || x.tries >= TRIES_MAX) {
793
793
  var said = err && err.data && typeof err.data.message === 'string' ? err.data.message.replace(/\s+/g, ' ').trim().slice(0, 200) : '';
794
- x.failed = true; x.err = st ? 'HTTP ' + st + (said ? ': ' + said : '') : (err && err.unexpected) || (err && err.tooBig ? 'answer too large' : 'no answer');
794
+ x.failed = true; x.err = st ? 'HTTP ' + st + (said ? ': ' + said : '') : (err && err.unexpected) || (err && err.tooBig ? U.t('answer too large') : U.t('no answer'));
795
795
  U.log('trakt', 'Not sent to Trakt: ' + describe(x) + ' (' + x.err + ')');
796
796
  } else {
797
797
  x.next = Date.now() + Math.max(((err && err.retryAfter) || 0) * 1000, Math.min(30000 * Math.pow(2, x.tries - 1), 3600000));
package/js/tvapps.js CHANGED
@@ -12,7 +12,7 @@ var TVApps = (function () {
12
12
 
13
13
  function api() { return (window.tizen && tizen.application) || null; }
14
14
  function available() { var a = api(); return !!(a && a.getAppsInfo && a.launch); }
15
- function errText(e) { return '' + ((e && (e.name || e.message)) || 'unknown error'); }
15
+ function errText(e) { return '' + ((e && (e.name || e.message)) || U.t('unknown error')); }
16
16
  function byName(x, y) { var p = x.name.toLowerCase(), q = y.name.toLowerCase(); return p < q ? -1 : p > q ? 1 : 0; }
17
17
 
18
18
  // The installed apps, by name: [{ id, name, version, show }] (show false: a hidden
@@ -27,7 +27,7 @@ var TVApps = (function () {
27
27
  reject(new Error(m));
28
28
  }
29
29
  var a = api();
30
- if (!a || !a.getAppsInfo) { reject(new Error('Not available here')); return; }
30
+ if (!a || !a.getAppsInfo) { reject(new Error(U.t('Not available here'))); return; }
31
31
  try {
32
32
  a.getAppsInfo(function (apps) {
33
33
  var list = [];
@@ -52,7 +52,7 @@ var TVApps = (function () {
52
52
  reject(new Error(m));
53
53
  }
54
54
  var a = api();
55
- if (!a || !a.launch) { fail(new Error('Not available here')); return; }
55
+ if (!a || !a.launch) { fail(new Error(U.t('Not available here'))); return; }
56
56
  try { a.launch(app.id, function () { resolve(); }, fail); } catch (e) { fail(e); }
57
57
  });
58
58
  }
@@ -65,7 +65,7 @@ var TVApps = (function () {
65
65
  function sendControl(appId, spec) {
66
66
  return new Promise(function (resolve, reject) {
67
67
  var a = api();
68
- if (!a || !a.launchAppControl || !window.tizen.ApplicationControl) { reject(new Error('Not available here')); return; }
68
+ if (!a || !a.launchAppControl || !window.tizen.ApplicationControl) { reject(new Error(U.t('Not available here'))); return; }
69
69
  try {
70
70
  var data = (spec.data || []).map(function (d) { return new tizen.ApplicationControlData(d[0], ['' + d[1]]); });
71
71
  var ctl = new tizen.ApplicationControl(OP[spec.operation] || spec.operation, spec.uri || null, null, null, data);
package/js/util.js CHANGED
@@ -167,30 +167,30 @@ var U = (function () {
167
167
  function urlProblem(input) { return parseUrlWhy(input).why; }
168
168
  function parseUrlWhy(input) {
169
169
  var u = ('' + (input || '')).trim();
170
- if (!u || u === 'https://' || u === 'http://') { return { why: 'Enter a URL' }; }
171
- if (/\s/.test(u)) { return { why: 'A URL can’t contain spaces' }; }
170
+ if (!u || u === 'https://' || u === 'http://') { return { why: t('Enter a URL') }; }
171
+ if (/\s/.test(u)) { return { why: t('A URL can’t contain spaces') }; }
172
172
  if (/^stremio:\/\//i.test(u)) { u = 'https://' + u.slice(10); }
173
173
  else if (!/^[a-z][a-z0-9+.-]*:/i.test(u)) { u = 'https://' + u.replace(/^\/\//, ''); }
174
174
  var m = u.match(/^([a-z][a-z0-9+.-]*):\/\/([^\/?#]*)([^?#]*)(\?[^#]*)?(#.*)?$/i);
175
- if (!m) { return { why: 'That isn’t a URL' }; }
175
+ if (!m) { return { why: t('That isn’t a URL') }; }
176
176
  var scheme = m[1].toLowerCase();
177
- if (scheme !== 'http' && scheme !== 'https') { return { why: 'Only http:// and https:// URLs are supported' }; }
177
+ if (scheme !== 'http' && scheme !== 'https') { return { why: t('Only http:// and https:// URLs are supported') }; }
178
178
  if (m[2].indexOf('@') !== -1) { return { why: 'Remove the user:password@ part (put credentials where your provider says, e.g. ?username=…&password=…)' }; }
179
179
  var hp = m[2].match(/^(\[[0-9a-f:.]+\]|[^\[\]:]+)(?::(\d{1,5}))?$/i);
180
- if (!hp) { return { why: 'That address has no valid host' }; }
180
+ if (!hp) { return { why: t('That address has no valid host') }; }
181
181
  var host = canonicalHost(hp[1]);
182
- if (host === null) { return { why: 'That address has no valid host' }; }
182
+ if (host === null) { return { why: t('That address has no valid host') }; }
183
183
  if (host.charAt(0) === '[') {
184
- if (!v6Words(host.slice(1, -1))) { return { why: 'That address has no valid host' }; }
184
+ if (!v6Words(host.slice(1, -1))) { return { why: t('That address has no valid host') }; }
185
185
  } else {
186
186
  if (/[^.]\.$/.test(host)) { host = host.slice(0, -1); } // "localhost." is localhost
187
- if (!/^[a-z0-9\u00a1-\uffff._-]+$/.test(host) || /^[.-]|[.-]$|\.\./.test(host)) { return { why: 'That address has no valid host' }; }
187
+ if (!/^[a-z0-9\u00a1-\uffff._-]+$/.test(host) || /^[.-]|[.-]$|\.\./.test(host)) { return { why: t('That address has no valid host') }; }
188
188
  // an IP address only in its usual form: 127.1, 2130706433, 0x7f.0.0.1, 0177.0.0.1
189
189
  // all mean 127.0.0.1 to the browser, and would slip past the checks below
190
- if (numericHost(host) && !quad(host)) { return { why: 'Write the IP address the usual way (four numbers 0–255, like 203.0.113.5)' }; }
190
+ if (numericHost(host) && !quad(host)) { return { why: t('Write the IP address the usual way (four numbers 0–255, like 203.0.113.5)') }; }
191
191
  }
192
192
  var port = hp[2] ? parseInt(hp[2], 10) : null;
193
- if (port !== null && (port < 1 || port > 65535)) { return { why: 'That port isn’t valid' }; }
193
+ if (port !== null && (port < 1 || port > 65535)) { return { why: t('That port isn’t valid') }; }
194
194
  var path = m[3] || '';
195
195
  return { url: { href: scheme + '://' + host + (hp[2] ? ':' + hp[2] : '') + path + (m[4] || '') + (m[5] || ''),
196
196
  scheme: scheme, host: host, port: port, path: path || '/', query: m[4] ? m[4].slice(1) : '', hash: m[5] || '' } };
@@ -414,16 +414,16 @@ var U = (function () {
414
414
  function problem(err) {
415
415
  var m = '' + ((err && err.message) || err || '');
416
416
  var big = m.match(/^Too large \((over [^)]+)\)/);
417
- if (big) { return 'too large (' + big[1] + ')'; }
418
- if (/^Bad JSON/.test(m)) { return 'not valid JSON'; }
417
+ if (big) { return t('too large ({what})', { what: big[1] }); }
418
+ if (/^Bad JSON/.test(m)) { return t('not valid JSON'); }
419
419
  var late = m.match(/^Timed out after (\d+ s)/);
420
- if (late) { return 'timed out after ' + late[1]; }
421
- if (/^Timeout/.test(m)) { return 'timed out'; }
422
- if (/^(No answer|Network error)/.test(m)) { return 'no answer (connection refused, blocked or certificate)'; }
423
- if (/^Redirected into the home network/.test(m)) { return 'redirected into the home network'; }
420
+ if (late) { return t('timed out after {time}', { time: late[1] }); }
421
+ if (/^Timeout/.test(m)) { return t('timed out'); }
422
+ if (/^(No answer|Network error)/.test(m)) { return t('no answer (connection refused, blocked or certificate)'); }
423
+ if (/^Redirected into the home network/.test(m)) { return t('redirected into the home network'); }
424
424
  var st = m.match(/^HTTP (\d+)/);
425
- if (st) { return st[1] === '0' ? 'no answer (connection refused, blocked or certificate)' : 'HTTP ' + st[1]; }
426
- return m.split(':')[0] || 'failed';
425
+ if (st) { return st[1] === '0' ? t('no answer (connection refused, blocked or certificate)') : 'HTTP ' + st[1]; }
426
+ return m.split(':')[0] || t('failed');
427
427
  }
428
428
 
429
429
  /* A list from an answer: [] unless it really is one, only its object items (the rest
@@ -709,7 +709,7 @@ var U = (function () {
709
709
  var LEFTOVER_SHARE = 0.5, _busy = null, _refusalTidy = false;
710
710
  // Use the TV's database (Settings › Diagnostics › Storage; on unless turned off):
711
711
  // off, the big copies are kept in the settings storage (BIG_KEY: the ones that go here).
712
- var USE_KEY = 'stremiok.bigdb', BIG_KEY = /^stremiok\.(homecache|local\.index|iptv\.cache\.|trakt\.watched|media\.watched)/;
712
+ var USE_KEY = 'stremiok.bigdb', BIG_KEY = /^stremiok\.(homecache|local\.index|iptv\.cache\.|trakt\.watched|media\.watched|stremio\.items)/;
713
713
  function enabled() { return store.get(USE_KEY, true) !== false; }
714
714
  function lsBigKeys() {
715
715
  var out = [];
@@ -966,8 +966,8 @@ var U = (function () {
966
966
  // "6 KB; the database: 380 KB used of 15.3 MB; the TV: 225 MB free" (what's known)
967
967
  function figures(size, q) {
968
968
  return diskInfo().then(function (d) {
969
- return fmtSize(size) + (q && q.quota ? '; the database: ' + fmtSize(q.usage || 0) + ' used of ' + fmtSize(q.quota) : '') +
970
- (d ? '; the TV: ' + fmtSize(d.free) + ' free' : '');
969
+ return fmtSize(size) + (q && q.quota ? '; ' + t('the database: {used} used of {quota}', { used: fmtSize(q.usage || 0), quota: fmtSize(q.quota) }) : '') +
970
+ (d ? '; ' + t('the TV: {free} free', { free: fmtSize(d.free) }) : '');
971
971
  });
972
972
  }
973
973
  function fmtSize(n) { return n >= 1048576 ? (n / 1048576).toFixed(1).replace(/\.0$/, '') + ' MB' : Math.max(1, Math.round(n / 1024)) + ' KB'; }
@@ -1071,7 +1071,7 @@ var U = (function () {
1071
1071
  }
1072
1072
  log('storage', 'TV storage full: could not save ' + key);
1073
1073
  var now = Date.now();
1074
- if (_fullToldAt === null || now - _fullToldAt > 60000) { _fullToldAt = now; try { toast('The TV’s storage is full: a change couldn’t be saved (Settings › Diagnostics).', 4000); } catch (e2) {} }
1074
+ if (_fullToldAt === null || now - _fullToldAt > 60000) { _fullToldAt = now; try { toast(t('The TV’s storage is full: a change couldn’t be saved (Settings › Diagnostics).'), 4000); } catch (e2) {} }
1075
1075
  return false;
1076
1076
  },
1077
1077
  remove: function (key) {
@@ -1574,19 +1574,30 @@ var U = (function () {
1574
1574
  }
1575
1575
 
1576
1576
  // A day relative to today: "today", "tomorrow", "yesterday", else "Thu 2 Oct" (and the
1577
- // year when it isn't this one).
1577
+ // year when it isn't this one), in the interface's language.
1578
1578
  var WDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
1579
1579
  var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
1580
+ function weekday(d) { return t(WDAYS[d]); }
1581
+ function month(m) { return t(MONTHS[m]); }
1580
1582
  function dayLabel(ms) {
1581
1583
  var d = new Date(ms), today = new Date(Date.now());
1582
1584
  function startOf(x) { return new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime(); }
1583
1585
  var diff = Math.round((startOf(d) - startOf(today)) / 86400000);
1584
- if (diff === 0) { return 'today'; }
1585
- if (diff === 1) { return 'tomorrow'; }
1586
- if (diff === -1) { return 'yesterday'; }
1587
- return WDAYS[d.getDay()] + ' ' + d.getDate() + ' ' + MONTHS[d.getMonth()] +
1586
+ if (diff === 0) { return t('today'); }
1587
+ if (diff === 1) { return t('tomorrow'); }
1588
+ if (diff === -1) { return t('yesterday'); }
1589
+ return weekday(d.getDay()) + ' ' + d.getDate() + ' ' + month(d.getMonth()) +
1588
1590
  (d.getFullYear() !== today.getFullYear() ? ' ' + d.getFullYear() : '');
1589
1591
  }
1592
+ // The interface's language (js/i18n.js): a phrase by its English text, {name}s filled in; a
1593
+ // number's singular or plural form. Without it (a test, a page that didn't load it): English.
1594
+ function t(s, vars) { return (typeof I18N !== 'undefined') ? I18N.t(s, vars) : ('' + s).replace(/\{(\w+)\}/g, function (m, k) { return vars && Object.prototype.hasOwnProperty.call(vars, k) ? '' + vars[k] : m; }); }
1595
+ function tn(n, one, other, vars) {
1596
+ if (typeof I18N !== 'undefined') { return I18N.tn(n, one, other, vars); }
1597
+ var v = { n: n };
1598
+ if (vars) { Object.keys(vars).forEach(function (k) { v[k] = vars[k]; }); }
1599
+ return t(n === 1 ? one : other, v);
1600
+ }
1590
1601
 
1591
1602
  /* Run an array of promise-returning fns with limited concurrency; never rejects.
1592
1603
  Returns Promise of array of {ok, value|error} in original order. */
@@ -1686,6 +1697,7 @@ var U = (function () {
1686
1697
  postJSON: postJSON, redactUrl: redactUrl, problem: problem, problemDetail: problemDetail, listOf: listOf, lru: lru, randomHex: randomHex, cachedJSON: cachedJSON,
1687
1698
  parseUrl: parseUrl, urlProblem: urlProblem, isPlaylistUrl: isPlaylistUrl, isManifestUrl: isManifestUrl,
1688
1699
  isPrivateHost: isPrivateHost, urlIsPrivate: urlIsPrivate, setLocalPolicy: setLocalPolicy, sanitizeHeaders: sanitizeHeaders, drawable: drawable,
1700
+ t: t, tn: tn, weekday: weekday, month: month,
1689
1701
  look: look, setLook: setLook, canBlur: canBlur, heroImages: heroImages, log: log, logEntries: logEntries, clearLog: clearLog, bigStore: bigStore, diskInfo: diskInfo,
1690
1702
  store: store, toast: toast, spinner: spinner,
1691
1703
  deferImage: deferImage, deferBg: deferBg, cardImage: cardImage, prioritizeImages: prioritizeImages, requeueImages: requeueImages,