Skip to content

Commit

Permalink
Fixed #7. Add the prefix's ago support. And update hte version to 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
poshboytl committed Aug 24, 2012
1 parent 6f104ff commit 3febf13
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lib/locales/timeago.en.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/locales/timeago.es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/locales/timeago.fr.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/locales/timeago.pt-br.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/locales/timeago.zh-cn.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions lib/timeago.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// https://pragmatic.ly/
// Licensed under the MIT license.
// https://github.com/pragmaticly/smart-time-ago/blob/master/LICENSE

//
// Generated by CoffeeScript 1.3.3

(function() {
var TimeAgo;

Expand Down Expand Up @@ -83,7 +84,7 @@
TimeAgo.prototype.timeAgoInWords = function(timeString) {
var absolutTime;
absolutTime = this.parse(timeString);
return this.distanceOfTimeInWords(absolutTime) + ("" + this.options.lang.suffix);
return "" + this.options.lang.prefixes.ago + (this.distanceOfTimeInWords(absolutTime)) + this.options.lang.suffix;
};

TimeAgo.prototype.parse = function(iso8601) {
Expand Down Expand Up @@ -184,7 +185,8 @@
lt: "less than a",
about: "about",
over: "over",
almost: "almost"
almost: "almost",
ago: ""
},
suffix: ' ago'
}
Expand Down
1 change: 1 addition & 0 deletions src/locales/timeago.en.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ $.fn.timeago.defaults.lang =
about: "about"
over: "over"
almost: "almost"
ago: ""
suffix: " ago"
1 change: 1 addition & 0 deletions src/locales/timeago.es.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ $.fn.timeago.defaults.lang =
about: "cerca de"
over: "poco más de"
almost: "casi"
ago: "hace "
suffix: ""

1 change: 1 addition & 0 deletions src/locales/timeago.fr.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ $.fn.timeago.defaults.lang =
about: "environ"
over: "plus de "
almost: "presque"
ago: "il y a "
suffix: ""
1 change: 1 addition & 0 deletions src/locales/timeago.pt-br.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ $.fn.timeago.defaults.lang =
about: "aproximadamente"
over: "pouco mais de"
almost: "quase"
ago: ""
suffix: " atrás"
1 change: 1 addition & 0 deletions src/locales/timeago.zh-cn.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ $.fn.timeago.defaults.lang =
about: "大约"
over: "超过"
almost: "接近"
ago: ""
suffix: "之前"
5 changes: 3 additions & 2 deletions src/timeago.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Smart Time Ago v0.1.0
# Smart Time Ago v0.1.1

# Copyright 2012, Terry Tai, Pragmatic.ly
# https://pragmatic.ly/
Expand Down Expand Up @@ -65,7 +65,7 @@ class TimeAgo

timeAgoInWords: (timeString) ->
absolutTime = @parse(timeString)
@distanceOfTimeInWords(absolutTime) + "#{@options.lang.suffix}"
"#{@options.lang.prefixes.ago}#{@distanceOfTimeInWords(absolutTime)}#{@options.lang.suffix}"

parse: (iso8601) ->
timeStr = $.trim(iso8601)
Expand Down Expand Up @@ -147,5 +147,6 @@ $.fn.timeago.defaults =
about: "about"
over: "over"
almost: "almost"
ago: ""
suffix: ' ago'

0 comments on commit 3febf13

Please sign in to comment.