From 2cd93384176e040c9f2cdd5948efa9966cd38bc0 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 5 Aug 2018 16:40:14 +0200 Subject: [PATCH] Added translation for dates --- assets/js/common/date.js | 18 +++++++++--------- assets/js/components/comments/ui.js | 2 +- assets/js/components/posts/ui.js | 2 +- assets/js/langs/en.inc.js | 12 ++++++++++++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/assets/js/common/date.js b/assets/js/common/date.js index 5a925ddc..3183599e 100644 --- a/assets/js/common/date.js +++ b/assets/js/common/date.js @@ -27,7 +27,7 @@ ComunicWeb.common.date = { //Check there was less than one minute if(difference == 0) - return seconds + "s"; + return lang("dates_s", [seconds]); //Calculate minutes @@ -36,7 +36,7 @@ ComunicWeb.common.date = { //Check there was less than one hour if(difference == 0) - return minutes + "min"; + return lang("dates_min", [minutes]); //Calculate hours @@ -45,7 +45,7 @@ ComunicWeb.common.date = { //Check there was less than a day if(difference == 0) - return hours + "h"; + return lang("dates_h", [hours]); //Calculate days @@ -55,9 +55,9 @@ ComunicWeb.common.date = { //Check there was less than a month if(difference == 0){ if(days == 1) - return "1 day"; + return lang("dates_one_day"); else - return days + " days"; + return lang("dates_days", [days]); } @@ -68,19 +68,19 @@ ComunicWeb.common.date = { //Check there was less than a year if(difference == 0){ if(months == 1) - return "1 month"; + return lang("dates_one_month"); else - return months + " months"; + return lang("dates_months", [months]); } //Calculate years var years = difference; if(years == 1){ - return "1 year"; + return lang("dates_one_year"); } else { - return years + " years"; + return lang("dates_years", [years]); } }, diff --git a/assets/js/components/comments/ui.js b/assets/js/components/comments/ui.js index 831d269e..b2744bd5 100644 --- a/assets/js/components/comments/ui.js +++ b/assets/js/components/comments/ui.js @@ -147,7 +147,7 @@ ComunicWeb.components.comments.ui = { createElem2({ appendTo: rightContainer, type: "span", - innerHTML: ComunicWeb.common.date.timeDiffToStr(infos.time_sent) + " ago" + innerHTML: lang("dates_ago", [ComunicWeb.common.date.timeDiffToStr(infos.time_sent)]) }); //Offer the user the possibility to delete and update the comment if he is allowed to do so diff --git a/assets/js/components/posts/ui.js b/assets/js/components/posts/ui.js index fa253fae..95dfbf5a 100644 --- a/assets/js/components/posts/ui.js +++ b/assets/js/components/posts/ui.js @@ -69,7 +69,7 @@ ComunicWeb.components.posts.ui = { }); //Show the age of the post - postDescription.innerHTML = ComunicWeb.common.date.timeDiffToStr(info.post_time) + " ago"; + postDescription.innerHTML = lang("dates_ago", [ComunicWeb.common.date.timeDiffToStr(info.post_time)]); /** diff --git a/assets/js/langs/en.inc.js b/assets/js/langs/en.inc.js index 95bbf125..b3a93a7b 100644 --- a/assets/js/langs/en.inc.js +++ b/assets/js/langs/en.inc.js @@ -18,6 +18,18 @@ ComunicWeb.common.langs.en = { "__fatal_error": "Fatal error", "__fatal_error_explanation": "A fatal error occured : %p. Please try to refresh the page...", + //Dates + dates_s: "%p s", + dates_min: "%p min", + dates_h: "% h", + dates_one_day: "1 day", + dates_days: "%p days", + dates_one_month: "1 month", + dates_months: "%p months", + dates_one_year: "1 year", + dates_years: "%p years", + dates_ago: "%p ago", + //Messages messages_loading_layout_title: "Loading", messages_loading_layout_message: "Please wait while this page is loading...",