gettext_i18n_rails 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gettext_i18n_rails (0.9.1)
4
+ gettext_i18n_rails (0.9.2)
5
5
  fast_gettext (>= 0.4.8)
6
6
 
7
7
  GEM
data/Readme.md CHANGED
@@ -231,6 +231,8 @@ If want to use your .PO files on client side javascript you should have a look a
231
231
  - [Ramón Cahenzli](https://github.com/psy-q)
232
232
  - [rustygeldmacher](https://github.com/rustygeldmacher)
233
233
  - [Jeroen Knoops](https://github.com/JeroenKnoops)
234
+ - [Ivan Necas](https://github.com/iNecas)
235
+ - [Andrey Chernih](https://github.com/AndreyChernyh)
234
236
 
235
237
  [Michael Grosser](http://grosser.it)<br/>
236
238
  grosser.michael@gmail.com<br/>
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/gettext_i18n_rails
3
3
  specs:
4
- gettext_i18n_rails (0.9.0)
4
+ gettext_i18n_rails (0.9.1)
5
5
  fast_gettext (>= 0.4.8)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/gettext_i18n_rails
3
3
  specs:
4
- gettext_i18n_rails (0.9.0)
4
+ gettext_i18n_rails (0.9.1)
5
5
  fast_gettext (>= 0.4.8)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/gettext_i18n_rails
3
3
  specs:
4
- gettext_i18n_rails (0.9.0)
4
+ gettext_i18n_rails (0.9.1)
5
5
  fast_gettext (>= 0.4.8)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/gettext_i18n_rails
3
3
  specs:
4
- gettext_i18n_rails (0.9.0)
4
+ gettext_i18n_rails (0.9.1)
5
5
  fast_gettext (>= 0.4.8)
6
6
 
7
7
  GEM
@@ -1,28 +1,2 @@
1
- module ActiveModel
2
- class Name < String
3
- def human(options={})
4
- _(@klass.humanize_class_name)
5
- end
6
- end
7
-
8
- module Translation
9
- # CarDealer.sales_count -> s_('CarDealer|Sales count') -> 'Sales count' if no translation was found
10
- def human_attribute_name(attribute, *args)
11
- s_(gettext_translation_for_attribute_name(attribute))
12
- end
13
-
14
- def gettext_translation_for_attribute_name(attribute)
15
- attribute = attribute.to_s
16
- if attribute.ends_with?('_id')
17
- humanize_class_name(attribute)
18
- else
19
- "#{self}|#{attribute.split('.').map! {|a| a.humanize }.join('|')}"
20
- end
21
- end
22
-
23
- def humanize_class_name(name=nil)
24
- name ||= self.to_s
25
- name.underscore.humanize
26
- end
27
- end
28
- end
1
+ require 'gettext_i18n_rails/active_model/name'
2
+ require 'gettext_i18n_rails/active_model/translation'
@@ -0,0 +1,7 @@
1
+ module ActiveModel
2
+ Name.class_eval do
3
+ def human(options={})
4
+ _(@klass.humanize_class_name)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ module ActiveModel
2
+ module Translation
3
+ # CarDealer.sales_count -> s_('CarDealer|Sales count') -> 'Sales count' if no translation was found
4
+ def human_attribute_name(attribute, *args)
5
+ s_(gettext_translation_for_attribute_name(attribute))
6
+ end
7
+
8
+ def gettext_translation_for_attribute_name(attribute)
9
+ attribute = attribute.to_s
10
+ if attribute.ends_with?('_id')
11
+ humanize_class_name(attribute)
12
+ else
13
+ "#{self}|#{attribute.split('.').map! {|a| a.humanize }.join('|')}"
14
+ end
15
+ end
16
+
17
+ def humanize_class_name(name=nil)
18
+ name ||= self.to_s
19
+ name.underscore.humanize
20
+ end
21
+ end
22
+ end
@@ -1,4 +1,4 @@
1
- require 'gettext_i18n_rails/active_model'
1
+ require 'gettext_i18n_rails/active_model/translation'
2
2
 
3
3
  class ActiveRecord::Base
4
4
  extend ActiveModel::Translation
@@ -1,3 +1,3 @@
1
1
  module GettextI18nRails
2
- Version = VERSION = '0.9.1'
2
+ Version = VERSION = '0.9.2'
3
3
  end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ if ActiveRecord::VERSION::MAJOR >= 3
5
+ require "gettext_i18n_rails/active_model/name"
6
+
7
+ describe ActiveModel::Name do
8
+ before do
9
+ FastGettext.current_cache = {}
10
+ end
11
+
12
+ describe 'human' do
13
+ it "is translated through FastGettext" do
14
+ name = ActiveModel::Name.new(CarSeat)
15
+ name.should_receive(:_).with('Car seat').and_return('Autositz')
16
+ name.human.should == 'Autositz'
17
+ end
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettext_i18n_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-24 00:00:00.000000000 Z
12
+ date: 2013-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fast_gettext
@@ -61,6 +61,8 @@ files:
61
61
  - lib/gettext_i18n_rails.rb
62
62
  - lib/gettext_i18n_rails/action_controller.rb
63
63
  - lib/gettext_i18n_rails/active_model.rb
64
+ - lib/gettext_i18n_rails/active_model/name.rb
65
+ - lib/gettext_i18n_rails/active_model/translation.rb
64
66
  - lib/gettext_i18n_rails/active_record.rb
65
67
  - lib/gettext_i18n_rails/backend.rb
66
68
  - lib/gettext_i18n_rails/base_parser.rb
@@ -77,7 +79,7 @@ files:
77
79
  - lib/gettext_i18n_rails/version.rb
78
80
  - lib/tasks/gettext_rails_i18n.rake
79
81
  - spec/gettext_i18n_rails/action_controller_spec.rb
80
- - spec/gettext_i18n_rails/active_model_spec.rb
82
+ - spec/gettext_i18n_rails/active_model/name_spec.rb
81
83
  - spec/gettext_i18n_rails/active_record_spec.rb
82
84
  - spec/gettext_i18n_rails/backend_spec.rb
83
85
  - spec/gettext_i18n_rails/haml_parser_spec.rb
@@ -101,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
103
  version: '0'
102
104
  segments:
103
105
  - 0
104
- hash: 3856174768908956080
106
+ hash: -3384457185642040654
105
107
  required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  none: false
107
109
  requirements:
@@ -110,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
112
  version: '0'
111
113
  segments:
112
114
  - 0
113
- hash: 3856174768908956080
115
+ hash: -3384457185642040654
114
116
  requirements: []
115
117
  rubyforge_project:
116
118
  rubygems_version: 1.8.24
@@ -1,16 +0,0 @@
1
- # encoding: utf-8
2
- require "spec_helper"
3
-
4
- describe ActiveModel::Name do
5
- before do
6
- FastGettext.current_cache = {}
7
- end
8
-
9
- describe 'human' do
10
- it "is translated through FastGettext" do
11
- name = ActiveModel::Name.new(CarSeat)
12
- name.should_receive(:_).with('Car seat').and_return('Autositz')
13
- name.human.should == 'Autositz'
14
- end
15
- end
16
- end if ActiveRecord::VERSION::MAJOR >= 3