diff --git a/.eslintrc.yml b/.eslintrc.yml index 880315fd12..f501f33546 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -49,8 +49,7 @@ globals: getWindowLocationSearch: writable Globalize: writable Hls: writable - humaneDate: writable - humaneElapsed: writable + dfnshelper: writable LibraryMenu: writable LinkParser: writable LiveTvHelpers: writable diff --git a/package.json b/package.json index 6fcd0e8766..bac0d7e251 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "dependencies": { "alameda": "^1.4.0", "core-js": "^3.6.4", + "date-fns": "^2.11.1", "document-register-element": "^1.14.3", "flv.js": "^1.5.0", "hls.js": "^0.13.1", @@ -89,7 +90,8 @@ "src/components/input/keyboardnavigation.js", "src/components/sanatizefilename.js", "src/scripts/settings/webSettings.js", - "src/components/scrollManager.js" + "src/components/scrollManager.js", + "src/scripts/dfnshelper.js" ], "plugins": [ "@babel/plugin-transform-modules-amd" diff --git a/src/bundle.js b/src/bundle.js index ba5f74b163..316f42c94a 100644 --- a/src/bundle.js +++ b/src/bundle.js @@ -112,3 +112,14 @@ var polyfill = require("@babel/polyfill/dist/polyfill"); _define("polyfill", function () { return polyfill; }); + +// Date-FNS +var date_fns = require("date-fns"); +_define("date-fns", function () { + return date_fns; +}); + +var date_fns_locale = require("date-fns/locale"); +_define("date-fns/locale", function () { + return date_fns_locale; +}); diff --git a/src/components/activitylog.js b/src/components/activitylog.js index 05971f01b8..934a610ad0 100644 --- a/src/components/activitylog.js +++ b/src/components/activitylog.js @@ -1,4 +1,4 @@ -define(["events", "globalize", "dom", "datetime", "userSettings", "serverNotifications", "connectionManager", "emby-button", "listViewStyle"], function (events, globalize, dom, datetime, userSettings, serverNotifications, connectionManager) { +define(["events", "globalize", "dom", "date-fns", "dfnshelper", "userSettings", "serverNotifications", "connectionManager", "emby-button", "listViewStyle"], function (events, globalize, dom, datefns, dfnshelper, userSettings, serverNotifications, connectionManager) { "use strict"; function getEntryHtml(entry, apiClient) { @@ -26,8 +26,7 @@ define(["events", "globalize", "dom", "datetime", "userSettings", "serverNotific html += entry.Name; html += ""; html += '
" + Globalize.translate("ValueContainer").replace("{0}", profile.Container || allText) + "
"; + html += "" + Globalize.translate("ValueContainer", profile.Container || allText) + "
"; if ("Video" == profile.Type) { - html += "" + Globalize.translate("ValueVideoCodec").replace("{0}", profile.VideoCodec || allText) + "
"; - html += "" + Globalize.translate("ValueAudioCodec").replace("{0}", profile.AudioCodec || allText) + "
"; + html += "" + Globalize.translate("ValueVideoCodec", profile.VideoCodec || allText) + "
"; + html += "" + Globalize.translate("ValueAudioCodec", profile.AudioCodec || allText) + "
"; } else { if ("Audio" == profile.Type) { - html += "" + Globalize.translate("ValueCodec").replace("{0}", profile.AudioCodec || allText) + "
"; + html += "" + Globalize.translate("ValueCodec", profile.AudioCodec || allText) + "
"; } } @@ -319,14 +319,14 @@ define(["jQuery", "loading", "fnchecked", "emby-select", "emby-button", "emby-in html += "Protocol: " + (profile.Protocol || "Http") + "
"; - html += "" + Globalize.translate("ValueContainer").replace("{0}", profile.Container || allText) + "
"; + html += "" + Globalize.translate("ValueContainer", profile.Container || allText) + "
"; if ("Video" == profile.Type) { - html += "" + Globalize.translate("ValueVideoCodec").replace("{0}", profile.VideoCodec || allText) + "
"; - html += "" + Globalize.translate("ValueAudioCodec").replace("{0}", profile.AudioCodec || allText) + "
"; + html += "" + Globalize.translate("ValueVideoCodec", profile.VideoCodec || allText) + "
"; + html += "" + Globalize.translate("ValueAudioCodec", profile.AudioCodec || allText) + "
"; } else { if ("Audio" == profile.Type) { - html += "" + Globalize.translate("ValueCodec").replace("{0}", profile.AudioCodec || allText) + "
"; + html += "" + Globalize.translate("ValueCodec", profile.AudioCodec || allText) + "
"; } } @@ -404,11 +404,11 @@ define(["jQuery", "loading", "fnchecked", "emby-select", "emby-button", "emby-in html += "" + Globalize.translate("ValueContainer").replace("{0}", profile.Container || allText) + "
"; + html += "" + Globalize.translate("ValueContainer", profile.Container || allText) + "
"; if (profile.Conditions && profile.Conditions.length) { html += ""; - html += Globalize.translate("ValueConditions").replace("{0}", profile.Conditions.map(function (c) { + html += Globalize.translate("ValueConditions", profile.Conditions.map(function (c) { return c.Property; }).join(", ")); html += "
"; @@ -476,11 +476,11 @@ define(["jQuery", "loading", "fnchecked", "emby-select", "emby-button", "emby-in html += "" + Globalize.translate("ValueCodec").replace("{0}", profile.Codec || allText) + "
"; + html += "" + Globalize.translate("ValueCodec", profile.Codec || allText) + "
"; if (profile.Conditions && profile.Conditions.length) { html += ""; - html += Globalize.translate("ValueConditions").replace("{0}", profile.Conditions.map(function (c) { + html += Globalize.translate("ValueConditions", profile.Conditions.map(function (c) { return c.Property; }).join(", ")); html += "
"; @@ -547,20 +547,20 @@ define(["jQuery", "loading", "fnchecked", "emby-select", "emby-button", "emby-in html += "" + Globalize.translate("ValueContainer").replace("{0}", profile.Container || allText) + "
"; + html += "" + Globalize.translate("ValueContainer", profile.Container || allText) + "
"; if ("Video" == profile.Type) { - html += "" + Globalize.translate("ValueVideoCodec").replace("{0}", profile.VideoCodec || allText) + "
"; - html += "" + Globalize.translate("ValueAudioCodec").replace("{0}", profile.AudioCodec || allText) + "
"; + html += "" + Globalize.translate("ValueVideoCodec", profile.VideoCodec || allText) + "
"; + html += "" + Globalize.translate("ValueAudioCodec", profile.AudioCodec || allText) + "
"; } else { if ("Audio" == profile.Type) { - html += "" + Globalize.translate("ValueCodec").replace("{0}", profile.AudioCodec || allText) + "
"; + html += "" + Globalize.translate("ValueCodec", profile.AudioCodec || allText) + "
"; } } if (profile.Conditions && profile.Conditions.length) { html += ""; - html += Globalize.translate("ValueConditions").replace("{0}", profile.Conditions.map(function (c) { + html += Globalize.translate("ValueConditions", profile.Conditions.map(function (c) { return c.Property; }).join(", ")); html += "
"; diff --git a/src/controllers/itemdetailpage.js b/src/controllers/itemdetailpage.js index 23a672751c..178419e284 100644 --- a/src/controllers/itemdetailpage.js +++ b/src/controllers/itemdetailpage.js @@ -591,7 +591,7 @@ define(["loading", "appRouter", "layoutManager", "connectionManager", "userSetti try { var birthday = datetime.parseISO8601Date(item.PremiereDate, true).toDateString(); itemBirthday.classList.remove("hide"); - itemBirthday.innerHTML = globalize.translate("BirthDateValue").replace("{0}", birthday); + itemBirthday.innerHTML = globalize.translate("BirthDateValue", birthday); } catch (err) { itemBirthday.classList.add("hide"); } @@ -605,7 +605,7 @@ define(["loading", "appRouter", "layoutManager", "connectionManager", "userSetti try { var deathday = datetime.parseISO8601Date(item.EndDate, true).toDateString(); itemDeathDate.classList.remove("hide"); - itemDeathDate.innerHTML = globalize.translate("DeathDateValue").replace("{0}", deathday); + itemDeathDate.innerHTML = globalize.translate("DeathDateValue", deathday); } catch (err) { itemDeathDate.classList.add("hide"); } @@ -618,7 +618,7 @@ define(["loading", "appRouter", "layoutManager", "connectionManager", "userSetti if ("Person" == item.Type && item.ProductionLocations && item.ProductionLocations.length) { var gmap = '' + item.ProductionLocations[0] + ""; itemBirthLocation.classList.remove("hide"); - itemBirthLocation.innerHTML = globalize.translate("BirthPlaceValue").replace("{0}", gmap); + itemBirthLocation.innerHTML = globalize.translate("BirthPlaceValue", gmap); } else { itemBirthLocation.classList.add("hide"); } diff --git a/src/controllers/movies/moviesrecommended.js b/src/controllers/movies/moviesrecommended.js index 7e19af4b9f..98e0871479 100644 --- a/src/controllers/movies/moviesrecommended.js +++ b/src/controllers/movies/moviesrecommended.js @@ -91,21 +91,21 @@ define(["events", "layoutManager", "inputManager", "userSettings", "libraryMenu" switch (recommendation.RecommendationType) { case "SimilarToRecentlyPlayed": - title = Globalize.translate("RecommendationBecauseYouWatched").replace("{0}", recommendation.BaselineItemName); + title = Globalize.translate("RecommendationBecauseYouWatched", recommendation.BaselineItemName); break; case "SimilarToLikedItem": - title = Globalize.translate("RecommendationBecauseYouLike").replace("{0}", recommendation.BaselineItemName); + title = Globalize.translate("RecommendationBecauseYouLike", recommendation.BaselineItemName); break; case "HasDirectorFromRecentlyPlayed": case "HasLikedDirector": - title = Globalize.translate("RecommendationDirectedBy").replace("{0}", recommendation.BaselineItemName); + title = Globalize.translate("RecommendationDirectedBy", recommendation.BaselineItemName); break; case "HasActorFromRecentlyPlayed": case "HasLikedActor": - title = Globalize.translate("RecommendationStarring").replace("{0}", recommendation.BaselineItemName); + title = Globalize.translate("RecommendationStarring", recommendation.BaselineItemName); break; } diff --git a/src/controllers/userprofilespage.js b/src/controllers/userprofilespage.js index 2a2387ab60..180d0e62ae 100644 --- a/src/controllers/userprofilespage.js +++ b/src/controllers/userprofilespage.js @@ -1,4 +1,4 @@ -define(["loading", "dom", "globalize", "humanedate", "paper-icon-button-light", "cardStyle", "emby-button", "indicators", "flexStyles"], function (loading, dom, globalize) { +define(["loading", "dom", "globalize", "date-fns", "dfnshelper", "paper-icon-button-light", "cardStyle", "emby-button", "indicators", "flexStyles"], function (loading, dom, globalize, datefns, dfnshelper) { "use strict"; function deleteUser(page, id) { @@ -125,10 +125,11 @@ define(["loading", "dom", "globalize", "humanedate", "paper-icon-button-light", html += "