<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
    <added>
      <filename>lib/translate/file.rb</filename>
    </added>
    <added>
      <filename>lib/translate/log.rb</filename>
    </added>
    <added>
      <filename>spec/file_spec.rb</filename>
    </added>
    <added>
      <filename>spec/log_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -6,30 +6,15 @@ class Translate::Storage
   end
   
   def write_to_file
-    File.open(file_path, &quot;w&quot;) do |file|
-      file.puts yaml
-    end
+    Translate::File.new(file_path).write(keys)
   end
   
   private
-  def yaml
-    # Stringifying keys for prettier YAML
-    messages = deep_stringify_keys({
-      locale.to_s =&gt; I18n.backend.send(:translations)[locale]
-    })
-    # Using ya2yaml, if available, for UTF8 support
-    messages.respond_to?(:ya2yaml) ? messages.ya2yaml(:escape_as_utf8 =&gt; true) : messages.to_yaml
+  def keys
+    {locale =&gt; I18n.backend.send(:translations)[locale]}
   end
   
   def file_path
     File.join(Rails.root, &quot;config&quot;, &quot;locales&quot;, &quot;#{locale}.yml&quot;)
   end
-  
-  def deep_stringify_keys(hash)
-    hash.inject({}) { |result, (key, value)|
-      value = deep_stringify_keys(value) if value.is_a? Hash
-      result[(key.to_s rescue key) || key] = value
-      result
-    }
-  end
 end</diff>
      <filename>lib/translate/storage.rb</filename>
    </modified>
    <modified>
      <diff>@@ -17,8 +17,10 @@ class TranslateController &lt; ActionController::Base
   end
   
   def translate
-    I18n.backend.store_translations(@to_locale, Translate::Keys.to_deep_hash(params[:key]))
+    translations = Translate::Keys.to_deep_hash(params[:key])
+    I18n.backend.store_translations(@to_locale, translations)
     Translate::Storage.new(@to_locale).write_to_file
+    Translate::Log.new(@from_locale, @to_locale, translations).write_to_file
     force_init_translations # Force reload from YAML file
     flash[:notice] = &quot;Translations stored&quot;
     redirect_to params.slice(:filter, :sort_by, :key_type, :key_pattern, :text_type, :text_pattern).merge({:action =&gt; :index})</diff>
      <filename>lib/translate_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -89,17 +89,21 @@ describe TranslateController do
   
   describe &quot;translate&quot; do
     it &quot;should store translations to I18n backend and then write them to a YAML file&quot; do
-      I18n.backend.should_receive(:store_translations).with(:en, {
+      translations = {
         :articles =&gt; {
           :new =&gt; {
             :title =&gt; &quot;New Article&quot;
           }
         },
         :category =&gt; &quot;Category&quot;
-      })
+      }
+      I18n.backend.should_receive(:store_translations).with(:en, translations)
       storage = mock(:storage)
       storage.should_receive(:write_to_file)
       Translate::Storage.should_receive(:new).with(:en).and_return(storage)
+      log = mock(:log)
+      log.should_receive(:write_to_file)
+      Translate::Log.should_receive(:new).with(:sv, :en, translations).and_return(log)
       post :translate, &quot;key&quot; =&gt; {'articles.new.title' =&gt; &quot;New Article&quot;, &quot;category&quot; =&gt; &quot;Category&quot;}
       response.should be_redirect
     end</diff>
      <filename>spec/controllers/translate_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,3 @@
-require 'fileutils'
 require File.dirname(__FILE__) + '/spec_helper'
 
 describe Translate::Storage do
@@ -6,22 +5,16 @@ describe Translate::Storage do
     before(:each) do
       @storage = Translate::Storage.new(:en)
     end
-
-    after(:each) do
-      FileUtils.rm(file_path)
-    end
-    
+  
     it &quot;writes all I18n messages for a locale to YAML file&quot; do
       I18n.backend.should_receive(:translations).and_return(translations)
       @storage.stub!(:file_path).and_return(file_path)
+      file = mock(:file)
+      file.should_receive(:write).with(translations)
+      Translate::File.should_receive(:new).with(file_path).and_return(file)
       @storage.write_to_file
-      load_yaml(file_path).should == @storage.send(:deep_stringify_keys, translations)
-    end
-
-    def load_yaml(filename)
-      YAML::load(IO.read(filename))
     end
-    
+  
     def file_path
       File.join(File.dirname(__FILE__), &quot;files&quot;, &quot;en.yml&quot;)
     end
@@ -37,28 +30,4 @@ describe Translate::Storage do
       }
     end
   end
-  
-  describe &quot;deep_stringify_keys&quot; do
-    before(:each) do
-      @storage = Translate::Storage.new(:en)
-    end
-
-    it &quot;should convert all keys in a hash to strings&quot; do
-      @storage.send(:deep_stringify_keys, {
-        :en =&gt; {
-          :article =&gt; {
-            :title =&gt; &quot;One Article&quot;
-          },
-          :category =&gt; &quot;Category&quot;
-        }
-      }).should == {
-        &quot;en&quot; =&gt; {
-          &quot;article&quot; =&gt; {
-            &quot;title&quot; =&gt; &quot;One Article&quot;
-          },
-          &quot;category&quot; =&gt; &quot;Category&quot;
-        }
-      }
-    end
-  end
 end</diff>
      <filename>spec/storage_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9f0260762a912c01a7970d35255a3cc016ef437e</id>
    </parent>
  </parents>
  <author>
    <name>Peter Marklund</name>
    <email>peter_marklund@fastmail.fm</email>
  </author>
  <url>http://github.com/newsdesk/translate/commit/900665411a7ab5d6c3b8f30f1636185efbbae8c8</url>
  <id>900665411a7ab5d6c3b8f30f1636185efbbae8c8</id>
  <committed-date>2009-03-19T05:07:47-07:00</committed-date>
  <authored-date>2009-03-19T05:07:47-07:00</authored-date>
  <message>Logging which text a translation was translated from. This will enable us to deal with text changes in texts in the from locale</message>
  <tree>ee80b63ccda1093bf1241f4e9845b7453b7a34ad</tree>
  <committer>
    <name>Peter Marklund</name>
    <email>peter_marklund@fastmail.fm</email>
  </committer>
</commit>
