gettext_i18n_rails 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -154,9 +154,10 @@ Contributors
154
154
  ======
155
155
  - [ruby gettext extractor](http://github.com/retoo/ruby_gettext_extractor/tree/master) from [retoo](http://github.com/retoo)
156
156
  - [Paul McMahon](http://github.com/pwim)
157
- - [Duncan Mac-Vicar P](http://duncan.mac-vicar.com/blog/)
158
- - [Ramihajamalala Hery](http://my.rails-royce.org/)
159
- - [J. Pablo Fernández](http://pupeno.com/)
157
+ - [Duncan Mac-Vicar P](http://duncan.mac-vicar.com/blog)
158
+ - [Ramihajamalala Hery](http://my.rails-royce.org)
159
+ - [J. Pablo Fernández](http://pupeno.com)
160
+ - [Anh Hai Trinh](http://blog.onideas.ws)
160
161
 
161
162
  [Michael Grosser](http://pragmatig.wordpress.com)
162
163
  grosser.michael@gmail.com
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gettext_i18n_rails}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2010-07-13}
12
+ s.date = %q{2010-08-10}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
14
  s.files = [
15
15
  ".gitignore",
@@ -10,7 +10,7 @@ if Gem::Version.new(FastGettext::VERSION) < Gem::Version.new("0.4.8")
10
10
  end
11
11
 
12
12
  # include translations into all the places it needs to go...
13
- Object.send(:include,FastGettext::Translation)
13
+ Object.send(:include, FastGettext::Translation)
14
14
 
15
15
  require 'gettext_i18n_rails/backend'
16
16
  I18n.backend = GettextI18nRails::Backend.new
@@ -23,6 +23,7 @@ module GettextI18nRails
23
23
  f.puts "#DO NOT MODIFY! AUTOMATICALLY GENERATED FILE!"
24
24
  end
25
25
  end
26
+ module_function :store_model_attributes
26
27
 
27
28
  class ModelAttributesFinder
28
29
  # options:
@@ -62,9 +62,13 @@ namespace :gettext do
62
62
  desc "write the locale/model_attributes.rb"
63
63
  task :store_model_attributes => :environment do
64
64
  FastGettext.silence_errors
65
+
65
66
  require 'gettext_i18n_rails/model_attributes_finder'
67
+ require 'gettext_i18n_rails/active_record'
68
+
66
69
  storage_file = 'locale/model_attributes.rb'
67
70
  puts "writing model translations to: #{storage_file}"
71
+
68
72
  ignore_tables = [/^sitemap_/, /_versions$/, 'schema_migrations', 'sessions']
69
73
  GettextI18nRails.store_model_attributes(
70
74
  :to => storage_file,
@@ -23,30 +23,45 @@ describe ActiveRecord::Base do
23
23
  FastGettext.current_cache = {}
24
24
  end
25
25
 
26
- it "has a human name that is translated through FastGettext" do
27
- CarSeat.should_receive(:_).with('car seat').and_return('Autositz')
28
- CarSeat.human_name.should == 'Autositz'
26
+ describe :human_name do
27
+ it "is translated through FastGettext" do
28
+ CarSeat.should_receive(:_).with('car seat').and_return('Autositz')
29
+ CarSeat.human_name.should == 'Autositz'
30
+ end
29
31
  end
30
32
 
31
- it "translates attributes through FastGettext" do
32
- CarSeat.should_receive(:s_).with('CarSeat|Seat color').and_return('Sitz farbe')
33
- CarSeat.human_attribute_name(:seat_color).should == 'Sitz farbe'
33
+ describe :human_attribute_name do
34
+ it "translates attributes through FastGettext" do
35
+ CarSeat.should_receive(:s_).with('CarSeat|Seat color').and_return('Sitz farbe')
36
+ CarSeat.human_attribute_name(:seat_color).should == 'Sitz farbe'
37
+ end
34
38
  end
35
39
 
36
- it "translates error messages" do
37
- FastGettext.stub!(:current_repository).and_return('translate me'=>"Übersetz mich!")
38
- FastGettext._('translate me').should == "Übersetz mich!"
39
- c = CarSeat.new
40
- c.valid?
41
- c.errors.on(:seat_color).should == "Übersetz mich!"
42
- end
40
+ describe 'error messages' do
41
+ let(:model){
42
+ c = CarSeat.new
43
+ c.valid?
44
+ c
45
+ }
46
+
47
+ it "translates error messages" do
48
+ FastGettext.stub!(:current_repository).and_return('translate me'=>"Übersetz mich!")
49
+ FastGettext._('translate me').should == "Übersetz mich!"
50
+ model.errors.on(:seat_color).should == "Übersetz mich!"
51
+ end
52
+
53
+ it "translates scoped error messages" do
54
+ pending 'scope is no longer added in 3.x' if ActiveRecord::VERSION::MAJOR >= 3
55
+ FastGettext.stub!(:current_repository).and_return('activerecord.errors.translate me'=>"Übersetz mich!")
56
+ FastGettext._('activerecord.errors.translate me').should == "Übersetz mich!"
57
+ model.errors.on(:seat_color).should == "Übersetz mich!"
58
+ end
43
59
 
44
- it "translates scoped error messages" do
45
- pending 'scope is no longer added in 3.x' if ActiveRecord::VERSION::MAJOR >= 3
46
- FastGettext.stub!(:current_repository).and_return('activerecord.errors.translate me'=>"Übersetz mich!")
47
- FastGettext._('activerecord.errors.translate me').should == "Übersetz mich!"
48
- c = CarSeat.new
49
- c.valid?
50
- c.errors.on(:seat_color).should == "Übersetz mich!"
60
+ it "translates error messages with %{fn}" do
61
+ pending
62
+ FastGettext.stub!(:current_repository).and_return('translate me'=>"Übersetz %{fn} mich!")
63
+ FastGettext._('translate me').should == "Übersetz %{fn} mich!"
64
+ model.errors.on(:seat_color).should == "Übersetz car_seat mich!"
65
+ end
51
66
  end
52
67
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-13 00:00:00 +02:00
17
+ date: 2010-08-10 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency