<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -5,14 +5,22 @@ require 'globalize/model/active_record/translated'
 
 module Globalize
   module Model
-    module ActiveRecord        
-      class &lt;&lt; self        
+    module ActiveRecord
+      class &lt;&lt; self
         def create_proxy_class(klass)
           Object.const_set &quot;#{klass.name}Translation&quot;, Class.new(::ActiveRecord::Base){
             belongs_to &quot;#{klass.name.underscore}&quot;.intern
+            
+            def locale
+              read_attribute(:locale).to_sym
+            end
+            
+            def locale=(locale)
+              write_attribute(:locale, locale.to_s)
+            end
           }
         end
-        
+
         def define_accessors(klass, attr_names)
           attr_names.each do |attr_name|
             klass.send :define_method, attr_name, lambda {
@@ -21,7 +29,7 @@ module Globalize
             klass.send :define_method, &quot;#{attr_name}=&quot;, lambda {|val|
               globalize.stash I18n.locale, attr_name, val
             }
-          end 
+          end
         end
       end
     end</diff>
      <filename>lib/globalize/model/active_record.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,11 +2,13 @@ module Globalize
   module Model
     class AttributeStash &lt; Hash
       def read(locale, attr_name)
+        locale = locale.to_sym
         self[locale] ||= {}
         self[locale][attr_name]
       end
       
       def write(locale, attr_name, value)
+        locale = locale.to_sym
         self[locale] ||= {}
         self[locale][attr_name] = value
       end
@@ -20,7 +22,7 @@ module Globalize
       end
       
       def fetch(locale, attr_name)
-        locale = I18n.locale 
+        # locale = I18n.locale
         @cache.read(locale, attr_name) || begin
           value = fetch_attribute locale, attr_name
           @cache.write locale, attr_name, value
@@ -33,7 +35,7 @@ module Globalize
       
       def update_translations!
         @stash.each do |locale, attrs|
-          translation = @record.globalize_translations.find_or_initialize_by_locale(locale)
+          translation = @record.globalize_translations.find_or_initialize_by_locale(locale.to_s)
           attrs.each{|attr_name, value| translation[attr_name] = value }
           translation.save!
         end
@@ -42,7 +44,7 @@ module Globalize
       private
       
       def fetch_attribute(locale, attr_name)
-        fallbacks = I18n.fallbacks[locale].map{|tag| tag.to_s}
+        fallbacks = I18n.fallbacks[locale].map{|tag| tag.to_s}.map(&amp;:to_sym)
         translations = @record.globalize_translations.by_locales(fallbacks)
         result, requested_locale = nil, locale
       </diff>
      <filename>lib/globalize/model/active_record/adapter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,7 +19,7 @@ module Globalize
               proxy_class = Globalize::Model::ActiveRecord.create_proxy_class(self)
               has_many :globalize_translations, :class_name =&gt; proxy_class.name do
                 def by_locales(locales)
-                  find :all, :conditions =&gt; { :locale =&gt; locales }
+                  find :all, :conditions =&gt; { :locale =&gt; locales.map(&amp;:to_s) }
                 end
               end
 </diff>
      <filename>lib/globalize/model/active_record/translated.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,174 +14,179 @@ describe Globalize::Model::ActiveRecord::Translated, 'in the guise of a Post obj
   include Spec::Matchers::HaveAttribute
   include Spec::Helpers::ActiveRecord
 
-  before do
-    I18n.locale = 'en-US'
-    I18n.fallbacks.clear 
-    reset_db
-  end
-
-  it &quot;has post_translations&quot; do
-    post = Post.create
-    lambda { post.globalize_translations }.should_not raise_error
-  end
-
-  it &quot;returns the value passed to :subject&quot; do
-    post = Post.new
-    (post.subject = 'foo').should == 'foo'
-  end
-
-  it &quot;translates subject and content into en-US&quot; do
-    post = Post.create :subject =&gt; 'foo', :content =&gt; 'bar'
-    post.subject.should == 'foo'
-    post.content.should == 'bar'
-    post.save.should == true
-    post.reload
-    post.subject.should == 'foo'
-    post.content.should == 'bar'
-  end
-
-  it &quot;finds a German post&quot; do
-    post = Post.create :subject =&gt; 'foo', :content =&gt; 'bar'
-    I18n.locale = 'de-DE'
-    post = Post.first
-    post.subject = 'baz'
-    post.save
-    Post.first.subject.should == 'baz'
-    I18n.locale = 'en-US'
-    Post.first.subject.should == 'foo'
-  end
 
-  it &quot;saves an English post and loads it correctly&quot; do
-    Post.first.should == nil
-    post = Post.create :subject =&gt; 'foo', :content =&gt; 'bar'
-    post.save.should == true
-    post = Post.first
-    post.subject.should == 'foo'
-    post.content.should == 'bar'
-  end
-
-  it &quot;updates an attribute&quot; do
-    post = Post.create :subject =&gt; 'foo', :content =&gt; 'bar'
-    post.update_attribute :subject, 'baz'
-    Post.first.subject.should == 'baz'
-  end
-
-  it &quot;validates presence of :subject&quot; do
-    class Post
-      validates_presence_of :subject
+  [:'en-US', 'en-US'].each do |locale|
+    describe &quot;(with the current locale being a #{locale.class.name})&quot; do
+      before do
+        I18n.locale = locale
+        I18n.fallbacks.clear 
+        reset_db
+      end
+
+      it &quot;has post_translations&quot; do
+        post = Post.create
+        lambda { post.globalize_translations }.should_not raise_error
+      end
+  
+      it &quot;returns the value passed to :subject&quot; do
+        post = Post.new
+        (post.subject = 'foo').should == 'foo'
+      end
+  
+      it &quot;translates subject and content into en-US&quot; do
+        post = Post.create :subject =&gt; 'foo', :content =&gt; 'bar'
+        post.subject.should == 'foo'
+        post.content.should == 'bar'
+        post.save.should == true
+        post.reload
+        post.subject.should == 'foo'
+        post.content.should == 'bar'
+      end
+  
+      it &quot;finds a German post&quot; do
+        post = Post.create :subject =&gt; 'foo (en)', :content =&gt; 'bar'
+        I18n.locale = 'de-DE'
+        post = Post.first
+        post.subject = 'baz (de)'
+        post.save
+        Post.first.subject.should == 'baz (de)'
+        I18n.locale = :'en-US'
+        Post.first.subject.should == 'foo (en)'
+      end
+  
+      it &quot;saves an English post and loads it correctly&quot; do
+        Post.first.should == nil
+        post = Post.create :subject =&gt; 'foo', :content =&gt; 'bar'
+        post.save.should == true
+        post = Post.first
+        post.subject.should == 'foo'
+        post.content.should == 'bar'
+      end
+  
+      it &quot;updates an attribute&quot; do
+        post = Post.create :subject =&gt; 'foo', :content =&gt; 'bar'
+        post.update_attribute :subject, 'baz'
+        Post.first.subject.should == 'baz'
+      end
+  
+      it &quot;validates presence of :subject&quot; do
+        class Post
+          validates_presence_of :subject
+        end
+  
+        post = Post.new
+        post.save.should == false
+  
+        post = Post.new :subject =&gt; 'foo'
+        post.save.should == true
+      end
+
+      it &quot;returns the value for the correct locale, after locale switching&quot; do
+        post = Post.create :subject =&gt; 'foo'
+        I18n.locale = 'de-DE'
+        post.subject = 'bar'
+        post.save
+        I18n.locale = 'en-US'
+        post = Post.first
+        post.subject.should == 'foo'
+        I18n.locale = 'de-DE'
+        post.subject.should == 'bar'
+      end
+  
+      it &quot;returns the value for the correct locale, after locale switching, without saving&quot; do
+        post = Post.create :subject =&gt; 'foo'
+        I18n.locale = 'de-DE'
+        post.subject = 'bar'
+        I18n.locale = 'en-US'
+        post.subject.should == 'foo'
+        I18n.locale = 'de-DE'
+        post.subject.should == 'bar'
+      end
+  
+      it &quot;saves all locales, even after locale switching&quot; do
+        post = Post.new :subject =&gt; 'foo'
+        I18n.locale = 'de-DE'
+        post.subject = 'bar'
+        I18n.locale = 'he-IL'
+        post.subject = 'baz'
+        post.save
+        I18n.locale = 'en-US'
+        post = Post.first
+        post.subject.should == 'foo'
+        I18n.locale = 'de-DE'
+        post.subject.should == 'bar'
+        I18n.locale = 'he-IL'
+        post.subject.should == 'baz'
+      end
+  
+      it &quot;resolves a simple fallback&quot; do
+        I18n.locale = 'de-DE'
+        post = Post.create :subject =&gt; 'foo'
+        I18n.locale = 'de'
+        post.subject = 'baz'
+        post.content = 'bar'
+        post.save
+        I18n.locale = 'de-DE'
+        post.subject.should == 'foo'
+        post.content.should == 'bar'
+      end
+  
+      it &quot;resolves a simple fallback without reloading&quot; do
+        I18n.locale = 'de-DE'
+        post = Post.new :subject =&gt; 'foo'
+        I18n.locale = 'de'
+        post.subject = 'baz'
+        post.content = 'bar'
+        I18n.locale = 'de-DE'
+        post.subject.should == 'foo'
+        post.content.should == 'bar'
+      end
+  
+      it &quot;resolves a complex fallback without reloading&quot; do
+        I18n.fallbacks.map 'de' =&gt; %w(en he)
+        I18n.locale = 'de'
+        post = Post.new
+        I18n.locale = 'en'
+        post.subject = 'foo'
+        I18n.locale = 'he'
+        post.subject = 'baz'
+        post.content = 'bar'
+        I18n.locale = 'de'
+        post.subject.should == 'foo'
+        post.content.should == 'bar'
+      end
+  
+      it &quot;returns nil if no translations are found&quot; do
+        post = Post.new :subject =&gt; 'foo'
+        post.subject.should == 'foo'
+        post.content.should be_nil
+      end
+  
+      it &quot;returns nil if no translations are found; reloaded&quot; do
+        post = Post.create :subject =&gt; 'foo'
+        post = Post.first
+        post.subject.should == 'foo'
+        post.content.should be_nil
+      end
+  
+      it &quot;works with associations&quot; do
+        blog = Blog.create
+        post1 = blog.posts.create :subject =&gt; 'foo'
+        I18n.locale = 'de-DE'
+        post2 = blog.posts.create :subject =&gt; 'bar'
+        blog.posts.size.should == 2
+        I18n.locale = 'en-US'
+        blog.posts.first.subject == 'foo'
+        blog.posts.last.subject.should be_nil
+        I18n.locale = 'de-DE'
+        blog.posts.last.subject.should == 'bar'
+      end
     end
-
-    post = Post.new
-    post.save.should == false
-
-    post = Post.new :subject =&gt; 'foo'
-    post.save.should == true
-  end
-
-  it &quot;returns the value for the correct locale, after locale switching&quot; do
-    post = Post.create :subject =&gt; 'foo'
-    I18n.locale = 'de-DE'
-    post.subject = 'bar'
-    post.save
-    I18n.locale = 'en-US'
-    post = Post.first
-    post.subject.should == 'foo'
-    I18n.locale = 'de-DE'
-    post.subject.should == 'bar'
-  end
-
-  it &quot;returns the value for the correct locale, after locale switching, without saving&quot; do
-    post = Post.create :subject =&gt; 'foo'
-    I18n.locale = 'de-DE'
-    post.subject = 'bar'
-    I18n.locale = 'en-US'
-    post.subject.should == 'foo'
-    I18n.locale = 'de-DE'
-    post.subject.should == 'bar'
-  end
-
-  it &quot;saves all locales, even after locale switching&quot; do
-    post = Post.new :subject =&gt; 'foo'
-    I18n.locale = 'de-DE'
-    post.subject = 'bar'
-    I18n.locale = 'he-IL'
-    post.subject = 'baz'
-    post.save
-    I18n.locale = 'en-US'
-    post = Post.first
-    post.subject.should == 'foo'
-    I18n.locale = 'de-DE'
-    post.subject.should == 'bar'
-    I18n.locale = 'he-IL'
-    post.subject.should == 'baz'
-  end
-
-  it &quot;resolves a simple fallback&quot; do
-    I18n.locale = 'de-DE'
-    post = Post.create :subject =&gt; 'foo'
-    I18n.locale = 'de'
-    post.subject = 'baz'
-    post.content = 'bar'
-    post.save
-    I18n.locale = 'de-DE'
-    post.subject.should == 'foo'
-    post.content.should == 'bar'
-  end
-
-  it &quot;resolves a simple fallback without reloading&quot; do
-    I18n.locale = 'de-DE'
-    post = Post.new :subject =&gt; 'foo'
-    I18n.locale = 'de'
-    post.subject = 'baz'
-    post.content = 'bar'
-    I18n.locale = 'de-DE'
-    post.subject.should == 'foo'
-    post.content.should == 'bar'
-  end
-
-  it &quot;resolves a complex fallback without reloading&quot; do
-    I18n.fallbacks.map 'de' =&gt; %w(en he)
-    I18n.locale = 'de'
-    post = Post.new
-    I18n.locale = 'en'
-    post.subject = 'foo'
-    I18n.locale = 'he'
-    post.subject = 'baz'
-    post.content = 'bar'
-    I18n.locale = 'de'
-    post.subject.should == 'foo'
-    post.content.should == 'bar'
-  end
-
-  it &quot;returns nil if no translations are found&quot; do
-    post = Post.new :subject =&gt; 'foo'
-    post.subject.should == 'foo'
-    post.content.should be_nil
-  end
-
-  it &quot;returns nil if no translations are found; reloaded&quot; do
-    post = Post.create :subject =&gt; 'foo'
-    post = Post.first
-    post.subject.should == 'foo'
-    post.content.should be_nil
-  end
-
-  it &quot;works with associations&quot; do
-    blog = Blog.create
-    post1 = blog.posts.create :subject =&gt; 'foo'
-    I18n.locale = 'de-DE'
-    post2 = blog.posts.create :subject =&gt; 'bar'
-    blog.posts.size.should == 2
-    I18n.locale = 'en-US'
-    blog.posts.first.subject == 'foo'
-    blog.posts.last.subject.should be_nil
-    I18n.locale = 'de-DE'
-    blog.posts.last.subject.should == 'bar'
   end
 
   # TODO error checking for fields that exist in main table, don't exist in
   # proxy table, aren't strings or text
-
+  # 
   # TODO allow finding by translated attributes in conditions?
   # TODO generate dynamic finders?
 end</diff>
      <filename>spec/model/active_record/translated_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3f30bb6cd54bc9facf584bf9b67cc1b01580762f</id>
    </parent>
  </parents>
  <author>
    <name>Sven Fuchs</name>
    <email>svenfuchs@artweb-design.de</email>
  </author>
  <url>http://github.com/hchoroomi/globalize2/commit/d63e851d1a371e6a6583bc64867fb1b50c85c474</url>
  <id>d63e851d1a371e6a6583bc64867fb1b50c85c474</id>
  <committed-date>2008-11-17T10:58:47-08:00</committed-date>
  <authored-date>2008-11-17T10:58:47-08:00</authored-date>
  <message>make model translations always save the locale as a string and always return it as a symbol</message>
  <tree>ea62596b9c55c272f390ffb7efc9812fae371aff</tree>
  <committer>
    <name>Sven Fuchs</name>
    <email>svenfuchs@artweb-design.de</email>
  </committer>
</commit>
