globalize3 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2008, 2009 Joshua Harvey
3
+ Copyright (c) 2008, 2009, 2010 Sven Fuchs, Joshua Harvey, Clemens Kofler, John-Paul Bader
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.textile CHANGED
@@ -1,10 +1,8 @@
1
1
  h1. Globalize3
2
2
 
3
- Globalize3 is the successor of Globalize for Rails. Globalize is targeted at ActiveRecord 3.
3
+ Globalize3 is the successor of Globalize for Rails. Globalize is targeted at ActiveRecord 3. It is compatible with and builds on the new "I18n api in Ruby on Rails":http://guides.rubyonrails.org/i18n.html and adds model translations to ActiveRecord.
4
4
 
5
- It is compatible with and builds on the new "I18n api in Ruby on Rails":http://guides.rubyonrails.org/i18n.html. and adds model translations to ActiveRecord.
6
-
7
- Globalize3 is much more lightweight and compatible than its predecessor was. Model translations in Globalize3 use default ActiveRecord features and do not limit any ActiveRecord functionality any more.
5
+ Globalize3 is much more lightweight and compatible than its predecessor Globalize for Rails was. Model translations in Globalize3 use default ActiveRecord features and do not limit any ActiveRecord functionality any more.
8
6
 
9
7
  h2. Requirements
10
8
 
@@ -29,7 +27,7 @@ class Post < ActiveRecord::Base
29
27
  end
30
28
  </code></pre>
31
29
 
32
- Allows you to values for the attributes :title and :text per locale:
30
+ Allows you to translate the attributes :title and :text per locale:
33
31
 
34
32
  <pre><code>
35
33
  I18n.locale = :en
@@ -58,7 +58,7 @@ module Globalize
58
58
  def method_missing(method, *args)
59
59
  if method.to_s =~ /^find_(first_|)by_(\w+)$/ && translated_attribute_names.include?($2.to_sym)
60
60
  result = with_translated_attribute($2, args.first)
61
- $1 == 'first_' ? result.first : result
61
+ $1 == 'first_' ? result.first : result.all
62
62
  else
63
63
  super
64
64
  end
@@ -12,17 +12,17 @@ module Globalize
12
12
  end
13
13
 
14
14
  def attributes=(attributes, *args)
15
- if locale = attributes.try(:delete, :locale)
16
- Globalize.with_locale(locale) { super }
17
- else
18
- super
19
- end
15
+ with_given_locale(attributes) { super }
16
+ end
17
+
18
+ def update_attributes(attributes, *args)
19
+ with_given_locale(attributes) { super }
20
20
  end
21
21
 
22
22
  def attribute_names
23
23
  translated_attribute_names.map(&:to_s) + super
24
24
  end
25
-
25
+
26
26
  def translated_attributes
27
27
  translated_attribute_names.inject({}) do |attributes, name|
28
28
  attributes.merge(name.to_s => send(name))
@@ -48,6 +48,14 @@ module Globalize
48
48
  def save_translations!
49
49
  globalize.save_translations!
50
50
  end
51
+
52
+ def with_given_locale(attributes, &block)
53
+ if locale = attributes.try(:delete, :locale)
54
+ Globalize.with_locale(locale, &block)
55
+ else
56
+ yield
57
+ end
58
+ end
51
59
  end
52
60
  end
53
61
  end
@@ -1,3 +1,3 @@
1
1
  module Globalize
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/globalize3.rb ADDED
@@ -0,0 +1 @@
1
+ require 'globalize'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: globalize3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sven Fuchs
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-07-31 00:00:00 +02:00
21
+ date: 2010-08-02 00:00:00 +02:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -57,13 +57,13 @@ files:
57
57
  - lib/globalize/active_record.rb
58
58
  - lib/globalize/version.rb
59
59
  - lib/globalize.rb
60
+ - lib/globalize3.rb
60
61
  - lib/i18n/missing_translations_log_handler.rb
61
62
  - lib/i18n/missing_translations_raise_handler.rb
62
63
  - lib/patches/active_record/xml_attribute_serializer.rb
63
64
  - LICENSE
64
65
  - Rakefile
65
66
  - README.textile
66
- - VERSION
67
67
  has_rdoc: true
68
68
  homepage: http://github.com/svenfuchs/globlize3
69
69
  licenses: []
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.1