` elements are also supported:
+
+```html
+December 17, 2011
```
As time passes, the timestamps will automatically update.
**For more usage and examples**: [http://timeago.yarp.com/](http://timeago.yarp.com/)
-**For different language configurations**: [http://gist.github.com/6251](http://gist.github.com/6251)
+**For different language configurations**: visit the [`locales`](https://github.com/rmm5t/jquery-timeago/tree/master/locales) directory.
## Author
@@ -49,4 +57,4 @@ As time passes, the timestamps will automatically update.
[MIT License](http://www.opensource.org/licenses/mit-license.php)
-Copyright (c) 2008-2010, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
+Copyright (c) 2008-2012, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
diff --git a/index.html b/index.html
index e1fc3e73..a7b32848 100644
--- a/index.html
+++ b/index.html
@@ -118,7 +118,7 @@ How?
Excusez-moi?
- Yes, timeago has locale/i18n/language support. Here are some configuration examples . Email Ryan McGeary for corrections or additional languages.
+ Yes, timeago has locale/i18n/language support. Here are some configuration examples . Please submit a GitHub pull request for corrections or additional languages.
Where?
@@ -159,6 +159,16 @@ What else?
jQuery("time.timeago").timeago();
});
+
+ Are you concerned about time zone support? Don't be. Timeago handles
+ this too. As long as your timestamps are
+ in ISO 8601 format
+ and include a
+ full time
+ zone designator (±hhmm), everything should work out of the box
+ regardless of the time zone that your visitors live in.
+
+
Huh?
Need a Rails helper to make those fancy microformat abbr tags? Fine, here ya go:
@@ -175,7 +185,7 @@
Huh?
MIT
License
- Copyright © 2008-2011 Ryan McGeary
+ Copyright © 2008-2012 Ryan McGeary
(@rmm5t )
diff --git a/jquery.timeago.js b/jquery.timeago.js
index bb20c421..2e8d29f5 100644
--- a/jquery.timeago.js
+++ b/jquery.timeago.js
@@ -3,7 +3,7 @@
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
*
* @name timeago
- * @version 0.10.1
+ * @version 0.11.4
* @requires jQuery v1.2.3+
* @author Ryan McGeary
* @license MIT License - http://www.opensource.org/licenses/mit-license.php
@@ -11,7 +11,7 @@
* For usage and examples, visit:
* http://timeago.yarp.com/
*
- * Copyright (c) 2008-2011, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
+ * Copyright (c) 2008-2012, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
*/
(function($) {
$.timeago = function(timestamp) {
@@ -19,6 +19,8 @@
return inWords(timestamp);
} else if (typeof timestamp === "string") {
return inWords($.timeago.parse(timestamp));
+ } else if (typeof timestamp === "number") {
+ return inWords(new Date(timestamp));
} else {
return inWords($.timeago.datetime(timestamp));
}
@@ -77,28 +79,31 @@
minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
minutes < 90 && substitute($l.hour, 1) ||
hours < 24 && substitute($l.hours, Math.round(hours)) ||
- hours < 48 && substitute($l.day, 1) ||
- days < 30 && substitute($l.days, Math.floor(days)) ||
- days < 60 && substitute($l.month, 1) ||
- days < 365 && substitute($l.months, Math.floor(days / 30)) ||
- years < 2 && substitute($l.year, 1) ||
- substitute($l.years, Math.floor(years));
+ hours < 42 && substitute($l.day, 1) ||
+ days < 30 && substitute($l.days, Math.round(days)) ||
+ days < 45 && substitute($l.month, 1) ||
+ days < 365 && substitute($l.months, Math.round(days / 30)) ||
+ years < 1.5 && substitute($l.year, 1) ||
+ substitute($l.years, Math.round(years));
- return $.trim([prefix, words, suffix].join($l.wordSeparator));
+ var separator = $l.wordSeparator === undefined ? " " : $l.wordSeparator;
+ return $.trim([prefix, words, suffix].join(separator));
},
parse: function(iso8601) {
var s = $.trim(iso8601);
- s = s.replace(/\.\d\d\d+/,""); // remove milliseconds
+ s = s.replace(/\.\d+/,""); // remove milliseconds
s = s.replace(/-/,"/").replace(/-/,"/");
s = s.replace(/T/," ").replace(/Z/," UTC");
s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
return new Date(s);
},
datetime: function(elem) {
- // jQuery's `is()` doesn't play well with HTML5 in IE
- var isTime = $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
- var iso8601 = isTime ? $(elem).attr("datetime") : $(elem).attr("title");
+ var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
return $t.parse(iso8601);
+ },
+ isTime: function(elem) {
+ // jQuery's `is()` doesn't play well with HTML5 in IE
+ return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
}
});
@@ -126,7 +131,7 @@
if (!element.data("timeago")) {
element.data("timeago", { datetime: $t.datetime(element) });
var text = $.trim(element.text());
- if (text.length > 0) {
+ if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
element.attr("title", text);
}
}
diff --git a/locales/README.md b/locales/README.md
new file mode 100644
index 00000000..7557112d
--- /dev/null
+++ b/locales/README.md
@@ -0,0 +1,27 @@
+# Locale override examples for timeago
+
+You can represent time statements in most western languages where
+a prefix and/or suffix is used.
+
+The default case is to use suffix only (as in English), which you
+do by providing the `suffixAgo` and `suffixFromNow` settings in
+the strings hash (earlier versions of timeago used the deprecated
+`ago` and `fromNow` options). If present, they are used.
+
+ 2 minutes [suffixAgo]
+ 2 minutes [suffixFromNow]
+
+In case you want to use prefix only instead of
+suffix (e.g. Greek), you provide the `prefixAgo` and
+`prefixFromNow` options in the strings hash and leave `suffixAgo`
+and `suffixFromNow` empty or null.
+
+ [prefixAgo] 2 minutes
+ [prefixFromNow] 2 minutes
+
+For languages where you want to use a prefix only for future
+tense and prefix/suffix for past tense (for example swedish), you
+can combine the prefix and suffixes as needed.
+
+ [prefixAgo] 2 minutes [suffixAgo]
+ [prefixFromNow] 2 minutes
diff --git a/locales/jquery.timeago.ar.js b/locales/jquery.timeago.ar.js
new file mode 100644
index 00000000..5fcb8197
--- /dev/null
+++ b/locales/jquery.timeago.ar.js
@@ -0,0 +1,32 @@
+// Language: Arabic
+// Translated By Khaled Attia < Khal3d.com >
+(function() {
+ function numpf(num, w, x, y, z) {
+ if( num == 0 ) {
+ return w;
+ } else if( num == 2 ) {
+ return x;
+ } else if( num >= 3 && num <= 10) {
+ return y; // 3:10
+ } else {
+ return z; // 11+
+ }
+ }
+ jQuery.timeago.settings.strings = {
+ prefixAgo: "منذ",
+ prefixFromNow: "يتبقى",
+ suffixAgo: null,
+ suffixFromNow: null, // null OR "من الآن"
+ seconds: function(value) { return numpf(value, "لحظات", "ثانيتين", "%d ثواني", "%d ثانيه"); },
+ minute: "دقيقة",
+ minutes: function(value) { return numpf(value, null, "دقيقتين", "%d دقائق", "%d دقيقة"); },
+ hour: "ساعة",
+ hours: function(value) { return numpf(value, null, "ساعتين", "%d ساعات", "%d ساعة"); },
+ day: "يوم",
+ days: function(value) { return numpf(value, null, "يومين", "%d أيام", "%d يوم"); },
+ month: "شهر",
+ months: function(value) { return numpf(value, null, "شهرين", "%d أشهر", "%d شهر"); },
+ year: "سنه",
+ years: function(value) { return numpf(value, null, "سنتين", "%d سنوات", "%d سنه"); }
+ };
+})();
\ No newline at end of file
diff --git a/locales/jquery.timeago.bg.js b/locales/jquery.timeago.bg.js
new file mode 100644
index 00000000..df6b865e
--- /dev/null
+++ b/locales/jquery.timeago.bg.js
@@ -0,0 +1,18 @@
+// Bulgarian
+jQuery.timeago.settings.strings = {
+ prefixAgo: "преди",
+ prefixFromNow: "след",
+ suffixAgo: null,
+ suffixFromNow: null,
+ seconds: "по-малко от минута",
+ minute: "една минута",
+ minutes: "%d минути",
+ hour: "един час",
+ hours: "%d часа",
+ day: "един ден",
+ days: "%d дни",
+ month: "един месец",
+ months: "%d месеца",
+ year: "една година",
+ years: "%d години"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.bs.js b/locales/jquery.timeago.bs.js
new file mode 100644
index 00000000..01530fea
--- /dev/null
+++ b/locales/jquery.timeago.bs.js
@@ -0,0 +1,49 @@
+// Bosnian
+(function() {
+ var numpf;
+
+ numpf = function(n, f, s, t) {
+ var n10;
+ n10 = n % 10;
+ if (n10 === 1 && (n === 1 || n > 20)) {
+ return f;
+ } else if (n10 > 1 && n10 < 5 && (n > 20 || n < 10)) {
+ return s;
+ } else {
+ return t;
+ }
+ };
+
+ jQuery.timeago.settings.strings = {
+ prefixAgo: "prije",
+ prefixFromNow: "za",
+ suffixAgo: null,
+ suffixFromNow: null,
+ second: "sekund",
+ seconds: function(value) {
+ return numpf(value, "%d sekund", "%d sekunde", "%d sekundi");
+ },
+ minute: "oko minut",
+ minutes: function(value) {
+ return numpf(value, "%d minut", "%d minute", "%d minuta");
+ },
+ hour: "oko sat",
+ hours: function(value) {
+ return numpf(value, "%d sat", "%d sata", "%d sati");
+ },
+ day: "oko jednog dana",
+ days: function(value) {
+ return numpf(value, "%d dan", "%d dana", "%d dana");
+ },
+ month: "mjesec dana",
+ months: function(value) {
+ return numpf(value, "%d mjesec", "%d mjeseca", "%d mjeseci");
+ },
+ year: "prije godinu dana ",
+ years: function(value) {
+ return numpf(value, "%d godinu", "%d godine", "%d godina");
+ },
+ wordSeparator: " "
+ };
+
+}).call(this);
\ No newline at end of file
diff --git a/locales/jquery.timeago.ca.js b/locales/jquery.timeago.ca.js
new file mode 100644
index 00000000..59014ea5
--- /dev/null
+++ b/locales/jquery.timeago.ca.js
@@ -0,0 +1,18 @@
+// Catalan
+jQuery.timeago.settings.strings = {
+ prefixAgo: "fa",
+ prefixFromNow: "d'aqui a",
+ suffixAgo: null,
+ suffixFromNow: null,
+ seconds: "menys d'1 minut",
+ minute: "1 minut",
+ minutes: "uns %d minuts",
+ hour: "1 hora",
+ hours: "unes %d hores",
+ day: "1 dia",
+ days: "%d dies",
+ month: "aproximadament un mes",
+ months: "%d mesos",
+ year: "aproximadament un any",
+ years: "%d anys"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.cy.js b/locales/jquery.timeago.cy.js
new file mode 100644
index 00000000..a285ff4e
--- /dev/null
+++ b/locales/jquery.timeago.cy.js
@@ -0,0 +1,20 @@
+// Welsh
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: null,
+ suffixAgo: "yn ôl",
+ suffixFromNow: "o hyn",
+ seconds: "llai na munud",
+ minute: "am funud",
+ minutes: "%d munud",
+ hour: "tua awr",
+ hours: "am %d awr",
+ day: "y dydd",
+ days: "%d diwrnod",
+ month: "tua mis",
+ months: "%d mis",
+ year: "am y flwyddyn",
+ years: "%d blynedd",
+ wordSeparator: " ",
+ numbers: []
+};
diff --git a/locales/jquery.timeago.cz.js b/locales/jquery.timeago.cz.js
new file mode 100644
index 00000000..b7137384
--- /dev/null
+++ b/locales/jquery.timeago.cz.js
@@ -0,0 +1,18 @@
+// Czech
+jQuery.timeago.settings.strings = {
+ prefixAgo: "před",
+ prefixFromNow: null,
+ suffixAgo: null,
+ suffixFromNow: null,
+ seconds: "méně než minutou",
+ minute: "minutou",
+ minutes: "%d minutami",
+ hour: "hodinou",
+ hours: "%d hodinami",
+ day: "1 dnem",
+ days: "%d dny",
+ month: "1 měsícem",
+ months: "%d měsíci",
+ year: "1 rokem",
+ years: "%d roky"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.da.js b/locales/jquery.timeago.da.js
new file mode 100644
index 00000000..ff50e873
--- /dev/null
+++ b/locales/jquery.timeago.da.js
@@ -0,0 +1,18 @@
+// Danish
+jQuery.timeago.settings.strings = {
+ prefixAgo: "for",
+ prefixFromNow: "om",
+ suffixAgo: "siden",
+ suffixFromNow: "",
+ seconds: "mindre end et minut",
+ minute: "ca. et minut",
+ minutes: "%d minutter",
+ hour: "ca. en time",
+ hours: "ca. %d timer",
+ day: "en dag",
+ days: "%d dage",
+ month: "ca. en måned",
+ months: "%d måneder",
+ year: "ca. et år",
+ years: "%d år"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.de.js b/locales/jquery.timeago.de.js
new file mode 100644
index 00000000..f10b06ee
--- /dev/null
+++ b/locales/jquery.timeago.de.js
@@ -0,0 +1,18 @@
+// German
+jQuery.timeago.settings.strings = {
+ prefixAgo: "vor",
+ prefixFromNow: "in",
+ suffixAgo: "",
+ suffixFromNow: "",
+ seconds: "wenigen Sekunden",
+ minute: "etwa einer Minute",
+ minutes: "%d Minuten",
+ hour: "etwa einer Stunde",
+ hours: "%d Stunden",
+ day: "etwa einem Tag",
+ days: "%d Tagen",
+ month: "etwa einem Monat",
+ months: "%d Monaten",
+ year: "etwa einem Jahr",
+ years: "%d Jahren"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.el.js b/locales/jquery.timeago.el.js
new file mode 100644
index 00000000..61aaafe4
--- /dev/null
+++ b/locales/jquery.timeago.el.js
@@ -0,0 +1,18 @@
+// Greek
+jQuery.timeago.settings.strings = {
+ prefixAgo: "πριν",
+ prefixFromNow: "σε",
+ suffixAgo: "",
+ suffixFromNow: "",
+ seconds: "λιγότερο από ένα λεπτό",
+ minute: "περίπου ένα λεπτό",
+ minutes: "%d λεπτά",
+ hour: "περίπου μία ώρα",
+ hours: "περίπου %d ώρες",
+ day: "μία μέρα",
+ days: "%d μέρες",
+ month: "περίπου ένα μήνα",
+ months: "%d μήνες",
+ year: "περίπου ένα χρόνο",
+ years: "%d χρόνια"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.en-short.js b/locales/jquery.timeago.en-short.js
new file mode 100644
index 00000000..4cab7ff6
--- /dev/null
+++ b/locales/jquery.timeago.en-short.js
@@ -0,0 +1,20 @@
+// English shortened
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: null,
+ suffixAgo: "",
+ suffixFromNow: "",
+ seconds: "1m",
+ minute: "1m",
+ minutes: "%dm",
+ hour: "1h",
+ hours: "%dh",
+ day: "1d",
+ days: "%dd",
+ month: "1mo",
+ months: "%dmo",
+ year: "1yr",
+ years: "%dyr",
+ wordSeparator: " ",
+ numbers: []
+};
diff --git a/locales/jquery.timeago.en.js b/locales/jquery.timeago.en.js
new file mode 100644
index 00000000..3d6652c2
--- /dev/null
+++ b/locales/jquery.timeago.en.js
@@ -0,0 +1,20 @@
+// English (Template)
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: null,
+ suffixAgo: "ago",
+ suffixFromNow: "from now",
+ seconds: "less than a minute",
+ minute: "about a minute",
+ minutes: "%d minutes",
+ hour: "about an hour",
+ hours: "about %d hours",
+ day: "a day",
+ days: "%d days",
+ month: "about a month",
+ months: "%d months",
+ year: "about a year",
+ years: "%d years",
+ wordSeparator: " ",
+ numbers: []
+};
diff --git a/locales/jquery.timeago.es.js b/locales/jquery.timeago.es.js
new file mode 100644
index 00000000..00c6d0a6
--- /dev/null
+++ b/locales/jquery.timeago.es.js
@@ -0,0 +1,18 @@
+// Spanish
+jQuery.timeago.settings.strings = {
+ prefixAgo: "hace",
+ prefixFromNow: "dentro de",
+ suffixAgo: "",
+ suffixFromNow: "",
+ seconds: "menos de un minuto",
+ minute: "un minuto",
+ minutes: "unos %d minutos",
+ hour: "una hora",
+ hours: "%d horas",
+ day: "un día",
+ days: "%d días",
+ month: "un mes",
+ months: "%d meses",
+ year: "un año",
+ years: "%d años"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.fa.js b/locales/jquery.timeago.fa.js
new file mode 100644
index 00000000..0a70819d
--- /dev/null
+++ b/locales/jquery.timeago.fa.js
@@ -0,0 +1,22 @@
+
+// Persian
+// Use DIR attribute for RTL text in Persian Language for ABBR tag .
+// By MB.seifollahi@gmail.com
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: null,
+ suffixAgo: "پیش",
+ suffixFromNow: "از حال",
+ seconds: "کمتر از یک دقیقه",
+ minute: "حدود یک دقیقه",
+ minutes: "%d دقیقه",
+ hour: "حدود یک ساعت",
+ hours: "حدود %d ساعت",
+ day: "یک روز",
+ days: "%d روز",
+ month: "حدود یک ماه",
+ months: "%d ماه",
+ year: "حدود یک سال",
+ years: "%d سال",
+ wordSeparator: " "
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.fi.js b/locales/jquery.timeago.fi.js
new file mode 100644
index 00000000..06b12ee0
--- /dev/null
+++ b/locales/jquery.timeago.fi.js
@@ -0,0 +1,28 @@
+// Finnish
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: null,
+ suffixAgo: "sitten",
+ suffixFromNow: "tulevaisuudessa",
+ seconds: "alle minuutti",
+ minute: "minuutti",
+ minutes: "%d minuuttia",
+ hour: "tunti",
+ hours: "%d tuntia",
+ day: "päivä",
+ days: "%d päivää",
+ month: "kuukausi",
+ months: "%d kuukautta",
+ year: "vuosi",
+ years: "%d vuotta"
+};
+
+// The above is not a great localization because one would usually
+// write "2 days ago" in Finnish as "2 päivää sitten", however
+// one would write "2 days into the future" as "2:n päivän päästä"
+// which cannot be achieved with localization support this simple.
+// This is because Finnish has word suffixes (attached directly
+// to the end of the word). The word "day" is "päivä" in Finnish.
+// As workaround, the above localizations will say
+// "2 päivää tulevaisuudessa" which is understandable but
+// not as fluent.
\ No newline at end of file
diff --git a/locales/jquery.timeago.fr.js b/locales/jquery.timeago.fr.js
new file mode 100644
index 00000000..50283423
--- /dev/null
+++ b/locales/jquery.timeago.fr.js
@@ -0,0 +1,17 @@
+// French
+jQuery.timeago.settings.strings = {
+ // environ ~= about, it's optional
+ prefixAgo: "il y a",
+ prefixFromNow: "d'ici",
+ seconds: "moins d'une minute",
+ minute: "environ une minute",
+ minutes: "environ %d minutes",
+ hour: "environ une heure",
+ hours: "environ %d heures",
+ day: "environ un jour",
+ days: "environ %d jours",
+ month: "environ un mois",
+ months: "environ %d mois",
+ year: "un an",
+ years: "%d ans"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.he.js b/locales/jquery.timeago.he.js
new file mode 100644
index 00000000..9d5b6c6b
--- /dev/null
+++ b/locales/jquery.timeago.he.js
@@ -0,0 +1,18 @@
+// Hebrew
+jQuery.timeago.settings.strings = {
+ prefixAgo: "לפני",
+ prefixFromNow: "מעכשיו",
+ suffixAgo: "",
+ suffixFromNow: "",
+ seconds: "פחות מדקה",
+ minute: "דקה",
+ minutes: "%d דקות",
+ hour: "שעה",
+ hours: "%d שעות",
+ day: "יום",
+ days: "%d ימים",
+ month: "חודש",
+ months: "%d חודשים",
+ year: "שנה",
+ years: "%d שנים"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.hr.js b/locales/jquery.timeago.hr.js
new file mode 100644
index 00000000..a85bd803
--- /dev/null
+++ b/locales/jquery.timeago.hr.js
@@ -0,0 +1,49 @@
+// Croatian
+(function () {
+ var numpf;
+
+ numpf = function (n, f, s, t) {
+ var n10;
+ n10 = n % 10;
+ if (n10 === 1 && (n === 1 || n > 20)) {
+ return f;
+ } else if (n10 > 1 && n10 < 5 && (n > 20 || n < 10)) {
+ return s;
+ } else {
+ return t;
+ }
+ };
+
+ jQuery.timeago.settings.strings = {
+ prefixAgo: "prije",
+ prefixFromNow: "za",
+ suffixAgo: null,
+ suffixFromNow: null,
+ second: "sekundu",
+ seconds: function (value) {
+ return numpf(value, "%d sekundu", "%d sekunde", "%d sekundi");
+ },
+ minute: "oko minutu",
+ minutes: function (value) {
+ return numpf(value, "%d minutu", "%d minute", "%d minuta");
+ },
+ hour: "oko jedan sat",
+ hours: function (value) {
+ return numpf(value, "%d sat", "%d sata", "%d sati");
+ },
+ day: "jedan dan",
+ days: function (value) {
+ return numpf(value, "%d dan", "%d dana", "%d dana");
+ },
+ month: "mjesec dana",
+ months: function (value) {
+ return numpf(value, "%d mjesec", "%d mjeseca", "%d mjeseci");
+ },
+ year: "prije godinu dana",
+ years: function (value) {
+ return numpf(value, "%d godinu", "%d godine", "%d godina");
+ },
+ wordSeparator: " "
+ };
+
+}).call(this);
\ No newline at end of file
diff --git a/locales/jquery.timeago.hu.js b/locales/jquery.timeago.hu.js
new file mode 100644
index 00000000..3079c22b
--- /dev/null
+++ b/locales/jquery.timeago.hu.js
@@ -0,0 +1,18 @@
+// Hungarian
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: null,
+ suffixAgo: null,
+ suffixFromNow: null,
+ seconds: "kevesebb mint egy perce",
+ minute: "körülbelül egy perce",
+ minutes: "%d perce",
+ hour: "körülbelül egy órája",
+ hours: "körülbelül %d órája",
+ day: "körülbelül egy napja",
+ days: "%d napja",
+ month: "körülbelül egy hónapja",
+ months: "%d hónapja",
+ year: "körülbelül egy éve",
+ years: "%d éve"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.hy.js b/locales/jquery.timeago.hy.js
new file mode 100644
index 00000000..cd6e195e
--- /dev/null
+++ b/locales/jquery.timeago.hy.js
@@ -0,0 +1,18 @@
+// Armenian
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: null,
+ suffixAgo: "առաջ",
+ suffixFromNow: "հետո",
+ seconds: "վայրկյաններ",
+ minute: "մեկ րոպե",
+ minutes: "%d րոպե",
+ hour: "մեկ ժամ",
+ hours: "%d ժամ",
+ day: "մեկ օր",
+ days: "%d օր",
+ month: "մեկ ամիս",
+ months: "%d ամիս",
+ year: "մեկ տարի",
+ years: "%d տարի"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.id.js b/locales/jquery.timeago.id.js
new file mode 100644
index 00000000..72c39097
--- /dev/null
+++ b/locales/jquery.timeago.id.js
@@ -0,0 +1,18 @@
+// Indonesian
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: null,
+ suffixAgo: "yang lalu",
+ suffixFromNow: "dari sekarang",
+ seconds: "kurang dari semenit",
+ minute: "sekitar satu menit",
+ minutes: "%d menit",
+ hour: "sekitar sejam",
+ hours: "sekitar %d jam",
+ day: "sehari",
+ days: "%d hari",
+ month: "sekitar sebulan",
+ months: "%d tahun",
+ year: "sekitar setahun",
+ years: "%d tahun"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.it.js b/locales/jquery.timeago.it.js
new file mode 100644
index 00000000..6308dd30
--- /dev/null
+++ b/locales/jquery.timeago.it.js
@@ -0,0 +1,16 @@
+// Italian
+jQuery.timeago.settings.strings = {
+ suffixAgo: "fa",
+ suffixFromNow: "da ora",
+ seconds: "meno di un minuto",
+ minute: "circa un minuto",
+ minutes: "%d minuti",
+ hour: "circa un'ora",
+ hours: "circa %d ore",
+ day: "un giorno",
+ days: "%d giorni",
+ month: "circa un mese",
+ months: "%d mesi",
+ year: "circa un anno",
+ years: "%d anni"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.ja.js b/locales/jquery.timeago.ja.js
new file mode 100644
index 00000000..218e345b
--- /dev/null
+++ b/locales/jquery.timeago.ja.js
@@ -0,0 +1,19 @@
+// Japanese
+jQuery.timeago.settings.strings = {
+ prefixAgo: "",
+ prefixFromNow: "今から",
+ suffixAgo: "前",
+ suffixFromNow: "後",
+ seconds: "ほんの数秒",
+ minute: "約一分",
+ minutes: "%d 分",
+ hour: "大体一時間",
+ hours: "大体 %d 時間位",
+ day: "一日",
+ days: "%d 日ほど",
+ month: "大体一ヶ月",
+ months: "%d ヶ月ほど",
+ year: "丁度一年(虎舞流w)",
+ years: "%d 年",
+ wordSeparator: ""
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.ko.js b/locales/jquery.timeago.ko.js
new file mode 100644
index 00000000..a192b97b
--- /dev/null
+++ b/locales/jquery.timeago.ko.js
@@ -0,0 +1,17 @@
+// Korean
+jQuery.timeago.settings.strings = {
+ suffixAgo: "전",
+ suffixFromNow: "후",
+ seconds: "1분 이내",
+ minute: "1분",
+ minutes: "%d분",
+ hour: "1시간",
+ hours: "%d시간",
+ day: "하루",
+ days: "%d일",
+ month: "한 달",
+ months: "%d달",
+ year: "1년",
+ years: "%d년",
+ wordSeparator: " "
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.nl.js b/locales/jquery.timeago.nl.js
new file mode 100644
index 00000000..cd68438c
--- /dev/null
+++ b/locales/jquery.timeago.nl.js
@@ -0,0 +1,20 @@
+// Dutch
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: "",
+ suffixAgo: "geleden",
+ suffixFromNow: "van nu",
+ seconds: "minder dan een minuut",
+ minute: "ongeveer een minuut",
+ minutes: "%d minuten",
+ hour: "ongeveer een uur",
+ hours: "ongeveer %d uur",
+ day: "een dag",
+ days: "%d dagen",
+ month: "ongeveer een maand",
+ months: "%d maanden",
+ year: "ongeveer een jaar",
+ years: "%d jaar",
+ wordSeparator: " ",
+ numbers: []
+};
diff --git a/locales/jquery.timeago.no.js b/locales/jquery.timeago.no.js
new file mode 100644
index 00000000..65d1b0d8
--- /dev/null
+++ b/locales/jquery.timeago.no.js
@@ -0,0 +1,18 @@
+// Norwegian
+jQuery.timeago.settings.strings = {
+ prefixAgo: "for",
+ prefixFromNow: "om",
+ suffixAgo: "siden",
+ suffixFromNow: "",
+ seconds: "mindre enn et minutt",
+ minute: "ca. et minutt",
+ minutes: "%d minutter",
+ hour: "ca. en time",
+ hours: "ca. %d timer",
+ day: "en dag",
+ days: "%d dager",
+ month: "ca. en måned",
+ months: "%d måneder",
+ year: "ca. et år",
+ years: "%d år"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.pl.js b/locales/jquery.timeago.pl.js
new file mode 100644
index 00000000..21d26fc1
--- /dev/null
+++ b/locales/jquery.timeago.pl.js
@@ -0,0 +1,31 @@
+// Polish
+(function() {
+ function numpf(n, s, t) {
+ // s - 2-4, 22-24, 32-34 ...
+ // t - 5-21, 25-31, ...
+ var n10 = n % 10;
+ if ( (n10 > 1) && (n10 < 5) && ( (n > 20) || (n < 10) ) ) {
+ return s;
+ } else {
+ return t;
+ }
+ }
+
+ jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: "za",
+ suffixAgo: "temu",
+ suffixFromNow: null,
+ seconds: "mniej niż minutę",
+ minute: "minutę",
+ minutes: function(value) { return numpf(value, "%d minuty", "%d minut"); },
+ hour: "godzinę",
+ hours: function(value) { return numpf(value, "%d godziny", "%d godzin"); },
+ day: "dzień",
+ days: "%d dni",
+ month: "miesiąc",
+ months: function(value) { return numpf(value, "%d miesiące", "%d miesięcy"); },
+ year: "rok",
+ years: function(value) { return numpf(value, "%d lata", "%d lat"); }
+ };
+})();
\ No newline at end of file
diff --git a/locales/jquery.timeago.pt.js b/locales/jquery.timeago.pt.js
new file mode 100644
index 00000000..416333c6
--- /dev/null
+++ b/locales/jquery.timeago.pt.js
@@ -0,0 +1,16 @@
+// Portuguese
+jQuery.timeago.settings.strings = {
+ suffixAgo: "atrás",
+ suffixFromNow: "a partir de agora",
+ seconds: "menos de um minuto",
+ minute: "cerca de um minuto",
+ minutes: "%d minutos",
+ hour: "cerca de uma hora",
+ hours: "cerca de %d horas",
+ day: "um dia",
+ days: "%d dias",
+ month: "cerca de um mês",
+ months: "%d meses",
+ year: "cerca de um ano",
+ years: "%d anos"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.ro.js b/locales/jquery.timeago.ro.js
new file mode 100644
index 00000000..883b5489
--- /dev/null
+++ b/locales/jquery.timeago.ro.js
@@ -0,0 +1,18 @@
+// Romanian
+$.timeago.settings.strings = {
+ prefixAgo: "acum",
+ prefixFromNow: "in timp de",
+ suffixAgo: "",
+ suffixFromNow: "",
+ seconds: "mai putin de un minut",
+ minute: "un minut",
+ minutes: "%d minute",
+ hour: "o ora",
+ hours: "%d ore",
+ day: "o zi",
+ days: "%d zile",
+ month: "o luna",
+ months: "%d luni",
+ year: "un an",
+ years: "%d ani"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.ru.js b/locales/jquery.timeago.ru.js
new file mode 100644
index 00000000..4cdc01b1
--- /dev/null
+++ b/locales/jquery.timeago.ru.js
@@ -0,0 +1,34 @@
+// Russian
+(function() {
+ function numpf(n, f, s, t) {
+ // f - 1, 21, 31, ...
+ // s - 2-4, 22-24, 32-34 ...
+ // t - 5-20, 25-30, ...
+ var n10 = n % 10;
+ if ( (n10 == 1) && ( (n == 1) || (n > 20) ) ) {
+ return f;
+ } else if ( (n10 > 1) && (n10 < 5) && ( (n > 20) || (n < 10) ) ) {
+ return s;
+ } else {
+ return t;
+ }
+ }
+
+ jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: "через",
+ suffixAgo: "назад",
+ suffixFromNow: null,
+ seconds: "меньше минуты",
+ minute: "минуту",
+ minutes: function(value) { return numpf(value, "%d минута", "%d минуты", "%d минут"); },
+ hour: "час",
+ hours: function(value) { return numpf(value, "%d час", "%d часа", "%d часов"); },
+ day: "день",
+ days: function(value) { return numpf(value, "%d день", "%d дня", "%d дней"); },
+ month: "месяц",
+ months: function(value) { return numpf(value, "%d месяц", "%d месяца", "%d месяцев"); },
+ year: "год",
+ years: function(value) { return numpf(value, "%d год", "%d года", "%d лет"); }
+ };
+})();
\ No newline at end of file
diff --git a/locales/jquery.timeago.sv.js b/locales/jquery.timeago.sv.js
new file mode 100644
index 00000000..b5c39471
--- /dev/null
+++ b/locales/jquery.timeago.sv.js
@@ -0,0 +1,18 @@
+// Swedish
+jQuery.timeago.settings.strings = {
+ prefixAgo: "för",
+ prefixFromNow: "om",
+ suffixAgo: "sedan",
+ suffixFromNow: "",
+ seconds: "mindre än en minut",
+ minute: "ungefär en minut",
+ minutes: "%d minuter",
+ hour: "ungefär en timme",
+ hours: "ungefär %d timmar",
+ day: "en dag",
+ days: "%d dagar",
+ month: "ungefär en månad",
+ months: "%d månader",
+ year: "ungefär ett år",
+ years: "%d år"
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.tr.js b/locales/jquery.timeago.tr.js
new file mode 100644
index 00000000..f3e3a67c
--- /dev/null
+++ b/locales/jquery.timeago.tr.js
@@ -0,0 +1,16 @@
+// Turkish
+jQuery.extend($.timeago.settings.strings, {
+ suffixAgo: 'önce',
+ suffixFromNow: null,
+ seconds: '1 dakikadan',
+ minute: '1 dakika',
+ minutes: '%d dakika',
+ hour: '1 saat',
+ hours: '%d saat',
+ day: '1 gün',
+ days: '%d gün',
+ month: '1 ay',
+ months: '%d ay',
+ year: '1 yıl',
+ years: '%d yıl'
+});
\ No newline at end of file
diff --git a/locales/jquery.timeago.uk.js b/locales/jquery.timeago.uk.js
new file mode 100644
index 00000000..e9516951
--- /dev/null
+++ b/locales/jquery.timeago.uk.js
@@ -0,0 +1,34 @@
+// Ukrainian
+(function() {
+ function numpf(n, f, s, t) {
+ // f - 1, 21, 31, ...
+ // s - 2-4, 22-24, 32-34 ...
+ // t - 5-20, 25-30, ...
+ var n10 = n % 10;
+ if ( (n10 == 1) && ( (n == 1) || (n > 20) ) ) {
+ return f;
+ } else if ( (n10 > 1) && (n10 < 5) && ( (n > 20) || (n < 10) ) ) {
+ return s;
+ } else {
+ return t;
+ }
+ }
+
+ jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: "через",
+ suffixAgo: "тому",
+ suffixFromNow: null,
+ seconds: "меньше хвилини",
+ minute: "хвилина",
+ minutes: function(value) { return numpf(value, "%d хвилина", "%d хвилини", "%d хвилин"); },
+ hour: "година",
+ hours: function(value) { return numpf(value, "%d година", "%d години", "%d годин"); },
+ day: "день",
+ days: function(value) { return numpf(value, "%d день", "%d дні", "%d днів"); },
+ month: "місяць",
+ months: function(value) { return numpf(value, "%d місяць", "%d місяці", "%d місяців"); },
+ year: "рік",
+ years: function(value) { return numpf(value, "%d рік", "%d роки", "%d років"); }
+ };
+})();
\ No newline at end of file
diff --git a/locales/jquery.timeago.uz.js b/locales/jquery.timeago.uz.js
new file mode 100755
index 00000000..31c0c02a
--- /dev/null
+++ b/locales/jquery.timeago.uz.js
@@ -0,0 +1,19 @@
+//Uzbek
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: "keyin",
+ suffixAgo: "avval",
+ suffixFromNow: null,
+ seconds: "bir necha soniya",
+ minute: "1 daqiqa",
+ minutes: function(value) { return "%d daqiqa" },
+ hour: "1 soat",
+ hours: function(value) { return "%d soat" },
+ day: "1 kun",
+ days: function(value) { return "%d kun" },
+ month: "1 oy",
+ months: function(value) { return "%d oy" },
+ year: "1 yil",
+ years: function(value) { return "%d yil" },
+ wordSeparator: " "
+};
diff --git a/locales/jquery.timeago.zh-CN.js b/locales/jquery.timeago.zh-CN.js
new file mode 100644
index 00000000..f39417ef
--- /dev/null
+++ b/locales/jquery.timeago.zh-CN.js
@@ -0,0 +1,20 @@
+// Simplified Chinese
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: "从现在开始",
+ suffixAgo: "之前",
+ suffixFromNow: null,
+ seconds: "不到 1 分钟",
+ minute: "大约 1 分钟",
+ minutes: "%d 分钟",
+ hour: "大约 1 小时",
+ hours: "大约 %d 小时",
+ day: "1 天",
+ days: "%d 天",
+ month: "大约 1 个月",
+ months: "%d 月",
+ year: "大约 1 年",
+ years: "%d 年",
+ numbers: [],
+ wordSeparator: ""
+};
\ No newline at end of file
diff --git a/locales/jquery.timeago.zh-TW.js b/locales/jquery.timeago.zh-TW.js
new file mode 100644
index 00000000..36cf7803
--- /dev/null
+++ b/locales/jquery.timeago.zh-TW.js
@@ -0,0 +1,20 @@
+// Traditional Chinese, zh-tw
+jQuery.timeago.settings.strings = {
+ prefixAgo: null,
+ prefixFromNow: "從現在開始",
+ suffixAgo: "之前",
+ suffixFromNow: null,
+ seconds: "不到 1 分鐘",
+ minute: "大約 1 分鐘",
+ minutes: "%d 分鐘",
+ hour: "大約 1 小時",
+ hours: "大約 %d 小時",
+ day: "1 天",
+ days: "%d 天",
+ month: "大約 1 個月",
+ months: "%d 月",
+ year: "大約 1 年",
+ years: "%d 年",
+ numbers: [],
+ wordSeparator: ""
+};
\ No newline at end of file
diff --git a/test/index.html b/test/index.html
index 55207a78..e937d54a 100644
--- a/test/index.html
+++ b/test/index.html
@@ -73,6 +73,9 @@ Other formats
Date only (default tooltip): .
Timestsamp (with millis): (you shouldn't see this) .
+ May 10, 2012
+ May 10, 2012
+
Errors
Bad (letters): (this should be displayed) .
@@ -90,8 +93,9 @@ Parsing
[from +09:00]
[from +0900]
[from blank TZ]
- [from Z with milliseonds]
- [from Z with microseonds]
+ [from Z with milliseconds]
+ [from Z with microseconds]
+ [from Z with tenths of a second]
Wording
@@ -112,12 +116,15 @@ Wording
[120 min]
[1380 min]
[25 hours]
- [48 hours]
+ [41 hours]
+ [42 hours]
+ [48 hours]
[696 hours]
[30 days]
[190 days]
[366 days]
- [1095 days]
+ [725 days]
+ [1095 days]
Settings
@@ -299,6 +306,14 @@ Settings
ok($("#defaultTooltip").attr("title") == "2008-02-26", "correctly set");
});
+ test("should preserve title in time tags", function () {
+ ok(($("#testTimeTitle").attr('title') === "May 10, 2012 10:06"), "title preserved")
+ });
+
+ test("should set title in time tags without a title", function () {
+ ok(($("#testTimeTitle2").attr('title') === "May 10, 2012"), "title set")
+ });
+
module("Parsing");
// Note, different browsers behave slightly different
@@ -340,6 +355,10 @@ Settings
ok(($("#testParsing9").html().match(correctMatch)), "Correctly parsed");
});
+ test("From Z with tenths of a second", function () {
+ ok(($("#testParsing10").html().match(correctMatch)), "Correctly parsed");
+ });
+
module("Wording");
test("-120 min", function () {
@@ -402,8 +421,14 @@ Settings
ok(($("#testWording15").html() === "a day ago"), "Correctly parsed");
});
+ test("41 hour", function () {
+ ok(($("#testWording16a").html() === "a day ago"), "Correctly parsed");
+ });
+ test("42 hours", function () {
+ ok(($("#testWording16b").html() === "2 days ago"), "Correctly parsed");
+ });
test("48 hours", function () {
- ok(($("#testWording16").html() === "2 days ago"), "Correctly parsed");
+ ok(($("#testWording16c").html() === "2 days ago"), "Correctly parsed");
});
test("696 hours", function () {
@@ -422,8 +447,12 @@ Settings
ok(($("#testWording20").html() === "about a year ago"), "Correctly parsed");
});
+ test("725 days", function () {
+ ok(($("#testWording21").html() === "2 years ago"), "Correctly parsed");
+ });
+
test("1095 days", function () {
- ok(($("#testWording21").html() === "3 years ago"), "Correctly parsed");
+ ok(($("#testWording22").html() === "3 years ago"), "Correctly parsed");
});
module("Settings");
diff --git a/test/test_helpers.js b/test/test_helpers.js
index b8cf36a3..78f956e3 100644
--- a/test/test_helpers.js
+++ b/test/test_helpers.js
@@ -36,8 +36,7 @@ function loadPigLatin() {
month: "about-hay a-hay onth-may",
months: "%d onths-may",
year: "about-hay a-hay ear-yay",
- years: "%d years-yay",
- wordSeparator: " "
+ years: "%d years-yay"
};
}
@@ -72,8 +71,7 @@ function loadRussian() {
month: "месяц",
months: function(value) { return numpf(value, "%d месяц", "%d месяца", "%d месяцев"); },
year: "год",
- years: function(value) { return numpf(value, "%d год", "%d года", "%d лет"); },
- wordSeparator: " "
+ years: function(value) { return numpf(value, "%d год", "%d года", "%d лет"); }
};
})();
}