Permalink
Browse files

introduced options.lang + automagic mapping for multiple language sup…

…port.
  • Loading branch information...
1 parent dee2f91 commit 213ff0568abf28bec4d564086051d0f88d27e97b @eFrane committed Aug 13, 2012
Showing with 8 additions and 6 deletions.
  1. +5 −3 jquery.timeago.js
  2. +2 −2 locales/jquery.timeago.de.js
  3. +1 −1 locales/jquery.timeago.en.js
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",

0 comments on commit 213ff05

Please sign in to comment.