Properly support pluralization in timeago strings

This commit is contained in:
Jonne Haß 2016-07-24 17:40:06 +02:00
parent f91734028c
commit 734f332333
No known key found for this signature in database
GPG key ID: F347E0EB47AC70D6
2 changed files with 27 additions and 10 deletions

View file

@ -7,14 +7,21 @@
(function() { (function() {
Diaspora.Widgets.TimeAgo = function() { Diaspora.Widgets.TimeAgo = function() {
this.subscribe("widget/ready", function() { this.subscribe("widget/ready", function() {
if(Diaspora.I18n.language !== "en") { if (Diaspora.I18n.language !== "en") {
$.timeago.settings.lang = Diaspora.I18n.language; $.timeago.settings.lang = Diaspora.I18n.language;
$.timeago.settings.strings[Diaspora.I18n.language] = {}; $.timeago.settings.strings[Diaspora.I18n.language] = {};
$.each($.timeago.settings.strings["en"], function(index) { $.each($.timeago.settings.strings.en, function(index) {
if(index === "numbers") { if (index === "numbers") {
$.timeago.settings.strings[Diaspora.I18n.language][index] = []; $.timeago.settings.strings[Diaspora.I18n.language][index] = [];
} } else if (index === "minutes" ||
else { index === "hours" ||
index === "days" ||
index === "months" ||
index === "years") {
$.timeago.settings.strings[Diaspora.I18n.language][index] = function(value) {
return Diaspora.I18n.t("timeago." + index, {count: value});
};
} else {
$.timeago.settings.strings[Diaspora.I18n.language][index] = Diaspora.I18n.t("timeago." + index); $.timeago.settings.strings[Diaspora.I18n.language][index] = Diaspora.I18n.t("timeago." + index);
} }
}); });

View file

@ -95,15 +95,25 @@ en:
inPast: "any moment now" inPast: "any moment now"
seconds: "less than a minute" seconds: "less than a minute"
minute: "about a minute" minute: "about a minute"
minutes: "%d minutes" minutes:
one: "1 minute"
other: "%d minutes"
hour: "about an hour" hour: "about an hour"
hours: "about %d hours" hours:
one: "about 1 hour"
other: "about %d hours"
day: "a day" day: "a day"
days: "%d days" days:
one: "1 day"
other: "%d days"
month: "about a month" month: "about a month"
months: "%d months" months:
one: "1 month"
other: "%d months"
year: "about a year" year: "about a year"
years: "%d years" years:
one: "1 year"
other: "%d years"
wordSeparator: " " wordSeparator: " "
contacts: contacts: