gettext_i18n_rails 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -2,11 +2,11 @@ source :rubygems
2
2
  gemspec
3
3
 
4
4
  gem 'haml'
5
- gem 'slim', :git => "https://github.com/grosser/slim.git", :ref => "rails2"
6
- gem 'hamlet', :git => "https://github.com/grosser/hamlet.rb.git", :ref => "all"
5
+ gem 'slim'
6
+ gem 'hamlet'
7
7
  gem 'ruby_parser'
8
8
  gem 'gettext'
9
- gem 'sqlite3', '~>1.3.4'
9
+ gem 'sqlite3', '~>1.3.6'
10
10
  gem 'rails', ENV['RAILS'] || '~>3'
11
11
  gem 'rake'
12
12
  gem 'rspec', '~>2'
@@ -1,24 +1,7 @@
1
- GIT
2
- remote: https://github.com/grosser/hamlet.rb.git
3
- revision: daf922bb40a9daa20fcc50a7e10c77cff772d688
4
- ref: all
5
- specs:
6
- hamlet (0.5.0.1)
7
- slim (~> 1.2.0)
8
-
9
- GIT
10
- remote: https://github.com/grosser/slim.git
11
- revision: f1b32d3b5422536b5f4f708dde55a13dc43568dc
12
- ref: rails2
13
- specs:
14
- slim (1.2.1)
15
- temple (~> 0.4.0)
16
- tilt (~> 1.3.3)
17
-
18
1
  PATH
19
2
  remote: .
20
3
  specs:
21
- gettext_i18n_rails (0.6.2)
4
+ gettext_i18n_rails (0.6.3)
22
5
  fast_gettext
23
6
 
24
7
  GEM
@@ -55,10 +38,12 @@ GEM
55
38
  builder (3.0.0)
56
39
  diff-lcs (1.1.2)
57
40
  erubis (2.7.0)
58
- fast_gettext (0.6.7)
41
+ fast_gettext (0.6.8)
59
42
  gettext (2.1.0)
60
43
  locale (>= 2.0.5)
61
44
  haml (3.1.4)
45
+ hamlet (0.1)
46
+ slim (~> 1.0)
62
47
  hike (1.2.1)
63
48
  i18n (0.6.0)
64
49
  journey (1.0.4)
@@ -107,11 +92,14 @@ GEM
107
92
  ruby_parser (2.3.1)
108
93
  sexp_processor (~> 3.0)
109
94
  sexp_processor (3.0.10)
95
+ slim (1.2.1)
96
+ temple (~> 0.4.0)
97
+ tilt (~> 1.3.3)
110
98
  sprockets (2.1.3)
111
99
  hike (~> 1.2)
112
100
  rack (~> 1.0)
113
101
  tilt (~> 1.1, != 1.3.0)
114
- sqlite3 (1.3.4)
102
+ sqlite3 (1.3.6)
115
103
  temple (0.4.0)
116
104
  thor (0.15.2)
117
105
  tilt (1.3.3)
@@ -127,10 +115,10 @@ DEPENDENCIES
127
115
  gettext
128
116
  gettext_i18n_rails!
129
117
  haml
130
- hamlet!
131
- rails (= 3.2.5)
118
+ hamlet
119
+ rails (~> 3)
132
120
  rake
133
121
  rspec (~> 2)
134
122
  ruby_parser
135
- slim!
136
- sqlite3 (~> 1.3.4)
123
+ slim
124
+ sqlite3 (~> 1.3.6)
data/Rakefile CHANGED
@@ -4,9 +4,9 @@ task :spec do
4
4
  sh "rspec spec"
5
5
  end
6
6
 
7
- task :default do
8
- ['2.3.14', '3.0.9', '3.1.0'].each do |version|
9
- sh "export RAILS='#{version}' && (bundle check || bundle install) && bundle exec rake spec"
7
+ task :default do # can fail when run with bundler
8
+ ['2.3.14', '~>3.0.15', '~>3.1.6', '~>3.2.6'].each do |version|
9
+ sh "export RAILS='#{version}' && (bundle check || bundle) && bundle exec rake spec"
10
10
  end
11
11
  sh "git checkout Gemfile.lock"
12
12
  end
@@ -23,15 +23,15 @@ I18n.backend = GettextI18nRails::Backend.new
23
23
 
24
24
  require 'gettext_i18n_rails/i18n_hacks'
25
25
 
26
- require 'gettext_i18n_rails/active_record'
27
- # If configuration via Railties is not available force activerecord extensions
28
- if not defined?(Rails::Railtie) and defined?(ActiveRecord)
29
- ActiveRecord::Base.extend GettextI18nRails::ActiveRecord
30
- end
31
-
32
- if not defined?(Rails::Railtie) and defined?(ActiveModel)
33
- require 'gettext_i18n_rails/active_model'
26
+ if defined? Rails::Railtie # Rails 3+
27
+ # load active_model extensions at the correct point in time
28
+ require 'gettext_i18n_rails/railtie'
29
+ else
30
+ if defined? ActiveRecord
31
+ require 'gettext_i18n_rails/active_record'
32
+ elsif defined?(ActiveModel)
33
+ require 'gettext_i18n_rails/active_model'
34
+ end
34
35
  end
35
36
 
36
37
  require 'gettext_i18n_rails/action_controller' if defined?(ActionController) # so that bundle console can work in a rails project
37
- require 'gettext_i18n_rails/railtie'
@@ -1,16 +1,14 @@
1
- # if running Rails 2 ActiveModel won't exist -- but we still need to load
2
- # our overrides for the include below to work
3
- begin
4
- require 'active_model'
5
- rescue LoadError
6
- require 'gettext_i18n_rails/active_model'
7
- end
1
+ require 'gettext_i18n_rails/active_model'
2
+
3
+ class ActiveRecord::Base
4
+ extend ActiveModel::Translation
8
5
 
9
- module GettextI18nRails::ActiveRecord
10
- include ActiveModel::Translation
6
+ def self.human_attribute_name(*args)
7
+ super(*args)
8
+ end
11
9
 
12
10
  # method deprecated in Rails 3.1
13
- def human_name(*args)
11
+ def self.human_name(*args)
14
12
  _(self.humanize_class_name)
15
13
  end
16
14
  end
@@ -5,6 +5,8 @@ module GettextI18nRails
5
5
  cattr_accessor :translate_defaults
6
6
  attr_accessor :backend
7
7
 
8
+ RUBY19 = (RUBY_VERSION > "1.9")
9
+
8
10
  def initialize(*args)
9
11
  self.backend = I18n::Backend::Simple.new(*args)
10
12
  end
@@ -18,7 +20,8 @@ module GettextI18nRails
18
20
  translation = FastGettext._(gettext_key)
19
21
  interpolate(translation, options)
20
22
  else
21
- backend.translate locale, key, options
23
+ result = backend.translate(locale, key, options)
24
+ RUBY19 ? result.force_encoding("UTF-8") : result
22
25
  end
23
26
  end
24
27
 
@@ -26,4 +26,4 @@ module GettextI18nRails
26
26
  text.to_s.html_safe
27
27
  end
28
28
  end
29
- end
29
+ end
@@ -1,20 +1,17 @@
1
- # add rake tasks if we are inside Rails
2
- if defined?(Rails::Railtie)
3
- module GettextI18nRails
4
- class Railtie < ::Rails::Railtie
5
- config.gettext_i18n_rails = ActiveSupport::OrderedOptions.new
6
- config.gettext_i18n_rails.msgmerge = %w[--sort-output --no-location --no-wrap]
7
- config.gettext_i18n_rails.use_for_active_record_attributes = true
1
+ module GettextI18nRails
2
+ class Railtie < ::Rails::Railtie
3
+ config.gettext_i18n_rails = ActiveSupport::OrderedOptions.new
4
+ config.gettext_i18n_rails.msgmerge = %w[--sort-output --no-location --no-wrap]
5
+ config.gettext_i18n_rails.use_for_active_record_attributes = true
8
6
 
9
- rake_tasks do
10
- require 'gettext_i18n_rails/tasks'
11
- end
7
+ rake_tasks do
8
+ require 'gettext_i18n_rails/tasks'
9
+ end
12
10
 
13
- config.after_initialize do |app|
14
- if app.config.gettext_i18n_rails.use_for_active_record_attributes
15
- ActiveSupport.on_load :active_record do
16
- require 'gettext_i18n_rails/active_model.rb'
17
- end
11
+ config.after_initialize do |app|
12
+ if app.config.gettext_i18n_rails.use_for_active_record_attributes
13
+ ActiveSupport.on_load :active_record do
14
+ require 'gettext_i18n_rails/active_model'
18
15
  end
19
16
  end
20
17
  end
@@ -1,3 +1,3 @@
1
1
  module GettextI18nRails
2
- Version = VERSION = '0.6.2'
2
+ Version = VERSION = '0.6.3'
3
3
  end
@@ -13,4 +13,4 @@ describe ActiveModel::Name do
13
13
  name.human.should == 'Autositz'
14
14
  end
15
15
  end
16
- end
16
+ end if ActiveRecord::VERSION::MAJOR >= 3
@@ -41,14 +41,14 @@ describe ActiveRecord::Base do
41
41
  it "translates error messages" do
42
42
  FastGettext.stub!(:current_repository).and_return('translate me'=>"Übersetz mich!")
43
43
  FastGettext._('translate me').should == "Übersetz mich!"
44
- model.errors[:seat_color].should == ["Übersetz mich!"]
44
+ model.errors.full_messages.should == ["Seat color Übersetz mich!"]
45
45
  end
46
46
 
47
47
  it "translates scoped error messages" do
48
48
  pending 'scope is no longer added in 3.x' if ActiveRecord::VERSION::MAJOR >= 3
49
49
  FastGettext.stub!(:current_repository).and_return('activerecord.errors.translate me'=>"Übersetz mich!")
50
50
  FastGettext._('activerecord.errors.translate me').should == "Übersetz mich!"
51
- model.errors[:seat_color].should == ["Übersetz mich!"]
51
+ model.errors.full_messages.should == ["Seat color Übersetz mich!"]
52
52
  end
53
53
 
54
54
  it "translates error messages with %{fn}" do
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require "spec_helper"
2
3
 
3
4
  FastGettext.silence_errors
@@ -41,6 +42,21 @@ describe GettextI18nRails::Backend do
41
42
  subject.translate('xx',:x ,:scope=>'xy.z').should == 'a'
42
43
  end
43
44
 
45
+ it "passes non-gettext keys to default backend" do
46
+ subject.backend.should_receive(:translate).with('xx', 'c', {}).and_return 'd'
47
+ FastGettext.stub(:current_repository).and_return 'a'=>'b'
48
+ subject.translate('xx', 'c', {}).should == 'd'
49
+ end
50
+
51
+ if RUBY_VERSION > "1.9"
52
+ it "produces UTF-8 when not using FastGettext to fix weird encoding bug" do
53
+ subject.backend.should_receive(:translate).with('xx', 'c', {}).and_return 'ü'.force_encoding("US-ASCII")
54
+ FastGettext.stub(:current_repository).and_return 'a'=>'b'
55
+ result = subject.translate('xx', 'c', {})
56
+ result.should == 'ü'
57
+ end
58
+ end
59
+
44
60
  # TODO NameError is raised <-> wtf ?
45
61
  xit "uses the super when the key is not translatable" do
46
62
  lambda{subject.translate('xx','y',:scope=>['xy','z'])}.should raise_error(I18n::MissingTranslationData)
@@ -9,6 +9,7 @@ require 'action_controller'
9
9
  require 'action_mailer'
10
10
  require 'fast_gettext'
11
11
  require 'gettext_i18n_rails'
12
+ require 'temple'
12
13
 
13
14
  begin
14
15
  Gem.all_load_paths
@@ -17,6 +18,15 @@ rescue
17
18
  module Gem;def self.all_load_paths;[];end;end
18
19
  end
19
20
 
21
+
22
+ # make temple not blow up in rails 2 env
23
+ class << Temple::Templates
24
+ alias_method :method_missing_old, :method_missing
25
+ def method_missing(name, engine, options = {})
26
+ name == :Rails || method_missing_old(name, engine, options)
27
+ end
28
+ end
29
+
20
30
  module Rails
21
31
  def self.root
22
32
  File.dirname(__FILE__)
@@ -75,5 +85,3 @@ end
75
85
  class Idea < ActiveRecord::Base
76
86
  self.abstract_class = true
77
87
  end
78
-
79
- ActiveRecord::Base.extend GettextI18nRails::ActiveRecord
metadata CHANGED
@@ -1,45 +1,38 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: gettext_i18n_rails
3
- version: !ruby/object:Gem::Version
4
- hash: 3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 6
9
- - 2
10
- version: 0.6.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Michael Grosser
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-06-15 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-06-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: fast_gettext
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
31
22
  type: :runtime
32
- requirement: *id001
33
23
  prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
34
30
  description:
35
31
  email: michael@grosser.it
36
32
  executables: []
37
-
38
33
  extensions: []
39
-
40
34
  extra_rdoc_files: []
41
-
42
- files:
35
+ files:
43
36
  - .gitignore
44
37
  - Gemfile
45
38
  - Gemfile.lock
@@ -77,37 +70,34 @@ files:
77
70
  - spec/gettext_i18n_rails_spec.rb
78
71
  - spec/spec_helper.rb
79
72
  homepage: http://github.com/grosser/gettext_i18n_rails
80
- licenses:
73
+ licenses:
81
74
  - MIT
82
75
  post_install_message:
83
76
  rdoc_options: []
84
-
85
- require_paths:
77
+ require_paths:
86
78
  - lib
87
- required_ruby_version: !ruby/object:Gem::Requirement
79
+ required_ruby_version: !ruby/object:Gem::Requirement
88
80
  none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ segments:
94
86
  - 0
95
- version: "0"
96
- required_rubygems_version: !ruby/object:Gem::Requirement
87
+ hash: -3221859057587682382
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
89
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ segments:
103
95
  - 0
104
- version: "0"
96
+ hash: -3221859057587682382
105
97
  requirements: []
106
-
107
98
  rubyforge_project:
108
99
  rubygems_version: 1.8.24
109
100
  signing_key:
110
101
  specification_version: 3
111
102
  summary: Simple FastGettext Rails integration.
112
103
  test_files: []
113
-