From 921a658548faa114b210b56e7064530f1de1e7c6 Mon Sep 17 00:00:00 2001
From: Kuba Brecka <kuba.brecka@gmail.com>
Date: Wed, 13 Mar 2013 13:38:41 +0100
Subject: [PATCH] move date formatting from server side to javascript, so we
 can reuse Sugar's i18n

---
 .../javascripts/discourse/views/modal/history_view.js       | 5 +++++
 app/serializers/version_serializer.rb                       | 6 +-----
 config/locales/client.en.yml                                | 1 +
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/app/assets/javascripts/discourse/views/modal/history_view.js b/app/assets/javascripts/discourse/views/modal/history_view.js
index 36a48c8dcbe..a31a6310f33 100644
--- a/app/assets/javascripts/discourse/views/modal/history_view.js
+++ b/app/assets/javascripts/discourse/views/modal/history_view.js
@@ -41,6 +41,11 @@ Discourse.HistoryView = Discourse.View.extend({
     this.set('postLeft', null);
     this.set('postRight', null);
     return this.get('originalPost').loadVersions(function(result) {
+      result.each(function(item) {
+        item.description = "v" + item.number + " - " + Date.create(item.created_at).relative() + " - " +
+          Em.String.i18n("changed_by", { author: item.display_username });
+      });
+
       _this.set('loading', false);
       _this.set('versionLeft', result.first());
       _this.set('versionRight', result.last());
diff --git a/app/serializers/version_serializer.rb b/app/serializers/version_serializer.rb
index d83e2722a79..a5d4f639712 100644
--- a/app/serializers/version_serializer.rb
+++ b/app/serializers/version_serializer.rb
@@ -1,6 +1,6 @@
 class VersionSerializer < ApplicationSerializer
 
-  attributes :number, :display_username, :created_at, :description
+  attributes :number, :display_username, :created_at
 
   def number
     object[:number]
@@ -14,8 +14,4 @@ class VersionSerializer < ApplicationSerializer
     object[:created_at]
   end
 
-  def description
-    "v#{object[:number]} - #{FreedomPatches::Rails4.time_ago_in_words(object[:created_at])} ago by #{object[:display_username]}"
-  end
-
 end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index e0214edfba6..53f52cc3785 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -629,6 +629,7 @@ en:
     top_contributors: "Participants"
     category_title: "Category"
     history: "History"
+    changed_by: "by {{author}}"
 
     categories_list: "Categories List"