i18n_helper 0.0.1

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 (65) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +10 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +3 -0
  6. data/Gemfile +14 -0
  7. data/Gemfile.lock +129 -0
  8. data/MIT-LICENSE +20 -0
  9. data/README.md +55 -0
  10. data/Rakefile +10 -0
  11. data/app/controllers/.keep +0 -0
  12. data/app/controllers/locales_controller.rb +16 -0
  13. data/app/helpers/.keep +0 -0
  14. data/app/helpers/locales_helper.rb +27 -0
  15. data/bin/publish +32 -0
  16. data/bin/rails +8 -0
  17. data/config/locales/en.yml +5 -0
  18. data/config/locales/fr.yml +5 -0
  19. data/config/routes.rb +3 -0
  20. data/i18n_helper.gemspec +36 -0
  21. data/lib/i18n_helper.rb +4 -0
  22. data/lib/i18n_helper/engine.rb +15 -0
  23. data/lib/i18n_helper/version.rb +3 -0
  24. data/spec/controllers/locales_controller_spec.rb +31 -0
  25. data/spec/dummy/README.rdoc +28 -0
  26. data/spec/dummy/Rakefile +6 -0
  27. data/spec/dummy/app/assets/images/.keep +0 -0
  28. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  29. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  30. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  31. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  32. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  33. data/spec/dummy/app/mailers/.keep +0 -0
  34. data/spec/dummy/app/models/.keep +0 -0
  35. data/spec/dummy/app/models/concerns/.keep +0 -0
  36. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  37. data/spec/dummy/bin/bundle +3 -0
  38. data/spec/dummy/bin/rails +4 -0
  39. data/spec/dummy/bin/rake +4 -0
  40. data/spec/dummy/config.ru +4 -0
  41. data/spec/dummy/config/application.rb +30 -0
  42. data/spec/dummy/config/boot.rb +5 -0
  43. data/spec/dummy/config/environment.rb +5 -0
  44. data/spec/dummy/config/environments/development.rb +27 -0
  45. data/spec/dummy/config/environments/production.rb +80 -0
  46. data/spec/dummy/config/environments/test.rb +36 -0
  47. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  48. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  49. data/spec/dummy/config/initializers/inflections.rb +16 -0
  50. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  51. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  52. data/spec/dummy/config/initializers/session_store.rb +3 -0
  53. data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
  54. data/spec/dummy/config/locales/en.yml +23 -0
  55. data/spec/dummy/config/routes.rb +3 -0
  56. data/spec/dummy/lib/assets/.keep +0 -0
  57. data/spec/dummy/log/.keep +0 -0
  58. data/spec/dummy/log/test.log +60 -0
  59. data/spec/dummy/public/404.html +58 -0
  60. data/spec/dummy/public/422.html +58 -0
  61. data/spec/dummy/public/500.html +57 -0
  62. data/spec/dummy/public/favicon.ico +0 -0
  63. data/spec/helpers/locales_helper_spec.rb +70 -0
  64. data/spec/spec_helper.rb +51 -0
  65. metadata +227 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8e182438cf1bacfb61515b85c846adf313bff276
4
+ data.tar.gz: bb09bd2753e19589493ab67d671986fea08508b4
5
+ SHA512:
6
+ metadata.gz: 2149e17307d795aaab43f2fd413ca1affabe4f0f980f635b7058461e9e47f513356a59b307661b8d57f49934f6fd0f3fece882e902c017ed2e58827497028c10
7
+ data.tar.gz: d561eeb0b9fb1e7e5224d8456b8602be42acf087b8a6e51a49ce0976de281cb1c55e825951783578fc3bee375db2d23ee1cd5ef13d55dce5577d8c2e09585b99
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: MfZJeU688bvHwtmzyJhYPWUANWGatauyq
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ spec/dummy/db/*.sqlite3
5
+ spec/dummy/db/*.sqlite3-journal
6
+ spec/dummy/log/*.log
7
+ spec/dummy/tmp/
8
+ spec/dummy/.sass-cache
9
+
10
+ coverage/*
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in i18n_helper.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ # To use debugger
14
+ # gem 'debugger'
data/Gemfile.lock ADDED
@@ -0,0 +1,129 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ i18n_helper (0.0.1)
5
+ i18n-language-translations (~> 0.0.2)
6
+ rails (~> 4.0.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (4.0.2)
12
+ actionpack (= 4.0.2)
13
+ mail (~> 2.5.4)
14
+ actionpack (4.0.2)
15
+ activesupport (= 4.0.2)
16
+ builder (~> 3.1.0)
17
+ erubis (~> 2.7.0)
18
+ rack (~> 1.5.2)
19
+ rack-test (~> 0.6.2)
20
+ activemodel (4.0.2)
21
+ activesupport (= 4.0.2)
22
+ builder (~> 3.1.0)
23
+ activerecord (4.0.2)
24
+ activemodel (= 4.0.2)
25
+ activerecord-deprecated_finders (~> 1.0.2)
26
+ activesupport (= 4.0.2)
27
+ arel (~> 4.0.0)
28
+ activerecord-deprecated_finders (1.0.3)
29
+ activesupport (4.0.2)
30
+ i18n (~> 0.6, >= 0.6.4)
31
+ minitest (~> 4.2)
32
+ multi_json (~> 1.3)
33
+ thread_safe (~> 0.1)
34
+ tzinfo (~> 0.3.37)
35
+ arel (4.0.1)
36
+ atomic (1.1.14)
37
+ builder (3.1.4)
38
+ coveralls (0.7.0)
39
+ multi_json (~> 1.3)
40
+ rest-client
41
+ simplecov (>= 0.7)
42
+ term-ansicolor
43
+ thor
44
+ diff-lcs (1.2.5)
45
+ docile (1.1.1)
46
+ erubis (2.7.0)
47
+ factory_girl (4.3.0)
48
+ activesupport (>= 3.0.0)
49
+ factory_girl_rails (4.3.0)
50
+ factory_girl (~> 4.3.0)
51
+ railties (>= 3.0.0)
52
+ gemnasium (2.0.1)
53
+ hike (1.2.3)
54
+ i18n (0.6.9)
55
+ i18n-language-translations (0.0.2)
56
+ i18n (~> 0.5)
57
+ railties (>= 3.0.0)
58
+ mail (2.5.4)
59
+ mime-types (~> 1.16)
60
+ treetop (~> 1.4.8)
61
+ mime-types (1.25.1)
62
+ minitest (4.7.5)
63
+ multi_json (1.8.2)
64
+ polyglot (0.3.3)
65
+ rack (1.5.2)
66
+ rack-test (0.6.2)
67
+ rack (>= 1.0)
68
+ rails (4.0.2)
69
+ actionmailer (= 4.0.2)
70
+ actionpack (= 4.0.2)
71
+ activerecord (= 4.0.2)
72
+ activesupport (= 4.0.2)
73
+ bundler (>= 1.3.0, < 2.0)
74
+ railties (= 4.0.2)
75
+ sprockets-rails (~> 2.0.0)
76
+ railties (4.0.2)
77
+ actionpack (= 4.0.2)
78
+ activesupport (= 4.0.2)
79
+ rake (>= 0.8.7)
80
+ thor (>= 0.18.1, < 2.0)
81
+ rake (10.1.1)
82
+ rest-client (1.6.7)
83
+ mime-types (>= 1.16)
84
+ rspec-core (2.14.7)
85
+ rspec-expectations (2.14.4)
86
+ diff-lcs (>= 1.1.3, < 2.0)
87
+ rspec-mocks (2.14.4)
88
+ rspec-rails (2.14.0)
89
+ actionpack (>= 3.0)
90
+ activesupport (>= 3.0)
91
+ railties (>= 3.0)
92
+ rspec-core (~> 2.14.0)
93
+ rspec-expectations (~> 2.14.0)
94
+ rspec-mocks (~> 2.14.0)
95
+ simplecov (0.8.2)
96
+ docile (~> 1.1.0)
97
+ multi_json
98
+ simplecov-html (~> 0.8.0)
99
+ simplecov-html (0.8.0)
100
+ sprockets (2.10.1)
101
+ hike (~> 1.2)
102
+ multi_json (~> 1.0)
103
+ rack (~> 1.0)
104
+ tilt (~> 1.1, != 1.3.0)
105
+ sprockets-rails (2.0.1)
106
+ actionpack (>= 3.0)
107
+ activesupport (>= 3.0)
108
+ sprockets (~> 2.8)
109
+ term-ansicolor (1.2.2)
110
+ tins (~> 0.8)
111
+ thor (0.18.1)
112
+ thread_safe (0.1.3)
113
+ atomic
114
+ tilt (1.4.1)
115
+ tins (0.13.1)
116
+ treetop (1.4.15)
117
+ polyglot
118
+ polyglot (>= 0.3.1)
119
+ tzinfo (0.3.38)
120
+
121
+ PLATFORMS
122
+ ruby
123
+
124
+ DEPENDENCIES
125
+ coveralls
126
+ factory_girl_rails
127
+ gemnasium
128
+ i18n_helper!
129
+ rspec-rails
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 Joel AZEMAR
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.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ [![Code Climate](https://codeclimate.com/github/joel/i18n_helper.png)](https://codeclimate.com/github/joel/i18n_helper)
2
+
3
+ [![Dependency Status](https://gemnasium.com/joel/i18n_helper.png)](https://gemnasium.com/joel/i18n_helper)
4
+
5
+ [![Build Status](https://travis-ci.org/joel/i18n_helper.png?branch=master)](https://travis-ci.org/joel/i18n_helper) (Travis CI)
6
+
7
+ [![Coverage Status](https://coveralls.io/repos/joel/i18n_helper/badge.png)](https://coveralls.io/r/joel/i18n_helper)
8
+
9
+ # I18nHelper
10
+
11
+ This is a really straightforward I18n locales helper. It can you help to change locale web app on the fly.
12
+
13
+ # Features
14
+
15
+ The locale of app is recorded on current session.
16
+
17
+ ## Installation
18
+
19
+ Add to your top of Gemfile:
20
+
21
+ gem 'i18n_helper'
22
+
23
+ ## Usage
24
+
25
+ Gem come with two main helpers ```formatted_locale``` and ```i18n_helper_link```
26
+
27
+ ```formatted_locale``` provide ``` 'Language : English' ``` title, entirely translated in your current locale
28
+
29
+ ```i18n_helper_link``` provide links ready to use for call controller for change your web app locales on the fly.
30
+
31
+ If you need more customize you can call directly ```i18n_helper``` helper, this one provide an Array ready to generate Html select translated in your current locale like that :
32
+
33
+ [ ['en', 'English'], ['fr', 'French'] ]
34
+
35
+ ## Caution
36
+
37
+ It a really first alpha version of this Helper, if you add any feature please contribute!
38
+
39
+ # User profil locale setting
40
+
41
+ If you use an authentication system, like ```Devise```, and your ```User model``` like (```Devise Resource```) accessible through the ```current_user``` method helper it automatically set the locale for the who is logged.
42
+
43
+ ## Dependencies
44
+
45
+ * Ruby 2.1
46
+ * rails ~> 4.0.2
47
+ * i18n-language-translations ~> 0.0.2
48
+
49
+ ## Contributing
50
+
51
+ 1. Fork it
52
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
54
+ 4. Push to the branch (`git push origin my-new-feature`)
55
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
8
+ load 'rails/tasks/engine.rake'
9
+
10
+ Bundler::GemHelper.install_tasks
File without changes
@@ -0,0 +1,16 @@
1
+ class LocalesController < ApplicationController
2
+
3
+ def setting
4
+ if params[:locale] and I18n.available_locales.include?(params[:locale].to_sym)
5
+ session[:locale] = params[:locale]
6
+ I18n.locale = params[:locale]
7
+ if self.respond_to? :current_user
8
+ if current_user and current_user.respond_to?(:locale)
9
+ current_user.update locale: params[:locale]
10
+ end
11
+ end
12
+ end
13
+ redirect_to :back
14
+ end
15
+
16
+ end
data/app/helpers/.keep ADDED
File without changes
@@ -0,0 +1,27 @@
1
+ module LocalesHelper
2
+
3
+ def formatted_locale current_locale = I18n.locale
4
+ I18n.t('helpers.links.locale', current_locale: t("languages.#{current_locale}", locale: current_locale))
5
+ end
6
+
7
+ def i18n_helper
8
+ @i18n_helper = begin
9
+ [].tap do |locales|
10
+ I18n.available_locales.each do |locale|
11
+ locales << [ locale.to_s, I18n.t("languages.#{locale}").capitalize ]
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ def i18n_helper_link
18
+ @i18n_helper_link = begin
19
+ [].tap do |links|
20
+ i18n_helper.each do |locale, title|
21
+ links << link_to(title, set_locale_path(locale: locale), method: :post)
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ end
data/bin/publish ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # bin/publish 0.0.1
4
+
5
+ class Publish
6
+
7
+ def start version, name
8
+ system "bundle && bundle exec rake spec"
9
+ unless File.exists? "#{name}-#{version}.gem"
10
+ system "gem build #{name}.gemspec"
11
+ if File.exists? "#{name}-#{version}.gem"
12
+ system "git tag -a v#{version} -m 'version #{version}'"
13
+ system "git push --tags"
14
+ system "gem push #{name}-#{version}.gem"
15
+ system "git push origin master"
16
+ else
17
+ puts "Build Fail"
18
+ end
19
+ else
20
+ puts "Version already exist"
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ if ARGV.length != 1 # or !ARGV[0].match(/\d{1,3}.\d{1,3}.\d{1,3}/)
27
+ puts 'HELP: '
28
+ puts '$ bin/publish 0.0.1'
29
+ exit 0
30
+ end
31
+
32
+ Publish.new.start ARGV[0], (ARGV[1] || 'i18n_helper')
data/bin/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/i18n_helper/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,5 @@
1
+ ---
2
+ en:
3
+ helpers:
4
+ links:
5
+ locale: "Language : %{current_locale}"
@@ -0,0 +1,5 @@
1
+ ---
2
+ fr:
3
+ helpers:
4
+ links:
5
+ locale: "Langue : %{current_locale}"
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ post 'locales/:locale' => 'locales#setting', as: :set_locale
3
+ end
@@ -0,0 +1,36 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require 'i18n_helper/version'
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = 'i18n_helper'
9
+ s.version = I18nHelper::VERSION
10
+ s.date = '2014-01-02'
11
+ s.authors = ['Joel AZEMAR']
12
+ s.email = ['joel.azemar@gmail.com']
13
+ s.homepage = 'https://github.com/joel/i18n_helper'
14
+ s.summary = 'Summary of I18nHelper.'
15
+ s.description = 'Description of I18nHelper.'
16
+ s.license = 'MIT'
17
+
18
+ s.files = `git ls-files`.split($/)
19
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
21
+ s.require_paths = ['lib']
22
+
23
+ # s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.rdoc']
24
+
25
+ s.add_dependency 'rails', '~> 4.0.2'
26
+ s.add_dependency 'i18n-language-translations', '~> 0.0.2'
27
+
28
+ s.add_development_dependency 'rspec-rails'
29
+ s.add_development_dependency 'factory_girl_rails'
30
+ s.add_development_dependency 'gemnasium'
31
+ s.add_development_dependency 'coveralls'
32
+
33
+ s.required_ruby_version = '~> 2.0'
34
+
35
+ s.test_files = Dir['spec/**/*']
36
+ end
@@ -0,0 +1,4 @@
1
+ require 'i18n_helper/engine'
2
+
3
+ module I18nHelper
4
+ end
@@ -0,0 +1,15 @@
1
+ require 'i18n_language_translations'
2
+
3
+ module I18nHelper
4
+ class Engine < ::Rails::Engine
5
+
6
+ config.generators do |g|
7
+ g.test_framework :rspec, fixture: false
8
+ g.fixture_replacement :factory_girl, dir: 'spec/factories'
9
+ g.integration_tool :rspec
10
+ g.assets false
11
+ g.helper false
12
+ end
13
+
14
+ end
15
+ end