From 5e10a911758300ee025272b575697f6d4ba6cb0d Mon Sep 17 00:00:00 2001 From: Blakko Date: Mon, 8 Jul 2013 12:33:05 +0200 Subject: [PATCH] Internationalization of the util part --- .../modules/core/scripts/util/date-time.js | 4 +-- .../modules/core/scripts/util/dialog.js | 2 +- main/webapp/modules/core/scripts/util/misc.js | 10 ++++---- .../scripts/util/select-encoding-dialog.html | 8 +++--- main/webapp/modules/langs/translation-en.json | 25 +++++++++++++------ 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/main/webapp/modules/core/scripts/util/date-time.js b/main/webapp/modules/core/scripts/util/date-time.js index 692eaa26e..a88b4eca7 100644 --- a/main/webapp/modules/core/scripts/util/date-time.js +++ b/main/webapp/modules/core/scripts/util/date-time.js @@ -96,7 +96,7 @@ DateTimeUtil.setIso8601Date = function(dateObject, string) { var d = string.match(DateTimeUtil._dateRegexp); if(!d) { - throw new Error("Invalid date string: " + string); + throw new Error($.i18n._('core-util-enc')["invalid-date"]+": " + string); } var sign = (d[1] == "-") ? -1 : 1; // BC or AD @@ -153,7 +153,7 @@ DateTimeUtil.setIso8601Time = function (dateObject, string) { var d = string.match(DateTimeUtil._timeRegexp); if(!d) { - SimileAjax.Debug.warn("Invalid time string: " + string); + SimileAjax.Debug.warn($.i18n._('core-util-enc')["invalid-date"]+": " + string); return false; } var hours = d[1]; diff --git a/main/webapp/modules/core/scripts/util/dialog.js b/main/webapp/modules/core/scripts/util/dialog.js index 54f748137..aef055271 100644 --- a/main/webapp/modules/core/scripts/util/dialog.js +++ b/main/webapp/modules/core/scripts/util/dialog.js @@ -113,7 +113,7 @@ DialogSystem.showBusy = function(message) { var body = $('
').attr('id', 'loading-message').appendTo(frame); $('').attr("src", "images/large-spinner.gif").appendTo(body); - $('').html(" " + (message || "Working...")).appendTo(body); + $('').html(" " + (message || $.i18n._('core-util-enc')["working"]+"...")).appendTo(body); var level = DialogSystem.showDialog(frame); diff --git a/main/webapp/modules/core/scripts/util/misc.js b/main/webapp/modules/core/scripts/util/misc.js index 82df4b332..21d538b53 100644 --- a/main/webapp/modules/core/scripts/util/misc.js +++ b/main/webapp/modules/core/scripts/util/misc.js @@ -64,22 +64,22 @@ function formatRelativeDate(d) { var tomorrow = Date.today().add({ days: 1 }); if (d.between(today, tomorrow)) { - return "today " + d.toString("h:mm tt"); + return $.i18n._('core-util-enc')["today"]+" " + d.toString("h:mm tt"); } else if (d.between(last_week, today)) { var diff = Math.floor(today.getDayOfYear() - d.getDayOfYear()); - return (diff <= 1) ? ("yesterday " + d.toString("h:mm tt")) : (diff + " days ago"); + return (diff <= 1) ? ($.i18n._('core-util-enc')["yesterday"]+" " + d.toString("h:mm tt")) : (diff + " "+$.i18n._('core-util-enc')["days-ago"]); } else if (d.between(last_month, today)) { var diff = Math.floor((today.getDayOfYear() - d.getDayOfYear()) / 7); if (diff < 1) {diff += 52}; - return (diff == 1) ? "a week ago" : diff.toFixed(0) + " weeks ago" ; + return (diff == 1) ? $.i18n._('core-util-enc')["week-ago"] : diff.toFixed(0) + " "+$.i18n._('core-util-enc')["weeks-ago"] ; } else if (d.between(almost_last_year, today)) { var diff = today.getMonth() - d.getMonth(); if (diff < 1) { diff += 12; } - return (diff == 1) ? "a month ago" : diff + " months ago"; + return (diff == 1) ? $.i18n._('core-util-enc')["month-ago"] : diff + " "+ $.i18n._('core-util-enc')["months-ago"]; } else { var diff = Math.floor(today.getYear() - d.getYear()); - return (diff == 1) ? "a year ago" : diff + " years ago"; + return (diff == 1) ? $.i18n._('core-util-enc')["year-ago"] : diff + " "+$.i18n._('core-util-enc')["years-ago"]; } } \ No newline at end of file diff --git a/main/webapp/modules/core/scripts/util/select-encoding-dialog.html b/main/webapp/modules/core/scripts/util/select-encoding-dialog.html index 03bfb83d0..5d5ec5b58 100644 --- a/main/webapp/modules/core/scripts/util/select-encoding-dialog.html +++ b/main/webapp/modules/core/scripts/util/select-encoding-dialog.html @@ -1,11 +1,11 @@
-
Select Encoding
+
@@ -16,7 +16,7 @@
\ No newline at end of file diff --git a/main/webapp/modules/langs/translation-en.json b/main/webapp/modules/langs/translation-en.json index 6969e2659..21ebb5cd8 100644 --- a/main/webapp/modules/langs/translation-en.json +++ b/main/webapp/modules/langs/translation-en.json @@ -113,13 +113,6 @@ "quotation-mark": "Quotation marks are used
to enclose cells containing
column separators", "click-xml": "Click on the first XML element corresponding to the first record to load." }, - "core-util-enc": { - "select-enc": "Select Encoding", - "common": "Common Encodings", - "all": "All Encodings", - "encoding": "Encoding", - "aliases": "Aliases" - }, "core-dialogs": { "cluster-edit": "Cluster & Edit column", "cluster-size": "Cluster Size", @@ -350,6 +343,24 @@ "fb-en-ns": "the Wikipedia English namespace", "this-ns": "this namespace:" }, + "core-util-enc": { + "select-enc": "Select Encoding", + "common": "Common Encodings", + "all": "All Encodings", + "encoding": "Encoding", + "aliases": "Aliases", + "today": "today", + "yesterday": "yesterday", + "days-ago": "days ago", + "week-ago": "a week ago", + "weeks-ago": "weeks ago", + "month-ago": "a month ago", + "months-ago": "months ago", + "year-ago": "a year ago", + "years-ago": "years ago", + "working": "Working", + "invalid-date": "Invalid date string" + }, "core-buttons": { "cancel": "Cancel", "ok": "  OK  ",