forked from ether/ep_comments_page
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luiza Pagliari
committed
May 27, 2015
1 parent
f31c86d
commit a437dbf
Showing
10 changed files
with
322 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"ep_comments_page.comment" : "Comment", | ||
"ep_comments_page.comments" : "Comments", | ||
"ep_comments_page.cancel" : "Cancel", | ||
"ep_comments_page.add_comment.title" : "Add new comment on selection", | ||
"ep_comments_page.show_comments" : "Show Comments", | ||
"ep_comments_page.comments_template.suggested_change" : "Suggested Change:", | ||
"ep_comments_page.comments_template.accept_change" : "Accept Change", | ||
"ep_comments_page.comments_template.suggest_change_from" : "Suggest change From:", | ||
"ep_comments_page.comments_template.to" : "To:", | ||
"ep_comments_page.comments_template.include_suggestion" : "Include suggested change", | ||
"ep_comments_page.time.seconds_ago" : "{{count}} seconds ago", | ||
"ep_comments_page.time.seconds_from_now" : "{{count}} seconds from now", | ||
"ep_comments_page.time.one_minute_ago" : "1 minute ago", | ||
"ep_comments_page.time.one_minute_from_now" : "1 minute from now", | ||
"ep_comments_page.time.minutes_ago" : "{{count}} minutes ago", | ||
"ep_comments_page.time.minutes_from_now" : "{{count}} minutes from now", | ||
"ep_comments_page.time.one_hour_ago" : "1 hour ago", | ||
"ep_comments_page.time.one_hour_from_now" : "1 hour from now", | ||
"ep_comments_page.time.hours_ago" : "{{count}} hours ago", | ||
"ep_comments_page.time.hours_from_now" : "{{count}} hours from now", | ||
"ep_comments_page.time.yesterday" : "yesterday", | ||
"ep_comments_page.time.tomorrow" : "tomorrow", | ||
"ep_comments_page.time.days_ago" : "{{count}} days ago", | ||
"ep_comments_page.time.days_from_now" : "{{count}} days from now", | ||
"ep_comments_page.time.last_week" : "last week", | ||
"ep_comments_page.time.next_week" : "next week", | ||
"ep_comments_page.time.weeks_ago" : "{{count}} weeks ago", | ||
"ep_comments_page.time.weeks_from_now" : "{{count}} weeks from now", | ||
"ep_comments_page.time.last_month" : "last month", | ||
"ep_comments_page.time.next_month" : "next month", | ||
"ep_comments_page.time.months_ago" : "{{count}} months ago", | ||
"ep_comments_page.time.months_from_now" : "{{count}} months from now", | ||
"ep_comments_page.time.last_year" : "last year", | ||
"ep_comments_page.time.next_year" : "next year", | ||
"ep_comments_page.time.years_ago" : "{{count}} years ago", | ||
"ep_comments_page.time.years_from_now" : "{{count}} years from now", | ||
"ep_comments_page.time.last_century" : "last century", | ||
"ep_comments_page.time.next_century" : "next century", | ||
"ep_comments_page.time.centuries_ago" : "{{count}} centuries ago", | ||
"ep_comments_page.time.centuries_from_now" : "{{count}} centuries from now" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
var localizable = typeof html10n !== "undefined"; | ||
|
||
l10nKeys = { | ||
"seconds" : "ep_comments_page.time.seconds", | ||
"1 minute ago" : "ep_comments_page.time.one_minute_ago", | ||
"1 minute from now" : "ep_comments_page.time.one_minute_from_now", | ||
"minutes" : "ep_comments_page.time.minutes", | ||
"1 hour ago" : "ep_comments_page.time.one_hour_ago", | ||
"1 hour from now" : "ep_comments_page.time.one_hour_from_now", | ||
"hours" : "ep_comments_page.time.hours", | ||
"yesterday" : "ep_comments_page.time.yesterday", | ||
"tomorrow" : "ep_comments_page.time.tomorrow", | ||
"days" : "ep_comments_page.time.days", | ||
"last week" : "ep_comments_page.time.last_week", | ||
"next week" : "ep_comments_page.time.next_week", | ||
"weeks" : "ep_comments_page.time.weeks", | ||
"last month" : "ep_comments_page.time.last_month", | ||
"next month" : "ep_comments_page.time.next_month", | ||
"months" : "ep_comments_page.time.months", | ||
"last year" : "ep_comments_page.time.last_year", | ||
"next year" : "ep_comments_page.time.next_year", | ||
"years" : "ep_comments_page.time.years", | ||
"last century" : "ep_comments_page.time.last_century", | ||
"next century" : "ep_comments_page.time.next_century", | ||
"centuries" : "ep_comments_page.time.centuries" | ||
} | ||
|
||
var time_formats = [ | ||
[60, 'seconds', 1], // 60 | ||
[120, '1 minute ago', '1 minute from now'], // 60*2 | ||
[3600, 'minutes', 60], // 60*60, 60 | ||
[7200, '1 hour ago', '1 hour from now'], // 60*60*2 | ||
[86400, 'hours', 3600], // 60*60*24, 60*60 | ||
[172800, 'yesterday', 'tomorrow'], // 60*60*24*2 | ||
[604800, 'days', 86400], // 60*60*24*7, 60*60*24 | ||
[1209600, 'last week', 'next week'], // 60*60*24*7*4*2 | ||
[2419200, 'weeks', 604800], // 60*60*24*7*4, 60*60*24*7 | ||
[4838400, 'last month', 'next month'], // 60*60*24*7*4*2 | ||
[29030400, 'months', 2419200], // 60*60*24*7*4*12, 60*60*24*7*4 | ||
[58060800, 'last year', 'next year'], // 60*60*24*7*4*12*2 | ||
[2903040000, 'years', 29030400], // 60*60*24*7*4*12*100, 60*60*24*7*4*12 | ||
[5806080000, 'last century', 'next century'], // 60*60*24*7*4*12*100*2 | ||
[58060800000, 'centuries', 2903040000] // 60*60*24*7*4*12*100*20, 60*60*24*7*4*12*100 | ||
]; | ||
|
||
function prettyDate(time){ | ||
/* | ||
var time = ('' + date_str).replace(/-/g,"/").replace(/[TZ]/g," ").replace(/^\s\s*/ /*rappel , '').replace(/\s\s*$/, ''); | ||
if(time.substr(time.length-4,1)==".") time =time.substr(0,time.length-4); | ||
*/ | ||
var seconds = (new Date - new Date(time)) / 1000; | ||
var token = 'ago', | ||
list_choice = 1, | ||
l10n_appendix = '_ago'; | ||
|
||
if (seconds < 0) { | ||
seconds = Math.abs(seconds); | ||
token = 'from now'; | ||
l10n_appendix = '_from_now'; | ||
list_choice = 2; | ||
} | ||
|
||
var i = 0, format; | ||
while (format = time_formats[i++]) | ||
if (seconds < format[0]) { | ||
var count = Math.floor(seconds / format[2]); | ||
var formatted_time; | ||
if (localizable) { | ||
var key = l10nKeys[format[list_choice]] + l10n_appendix; | ||
formatted_time = html10n.get(key, { count: count }); | ||
} | ||
|
||
// Wasn't able to localize properly the date, so use the default: | ||
if (formatted_time === undefined) { | ||
if (typeof format[2] == 'string') | ||
formatted_time = format[list_choice]; | ||
else | ||
formatted_time = count + ' ' + format[1] + ' ' + token; | ||
} | ||
return formatted_time; | ||
} | ||
return time; | ||
}; | ||
|
||
exports.prettyDate = prettyDate; |
Oops, something went wrong.