rails-localization 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create 1.9.2@rails-localization
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails"
4
+ gem "localization-middleware"
5
+ gem "i18n"
6
+
7
+ group :development, :test do
8
+ gem "test-unit"
9
+ gem "test-spec"
10
+ gem "shoulda"
11
+ gem "yard", "~> 0.6.0"
12
+ gem "jeweler", "~> 1.6.4"
13
+
14
+ gem "simplecov", "~> 0.6.4", :platform => :ruby_19
15
+ gem "rcov", "~> 1.0.0", :platform => :ruby_18
16
+
17
+ gem "debugger", "~> 1.1.3", :platform => :ruby_19
18
+ gem 'ruby-debug', :platform => :ruby_18
19
+
20
+ gem "capybara"
21
+ end
@@ -0,0 +1,156 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.2.8)
5
+ actionpack (= 3.2.8)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.8)
8
+ activemodel (= 3.2.8)
9
+ activesupport (= 3.2.8)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.4)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.2)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.1.3)
17
+ activemodel (3.2.8)
18
+ activesupport (= 3.2.8)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.8)
21
+ activemodel (= 3.2.8)
22
+ activesupport (= 3.2.8)
23
+ arel (~> 3.0.2)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.8)
26
+ activemodel (= 3.2.8)
27
+ activesupport (= 3.2.8)
28
+ activesupport (3.2.8)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ addressable (2.3.2)
32
+ arel (3.0.2)
33
+ builder (3.0.0)
34
+ capybara (1.1.2)
35
+ mime-types (>= 1.16)
36
+ nokogiri (>= 1.3.3)
37
+ rack (>= 1.0.0)
38
+ rack-test (>= 0.5.4)
39
+ selenium-webdriver (~> 2.0)
40
+ xpath (~> 0.1.4)
41
+ childprocess (0.3.5)
42
+ ffi (~> 1.0, >= 1.0.6)
43
+ columnize (0.3.6)
44
+ debugger (1.1.4)
45
+ columnize (>= 0.3.1)
46
+ debugger-linecache (~> 1.1.1)
47
+ debugger-ruby_core_source (~> 1.1.3)
48
+ debugger-linecache (1.1.2)
49
+ debugger-ruby_core_source (>= 1.1.1)
50
+ debugger-ruby_core_source (1.1.3)
51
+ erubis (2.7.0)
52
+ ffi (1.1.5)
53
+ git (1.2.5)
54
+ hike (1.2.1)
55
+ i18n (0.6.1)
56
+ jeweler (1.6.4)
57
+ bundler (~> 1.0)
58
+ git (>= 1.2.5)
59
+ rake
60
+ journey (1.0.4)
61
+ json (1.7.5)
62
+ libwebsocket (0.1.5)
63
+ addressable
64
+ linecache (0.46)
65
+ rbx-require-relative (> 0.0.4)
66
+ localization-middleware (0.1.0)
67
+ i18n
68
+ mail (2.4.4)
69
+ i18n (>= 0.4.0)
70
+ mime-types (~> 1.16)
71
+ treetop (~> 1.4.8)
72
+ mime-types (1.19)
73
+ multi_json (1.3.6)
74
+ nokogiri (1.5.5)
75
+ polyglot (0.3.3)
76
+ rack (1.4.1)
77
+ rack-cache (1.2)
78
+ rack (>= 0.4)
79
+ rack-ssl (1.3.2)
80
+ rack
81
+ rack-test (0.6.1)
82
+ rack (>= 1.0)
83
+ rails (3.2.8)
84
+ actionmailer (= 3.2.8)
85
+ actionpack (= 3.2.8)
86
+ activerecord (= 3.2.8)
87
+ activeresource (= 3.2.8)
88
+ activesupport (= 3.2.8)
89
+ bundler (~> 1.0)
90
+ railties (= 3.2.8)
91
+ railties (3.2.8)
92
+ actionpack (= 3.2.8)
93
+ activesupport (= 3.2.8)
94
+ rack-ssl (~> 1.3.2)
95
+ rake (>= 0.8.7)
96
+ rdoc (~> 3.4)
97
+ thor (>= 0.14.6, < 2.0)
98
+ rake (0.9.2.2)
99
+ rbx-require-relative (0.0.9)
100
+ rcov (1.0.0)
101
+ rdoc (3.12)
102
+ json (~> 1.4)
103
+ ruby-debug (0.10.4)
104
+ columnize (>= 0.1)
105
+ ruby-debug-base (~> 0.10.4.0)
106
+ ruby-debug-base (0.10.4)
107
+ linecache (>= 0.3)
108
+ rubyzip (0.9.9)
109
+ selenium-webdriver (2.25.0)
110
+ childprocess (>= 0.2.5)
111
+ libwebsocket (~> 0.1.3)
112
+ multi_json (~> 1.0)
113
+ rubyzip
114
+ shoulda (3.1.1)
115
+ shoulda-context (~> 1.0)
116
+ shoulda-matchers (~> 1.2)
117
+ shoulda-context (1.0.0)
118
+ shoulda-matchers (1.3.0)
119
+ activesupport (>= 3.0.0)
120
+ simplecov (0.6.4)
121
+ multi_json (~> 1.0)
122
+ simplecov-html (~> 0.5.3)
123
+ simplecov-html (0.5.3)
124
+ sprockets (2.1.3)
125
+ hike (~> 1.2)
126
+ rack (~> 1.0)
127
+ tilt (~> 1.1, != 1.3.0)
128
+ test-spec (0.10.0)
129
+ test-unit (2.5.2)
130
+ thor (0.16.0)
131
+ tilt (1.3.3)
132
+ treetop (1.4.10)
133
+ polyglot
134
+ polyglot (>= 0.3.1)
135
+ tzinfo (0.3.33)
136
+ xpath (0.1.4)
137
+ nokogiri (~> 1.3)
138
+ yard (0.6.8)
139
+
140
+ PLATFORMS
141
+ ruby
142
+
143
+ DEPENDENCIES
144
+ capybara
145
+ debugger (~> 1.1.3)
146
+ i18n
147
+ jeweler (~> 1.6.4)
148
+ localization-middleware
149
+ rails
150
+ rcov (~> 1.0.0)
151
+ ruby-debug
152
+ shoulda
153
+ simplecov (~> 0.6.4)
154
+ test-spec
155
+ test-unit
156
+ yard (~> 0.6.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 E-Max
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = rails-localization
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to rails-localization
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 E-Max. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "rails-localization"
18
+ gem.homepage = "http://github.com/kot-begemot/rails-localization"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Rails localization Gem}
21
+ gem.description = %Q{This gem allows you to localize your rails application with ease}
22
+ gem.email = "max@studentify.nl"
23
+ gem.authors = ["E-Max"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ task :default => :test
36
+
37
+ require 'yard'
38
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,2 @@
1
+ require 'rails-localization/middleware'
2
+ require 'rails-localization/routes_ext'
@@ -0,0 +1,8 @@
1
+ require 'localization-middleware'
2
+
3
+ module Rails
4
+ module Localization
5
+ class UnknownLocaleError < Exception; end
6
+ class Middleware < ::Localization::Middleware; end
7
+ end
8
+ end
@@ -0,0 +1,33 @@
1
+ require 'active_support'
2
+
3
+ module Rails
4
+ module Localization
5
+ module RoutesExt
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ def generate_with_locale
10
+ locale = options.delete(:locale)
11
+ path, params = generate_without_locale
12
+ if locale != false #only in case of :locale => false ignore the block below
13
+ path = localized_path(path, (locale || ::I18n.locale))
14
+ end
15
+ [path, params]
16
+ end
17
+ alias_method_chain :generate, :locale
18
+
19
+ private
20
+
21
+ def localized_path path, locale
22
+ raise Rails::Localization::UnknownLocaleError.new("Not supported locale: #{locale}. If this locale should be \
23
+ supported, add it to Middelware (#{Rails.root.join('config','application.rb')})") unless Rails::Localization::Middleware.languages.include?(locale.to_s)
24
+ locale.to_sym == ::I18n.default_locale ? path : "/#{locale}#{path}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ ActiveSupport.on_load(:before_initialize) do
32
+ ActionDispatch::Routing::RouteSet::Generator.send :include, Rails::Localization::RoutesExt
33
+ end
@@ -0,0 +1 @@
1
+ require 'rails-localization'
@@ -0,0 +1,127 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "rails-localization"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["E-Max"]
12
+ s.date = "2012-09-10"
13
+ s.description = "This gem allows you to localize your rails application with ease"
14
+ s.email = "max@studentify.nl"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rvmrc",
22
+ ".travis.yml",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/rails-localization.rb",
30
+ "lib/rails-localization/middleware.rb",
31
+ "lib/rails-localization/routes_ext.rb",
32
+ "lib/rails_localization.rb",
33
+ "rails-localization.gemspec",
34
+ "test/rails-localization_test.rb",
35
+ "test/support/capybara_helper.rb",
36
+ "test/test_app/.gitignore",
37
+ "test/test_app/app/assets/images/rails.png",
38
+ "test/test_app/app/assets/javascripts/application.js",
39
+ "test/test_app/app/assets/stylesheets/application.css",
40
+ "test/test_app/app/controllers/application_controller.rb",
41
+ "test/test_app/app/controllers/main_controller.rb",
42
+ "test/test_app/app/controllers/users_controller.rb",
43
+ "test/test_app/app/helpers/application_helper.rb",
44
+ "test/test_app/app/mailers/.gitkeep",
45
+ "test/test_app/app/models/.gitkeep",
46
+ "test/test_app/app/views/layouts/application.html.erb",
47
+ "test/test_app/config.ru",
48
+ "test/test_app/config/application.rb",
49
+ "test/test_app/config/boot.rb",
50
+ "test/test_app/config/environment.rb",
51
+ "test/test_app/config/environments/development.rb",
52
+ "test/test_app/config/environments/production.rb",
53
+ "test/test_app/config/environments/test.rb",
54
+ "test/test_app/config/initializers/backtrace_silencers.rb",
55
+ "test/test_app/config/initializers/inflections.rb",
56
+ "test/test_app/config/initializers/mime_types.rb",
57
+ "test/test_app/config/initializers/secret_token.rb",
58
+ "test/test_app/config/initializers/session_store.rb",
59
+ "test/test_app/config/initializers/wrap_parameters.rb",
60
+ "test/test_app/config/locales/en.yml",
61
+ "test/test_app/config/routes.rb",
62
+ "test/test_app/lib/assets/.gitkeep",
63
+ "test/test_app/lib/tasks/.gitkeep",
64
+ "test/test_app/log/.gitkeep",
65
+ "test/test_app/public/404.html",
66
+ "test/test_app/public/422.html",
67
+ "test/test_app/public/500.html",
68
+ "test/test_app/public/favicon.ico",
69
+ "test/test_app/public/robots.txt",
70
+ "test/test_helper.rb",
71
+ "test/urls_overwriting_test.rb"
72
+ ]
73
+ s.homepage = "http://github.com/kot-begemot/rails-localization"
74
+ s.licenses = ["MIT"]
75
+ s.require_paths = ["lib"]
76
+ s.rubygems_version = "1.8.10"
77
+ s.summary = "Rails localization Gem"
78
+
79
+ if s.respond_to? :specification_version then
80
+ s.specification_version = 3
81
+
82
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
83
+ s.add_runtime_dependency(%q<rails>, [">= 0"])
84
+ s.add_runtime_dependency(%q<localization-middleware>, [">= 0"])
85
+ s.add_runtime_dependency(%q<i18n>, [">= 0"])
86
+ s.add_development_dependency(%q<test-unit>, [">= 0"])
87
+ s.add_development_dependency(%q<test-spec>, [">= 0"])
88
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
89
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
90
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
91
+ s.add_development_dependency(%q<simplecov>, ["~> 0.6.4"])
92
+ s.add_development_dependency(%q<rcov>, ["~> 1.0.0"])
93
+ s.add_development_dependency(%q<debugger>, ["~> 1.1.3"])
94
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
95
+ s.add_development_dependency(%q<capybara>, [">= 0"])
96
+ else
97
+ s.add_dependency(%q<rails>, [">= 0"])
98
+ s.add_dependency(%q<localization-middleware>, [">= 0"])
99
+ s.add_dependency(%q<i18n>, [">= 0"])
100
+ s.add_dependency(%q<test-unit>, [">= 0"])
101
+ s.add_dependency(%q<test-spec>, [">= 0"])
102
+ s.add_dependency(%q<shoulda>, [">= 0"])
103
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
104
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
105
+ s.add_dependency(%q<simplecov>, ["~> 0.6.4"])
106
+ s.add_dependency(%q<rcov>, ["~> 1.0.0"])
107
+ s.add_dependency(%q<debugger>, ["~> 1.1.3"])
108
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
109
+ s.add_dependency(%q<capybara>, [">= 0"])
110
+ end
111
+ else
112
+ s.add_dependency(%q<rails>, [">= 0"])
113
+ s.add_dependency(%q<localization-middleware>, [">= 0"])
114
+ s.add_dependency(%q<i18n>, [">= 0"])
115
+ s.add_dependency(%q<test-unit>, [">= 0"])
116
+ s.add_dependency(%q<test-spec>, [">= 0"])
117
+ s.add_dependency(%q<shoulda>, [">= 0"])
118
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
119
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
120
+ s.add_dependency(%q<simplecov>, ["~> 0.6.4"])
121
+ s.add_dependency(%q<rcov>, ["~> 1.0.0"])
122
+ s.add_dependency(%q<debugger>, ["~> 1.1.3"])
123
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
124
+ s.add_dependency(%q<capybara>, [">= 0"])
125
+ end
126
+ end
127
+