introduced options.lang + automagic mapping for multiple language support.. #88

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+8 −6
Split
View
@@ -31,7 +31,8 @@
settings: {
refreshMillis: 60000,
allowFuture: false,
- strings: {
+ lang: "en",
+ strings: { "en": {
prefixAgo: null,
prefixFromNow: null,
suffixAgo: "ago",
@@ -49,10 +50,10 @@
years: "%d years",
wordSeparator: " ",
numbers: []
- }
+ }}
},
inWords: function(distanceMillis) {
- var $l = this.settings.strings;
+ var $l = this.settings.strings[this.settings.lang];
var prefix = $l.prefixAgo;
var suffix = $l.suffixAgo;
if (this.settings.allowFuture) {
@@ -127,6 +128,7 @@
}
function prepareData(element) {
+ $t.settings.lang = ($(element).attr('lang')) ? $(element).attr('lang') : $t.settings.lang;
element = $(element);
if (!element.data("timeago")) {
element.data("timeago", { datetime: $t.datetime(element) });
@@ -1,5 +1,5 @@
// German
-jQuery.timeago.settings.strings = {
+jQuery.timeago.settings.strings["de"] = {
prefixAgo: "vor",
prefixFromNow: "in",
suffixAgo: "",
@@ -15,4 +15,4 @@ jQuery.timeago.settings.strings = {
months: "%d Monaten",
year: "etwa einem Jahr",
years: "%d Jahren"
-};
+};
@@ -1,5 +1,5 @@
// English (Template)
-jQuery.timeago.settings.strings = {
+jQuery.timeago.settings.strings["en"] = {
prefixAgo: null,
prefixFromNow: null,
suffixAgo: "ago",