Skip to content

Instantly share code, notes, and snippets.

@jnstq
Forked from rmm5t/README.md
Created February 22, 2012 12:54
Show Gist options
  • Save jnstq/1885008 to your computer and use it in GitHub Desktop.
Save jnstq/1885008 to your computer and use it in GitHub Desktop.
Locale override examples for the timeago jQuery plugin (http://timeago.yarp.com)
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
// 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 سنه"); }
};
})();
// 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 години"
};
// 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"
};
// 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"
};
// 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"
};
// 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"
};
// 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 χρόνια"
};
// 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"
};
// 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.
// 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"
};
// 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 שנים"
};
// 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"
};
// 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 տարի"
};
// 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"
};
// 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"
};
// 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 年"
};
// 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년"
};
// Dutch
jQuery.timeago.settings.strings = {
suffixAgo: "geleden",
suffixFromNow: "vanaf nu",
seconds: "iets minder dan een minuut",
minute: "ongeveer een minuut",
minutes: "%d minuten",
hour: "ongeveer een uur",
hours: "ongeveer %d uren",
day: "een dag",
days: "%d dagen",
month: "ongeveer een maand",
months: "%d maanden",
year: "ongeveer een jaar",
years: "%d jaar"
};
// 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"
};
// 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"); }
};
})();
// 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"
};
// 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"
};
// 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 лет"); }
};
})();
// 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"
};
// 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'
});
// 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 років"); }
};
})();
// 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: []
}
// 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: []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment