<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2,8 +2,12 @@ class DbTranslationLocale &lt; ActiveRecord::Base
   set_table_name &quot;translation_locales&quot;
   acts_as_tree
   belongs_to :creator, :class_name =&gt; &quot;User&quot;, :foreign_key =&gt; &quot;user_id&quot;
-  has_many :translations, :class_name =&gt; &quot;DbTranslation&quot;, :foreign_key =&gt; &quot;locale_id&quot;
-  validates_uniqueness_of :locale
+  has_many :translations, :class_name =&gt; &quot;DbTranslation&quot;, :foreign_key =&gt; &quot;locale_id&quot;, :dependent =&gt; :destroy
+  
+  validates_presence_of :locale
+  validates_uniqueness_of :name
+  
+  before_create :copy_translations_from_parent
   
   def translation_hash
     return @hash unless @hash.nil?
@@ -24,6 +28,45 @@ class DbTranslationLocale &lt; ActiveRecord::Base
   end
   
   def language_tag
-    &quot;#{locale}-x-#{id}&quot;
+    new_record? ? locale : &quot;#{locale}-x-#{id}&quot;
+  end
+  
+  def copy_translations_from(other_locale)
+    other_locale.translations.each do |other_translation|
+      translations &lt;&lt; other_translation.clone
+    end
+  end
+  
+  def self.from_yaml_file(file, locale)
+    data = YAML::load(file)
+
+    translation_locale = DbTranslationLocale.new(:locale =&gt; locale)
+    add_translations_from_yaml(translation_locale, data[locale])
+    translation_locale
+  end
+  
+  def missing_keys(all_keys)
+    all_keys - translations.map {|t| t.key}
+  end
+  
+  def complete?(all_keys)
+    missing_keys(all_keys).empty?
+  end
+  
+  protected
+  
+  def copy_translations_from_parent
+    copy_translations_from(parent) if parent
+  end
+  
+  def self.add_translations_from_yaml(locale, data, prefix = nil)
+    data.each do |key, value|
+      full_key = prefix.nil? ? key : &quot;#{prefix}.#{key}&quot;
+      if value.is_a?(Hash)
+        add_translations_from_yaml(locale, value, full_key)
+      else
+        locale.translations.build(:key =&gt; full_key, :value =&gt; value)
+      end
+    end
   end
 end</diff>
      <filename>lib/globalize/backend/db/db_translation_locale.rb</filename>
    </modified>
    <modified>
      <diff>@@ -46,6 +46,8 @@ module Globalize
             result.map do |value|
               translation(value, meta)
             end
+          when Symbol
+            result
           else
             raise &quot;unexpected translation type: #{result.inspect}&quot;
           end</diff>
      <filename>lib/globalize/backend/static.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e518e7916bf362810958f8f7b4f74688edee2d82</id>
    </parent>
  </parents>
  <author>
    <name>Mick Staugaard</name>
    <email>spam@staugaard.com</email>
  </author>
  <url>http://github.com/hchoroomi/globalize2/commit/b6a2a0d0b4653f33d1d6f62e019015976da75cf3</url>
  <id>b6a2a0d0b4653f33d1d6f62e019015976da75cf3</id>
  <committed-date>2009-01-05T04:27:53-08:00</committed-date>
  <authored-date>2009-01-05T04:27:53-08:00</authored-date>
  <message>when creating a new locale with a parent, the parent translations are now copied to the new locale</message>
  <tree>77f1f8b9990448afb76f0e3802f68ee30c25b39b</tree>
  <committer>
    <name>Mick Staugaard</name>
    <email>spam@staugaard.com</email>
  </committer>
</commit>
