rails-localization 0.1.0

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.
Files changed (53) hide show
  1. data/.document +5 -0
  2. data/.rvmrc +1 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile +21 -0
  5. data/Gemfile.lock +156 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.rdoc +19 -0
  8. data/Rakefile +38 -0
  9. data/VERSION +1 -0
  10. data/lib/rails-localization.rb +2 -0
  11. data/lib/rails-localization/middleware.rb +8 -0
  12. data/lib/rails-localization/routes_ext.rb +33 -0
  13. data/lib/rails_localization.rb +1 -0
  14. data/rails-localization.gemspec +127 -0
  15. data/test/rails-localization_test.rb +80 -0
  16. data/test/support/capybara_helper.rb +12 -0
  17. data/test/test_app/.gitignore +15 -0
  18. data/test/test_app/app/assets/images/rails.png +0 -0
  19. data/test/test_app/app/assets/javascripts/application.js +15 -0
  20. data/test/test_app/app/assets/stylesheets/application.css +13 -0
  21. data/test/test_app/app/controllers/application_controller.rb +9 -0
  22. data/test/test_app/app/controllers/main_controller.rb +9 -0
  23. data/test/test_app/app/controllers/users_controller.rb +11 -0
  24. data/test/test_app/app/helpers/application_helper.rb +2 -0
  25. data/test/test_app/app/mailers/.gitkeep +0 -0
  26. data/test/test_app/app/models/.gitkeep +0 -0
  27. data/test/test_app/app/views/layouts/application.html.erb +14 -0
  28. data/test/test_app/config.ru +4 -0
  29. data/test/test_app/config/application.rb +72 -0
  30. data/test/test_app/config/boot.rb +6 -0
  31. data/test/test_app/config/environment.rb +5 -0
  32. data/test/test_app/config/environments/development.rb +37 -0
  33. data/test/test_app/config/environments/production.rb +67 -0
  34. data/test/test_app/config/environments/test.rb +37 -0
  35. data/test/test_app/config/initializers/backtrace_silencers.rb +7 -0
  36. data/test/test_app/config/initializers/inflections.rb +15 -0
  37. data/test/test_app/config/initializers/mime_types.rb +5 -0
  38. data/test/test_app/config/initializers/secret_token.rb +7 -0
  39. data/test/test_app/config/initializers/session_store.rb +8 -0
  40. data/test/test_app/config/initializers/wrap_parameters.rb +14 -0
  41. data/test/test_app/config/locales/en.yml +5 -0
  42. data/test/test_app/config/routes.rb +6 -0
  43. data/test/test_app/lib/assets/.gitkeep +0 -0
  44. data/test/test_app/lib/tasks/.gitkeep +0 -0
  45. data/test/test_app/log/.gitkeep +0 -0
  46. data/test/test_app/public/404.html +26 -0
  47. data/test/test_app/public/422.html +26 -0
  48. data/test/test_app/public/500.html +25 -0
  49. data/test/test_app/public/favicon.ico +0 -0
  50. data/test/test_app/public/robots.txt +5 -0
  51. data/test/test_helper.rb +20 -0
  52. data/test/urls_overwriting_test.rb +31 -0
  53. metadata +245 -0
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
11
+ #
12
+ # These inflection rules are supported but not enabled by default:
13
+ # ActiveSupport::Inflector.inflections do |inflect|
14
+ # inflect.acronym 'RESTful'
15
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ TestApp::Application.config.secret_token = '2dfa87d4cd5809fc27fae79627ad5203edbc35bad2a5730fe5ef969f0ef736a798480f49e8cfccc9b25f7e12d8ab500d619d4fbe572da497380293fba0c99975'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ TestApp::Application.config.session_store :cookie_store, :key => '_test_app_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # TestApp::Application.config.session_store :active_record_store
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters :format => [:json]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,6 @@
1
+ TestApp::Application.routes.draw do
2
+ resources :users
3
+ get :welcome, :to => 'main#welcome'
4
+
5
+ root :to => 'main#index'
6
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -0,0 +1,20 @@
1
+ require 'bundler'
2
+ require 'rack/test'
3
+ require 'test/unit'
4
+ require 'ruby-debug'
5
+
6
+ Bundler.setup(:default, :test)
7
+
8
+ ENV["RAILS_ENV"] = "test"
9
+
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
11
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
12
+ require 'rails-localization'
13
+
14
+ require File.join(File.dirname(__FILE__), 'test_app', 'config', 'environment')
15
+ require File.expand_path("support/capybara_helper", File.dirname(__FILE__))
16
+
17
+ require 'rails/test_help'
18
+ require 'capybara/rails'
19
+
20
+ I18n.locale = :en
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require File.expand_path("test_helper", File.dirname(__FILE__))
3
+
4
+ class UrlsOverwritingTest < ActionController::TestCase
5
+
6
+ def teardown
7
+ ::I18n.locale = ::I18n.default_locale
8
+ end
9
+
10
+ test "root" do
11
+ assert_generates("/", :controller => "main", :action => "index")
12
+ ::I18n.locale = :en
13
+ assert_generates("/", :controller => "main", :action => "index")
14
+ ::I18n.locale = :ru
15
+ assert_generates("/", :controller => "main", :action => "index", :locale => false)
16
+ assert_generates("/", :controller => "main", :action => "index", :locale => :en)
17
+ assert_generates("/", :controller => "main", :action => "index", :locale => "en")
18
+ assert_generates("/ru/", :controller => "main", :action => "index")
19
+ end
20
+
21
+ test "incorrect locale" do
22
+ assert_raises Rails::Localization::UnknownLocaleError do
23
+ assert_generates("/", :controller => "main", :action => "index", :locale => :de)
24
+ end
25
+ end
26
+
27
+ # test "routing" do
28
+ # assert_equal '/', TestApp::Application.routes.url_for
29
+ # end
30
+
31
+ end
metadata ADDED
@@ -0,0 +1,245 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-localization
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - E-Max
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-10 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &78203240 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *78203240
25
+ - !ruby/object:Gem::Dependency
26
+ name: localization-middleware
27
+ requirement: &78202930 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *78202930
36
+ - !ruby/object:Gem::Dependency
37
+ name: i18n
38
+ requirement: &78202510 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *78202510
47
+ - !ruby/object:Gem::Dependency
48
+ name: test-unit
49
+ requirement: &78202130 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *78202130
58
+ - !ruby/object:Gem::Dependency
59
+ name: test-spec
60
+ requirement: &78201750 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *78201750
69
+ - !ruby/object:Gem::Dependency
70
+ name: shoulda
71
+ requirement: &78201150 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *78201150
80
+ - !ruby/object:Gem::Dependency
81
+ name: yard
82
+ requirement: &78200420 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 0.6.0
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *78200420
91
+ - !ruby/object:Gem::Dependency
92
+ name: jeweler
93
+ requirement: &78199960 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 1.6.4
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *78199960
102
+ - !ruby/object:Gem::Dependency
103
+ name: simplecov
104
+ requirement: &78199470 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.6.4
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *78199470
113
+ - !ruby/object:Gem::Dependency
114
+ name: rcov
115
+ requirement: &78198970 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ~>
119
+ - !ruby/object:Gem::Version
120
+ version: 1.0.0
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *78198970
124
+ - !ruby/object:Gem::Dependency
125
+ name: debugger
126
+ requirement: &78198490 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 1.1.3
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: *78198490
135
+ - !ruby/object:Gem::Dependency
136
+ name: ruby-debug
137
+ requirement: &78197940 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: *78197940
146
+ - !ruby/object:Gem::Dependency
147
+ name: capybara
148
+ requirement: &78197570 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: *78197570
157
+ description: This gem allows you to localize your rails application with ease
158
+ email: max@studentify.nl
159
+ executables: []
160
+ extensions: []
161
+ extra_rdoc_files:
162
+ - LICENSE.txt
163
+ - README.rdoc
164
+ files:
165
+ - .document
166
+ - .rvmrc
167
+ - .travis.yml
168
+ - Gemfile
169
+ - Gemfile.lock
170
+ - LICENSE.txt
171
+ - README.rdoc
172
+ - Rakefile
173
+ - VERSION
174
+ - lib/rails-localization.rb
175
+ - lib/rails-localization/middleware.rb
176
+ - lib/rails-localization/routes_ext.rb
177
+ - lib/rails_localization.rb
178
+ - rails-localization.gemspec
179
+ - test/rails-localization_test.rb
180
+ - test/support/capybara_helper.rb
181
+ - test/test_app/.gitignore
182
+ - test/test_app/app/assets/images/rails.png
183
+ - test/test_app/app/assets/javascripts/application.js
184
+ - test/test_app/app/assets/stylesheets/application.css
185
+ - test/test_app/app/controllers/application_controller.rb
186
+ - test/test_app/app/controllers/main_controller.rb
187
+ - test/test_app/app/controllers/users_controller.rb
188
+ - test/test_app/app/helpers/application_helper.rb
189
+ - test/test_app/app/mailers/.gitkeep
190
+ - test/test_app/app/models/.gitkeep
191
+ - test/test_app/app/views/layouts/application.html.erb
192
+ - test/test_app/config.ru
193
+ - test/test_app/config/application.rb
194
+ - test/test_app/config/boot.rb
195
+ - test/test_app/config/environment.rb
196
+ - test/test_app/config/environments/development.rb
197
+ - test/test_app/config/environments/production.rb
198
+ - test/test_app/config/environments/test.rb
199
+ - test/test_app/config/initializers/backtrace_silencers.rb
200
+ - test/test_app/config/initializers/inflections.rb
201
+ - test/test_app/config/initializers/mime_types.rb
202
+ - test/test_app/config/initializers/secret_token.rb
203
+ - test/test_app/config/initializers/session_store.rb
204
+ - test/test_app/config/initializers/wrap_parameters.rb
205
+ - test/test_app/config/locales/en.yml
206
+ - test/test_app/config/routes.rb
207
+ - test/test_app/lib/assets/.gitkeep
208
+ - test/test_app/lib/tasks/.gitkeep
209
+ - test/test_app/log/.gitkeep
210
+ - test/test_app/public/404.html
211
+ - test/test_app/public/422.html
212
+ - test/test_app/public/500.html
213
+ - test/test_app/public/favicon.ico
214
+ - test/test_app/public/robots.txt
215
+ - test/test_helper.rb
216
+ - test/urls_overwriting_test.rb
217
+ homepage: http://github.com/kot-begemot/rails-localization
218
+ licenses:
219
+ - MIT
220
+ post_install_message:
221
+ rdoc_options: []
222
+ require_paths:
223
+ - lib
224
+ required_ruby_version: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ segments:
231
+ - 0
232
+ hash: -787288623
233
+ required_rubygems_version: !ruby/object:Gem::Requirement
234
+ none: false
235
+ requirements:
236
+ - - ! '>='
237
+ - !ruby/object:Gem::Version
238
+ version: '0'
239
+ requirements: []
240
+ rubyforge_project:
241
+ rubygems_version: 1.8.10
242
+ signing_key:
243
+ specification_version: 3
244
+ summary: Rails localization Gem
245
+ test_files: []