Attempt to implement date-fns internalization

This commit is contained in:
ferferga 2020-03-26 13:53:30 +01:00
parent cbe3cbe221
commit 1656e73adf
3 changed files with 17 additions and 2 deletions

View File

@ -114,3 +114,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;
});

View File

@ -1,4 +1,5 @@
define(["jQuery", "loading", "events", "globalize", "serverNotifications", "humanedate", "listViewStyle", "emby-button"], function($, loading, events, globalize, serverNotifications) {
import { es } from 'date-fns/locale'
define(["jQuery", "loading", "events", "globalize", "serverNotifications", "date-fns", "listViewStyle", "emby-button"], function($, loading, events, globalize, serverNotifications, datefns) {
"use strict";
function reloadList(page) {
@ -66,7 +67,8 @@ define(["jQuery", "loading", "events", "globalize", "serverNotifications", "huma
var html = "";
if (task.State === "Idle") {
if (task.LastExecutionResult) {
html += globalize.translate("LabelScheduledTaskLastRan", humaneDate(task.LastExecutionResult.EndTimeUtc), humaneElapsed(task.LastExecutionResult.StartTimeUtc, task.LastExecutionResult.EndTimeUtc));
html += globalize.translate("LabelScheduledTaskLastRan", datefns.formatDistanceToNow(Date.parse(task.LastExecutionResult.EndTimeUtc), { addSuffix: true, locale: es }),
datefns.formatDistance(Date.parse(task.LastExecutionResult.StartTimeUtc), Date.parse(task.LastExecutionResult.EndTimeUtc), { addSuffix: false, locale: es }));
if (task.LastExecutionResult.Status === "Failed") {
html += " <span style='color:#FF0000;'>(" + globalize.translate("LabelFailed") + ")</span>";
} else if (task.LastExecutionResult.Status === "Cancelled") {

View File

@ -619,6 +619,7 @@ var AppInfo = {};
}
require(["mediaSession", "serverNotifications"]);
require(["date-fns", "date-fns/locale"]);
if (!browser.tv && !browser.xboxOne) {
require(["components/playback/playbackorientation"]);
@ -738,6 +739,7 @@ var AppInfo = {};
"webcomponents",
"material-icons",
"jellyfin-noto",
"date-fns",
"page",
"polyfill"
]