language_switcher 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/LICENSE +1 -1
- data/README.rdoc +15 -12
- data/Rakefile +4 -25
- data/VERSION +1 -1
- data/spec/language_switcher_spec.rb +22 -3
- data/spec/spec_helper.rb +3 -7
- metadata +25 -9
- data/language_switcher.gemspec +0 -57
- data/spec/spec.opts +0 -1
data/.gitignore
CHANGED
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,17 +1,20 @@
|
|
1
|
-
=
|
1
|
+
= Language Switcher
|
2
2
|
|
3
|
-
|
3
|
+
This is a gem for Rails to easily change and iterate over languages defined in I18n.available_locales.
|
4
4
|
|
5
|
-
==
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
The most useful command should be language_switcher helper,
|
8
|
+
which add a div and ul to allow to see an element in several different languages.
|
9
|
+
|
10
|
+
I also recommend using some tabbing with js, such as Jquery tabs:
|
11
|
+
$(document).ready(function(){
|
12
|
+
$('[data-tabs]').tabs();
|
13
|
+
});
|
14
|
+
|
15
|
+
language and each_language are also useful methods.
|
14
16
|
|
15
17
|
== Copyright
|
18
|
+
This is a pretty simple plugin, but i started to use the same set of methods in
|
19
|
+
several projects and decided to make it a gem.
|
16
20
|
|
17
|
-
Copyright (c) 2010 Stefano Diem Benatti. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'rake'
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
|
4
4
|
begin
|
5
5
|
require 'jeweler'
|
@@ -12,7 +12,8 @@ begin
|
|
12
12
|
gem.email = "stefano.diem@gmail.com"
|
13
13
|
gem.homepage = "http://github.com/teonimesic/language_switcher"
|
14
14
|
gem.authors = ["Stefano Diem Benatti"]
|
15
|
-
gem.add_development_dependency "rspec", ">=
|
15
|
+
gem.add_development_dependency "rspec-core", ">= 2.0.0.beta.13"
|
16
|
+
gem.add_dependency 'activerecord', '>= 3.0.0.beta4'
|
16
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
18
|
end
|
18
19
|
Jeweler::GemcutterTasks.new
|
@@ -20,28 +21,6 @@ rescue LoadError
|
|
20
21
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
22
|
end
|
22
23
|
|
23
|
-
|
24
|
-
#RSpec::Core::RakeTask.new(:spec) do |spec|
|
25
|
-
# spec.libs << 'lib' << 'spec'
|
26
|
-
# spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
-
#end
|
28
|
-
|
29
|
-
#RSpec::Core::RakeTask.new(:rcov) do |spec|
|
30
|
-
# spec.libs << 'lib' << 'spec'
|
31
|
-
# spec.pattern = 'spec/**/*_spec.rb'
|
32
|
-
# spec.rcov = true
|
33
|
-
#end
|
34
|
-
|
35
|
-
task :spec => :check_dependencies
|
36
|
-
|
24
|
+
RSpec::Core::RakeTask.new(:spec)
|
37
25
|
task :default => :spec
|
38
26
|
|
39
|
-
require 'rake/rdoctask'
|
40
|
-
Rake::RDocTask.new do |rdoc|
|
41
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
42
|
-
|
43
|
-
rdoc.rdoc_dir = 'rdoc'
|
44
|
-
rdoc.title = "language_switcher #{version}"
|
45
|
-
rdoc.rdoc_files.include('README*')
|
46
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
-
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
@@ -1,7 +1,26 @@
|
|
1
|
-
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
include LanguageSwitcher
|
4
|
+
I18n.available_locales = [:pt, :en]
|
2
5
|
|
3
6
|
describe "LanguageSwitcher" do
|
4
|
-
it "
|
5
|
-
|
7
|
+
it "should be able to switch to a language" do
|
8
|
+
language(:pt){ I18n.locale.should == :pt }
|
9
|
+
language(:en){ I18n.locale.should == :en }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should not be able to switch to a language unless it is included in I18n.default_locales" do
|
13
|
+
lambda { language(:es) }.should raise_error
|
6
14
|
end
|
15
|
+
|
16
|
+
it "should pass thought each locale in I18n in order" do
|
17
|
+
i = 0
|
18
|
+
each_language do |l|
|
19
|
+
I18n.locale.should == I18n.available_locales[i]
|
20
|
+
I18n.locale.should == l
|
21
|
+
i+=1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# TODO: Add language_switcher view specs
|
7
26
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
require 'active_record'
|
3
3
|
require 'language_switcher'
|
4
|
-
require '
|
5
|
-
require 'spec/autorun'
|
4
|
+
require 'rspec'
|
6
5
|
|
7
|
-
Spec::Runner.configure do |config|
|
8
|
-
|
9
|
-
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.0
|
9
|
+
version: 0.1.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Stefano Diem Benatti
|
@@ -14,11 +14,11 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-07-
|
17
|
+
date: 2010-07-12 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name: rspec
|
21
|
+
name: rspec-core
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
@@ -26,12 +26,30 @@ dependencies:
|
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
|
-
- 1
|
30
29
|
- 2
|
31
|
-
-
|
32
|
-
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
- beta
|
33
|
+
- 13
|
34
|
+
version: 2.0.0.beta.13
|
33
35
|
type: :development
|
34
36
|
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: activerecord
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
segments:
|
46
|
+
- 3
|
47
|
+
- 0
|
48
|
+
- 0
|
49
|
+
- beta4
|
50
|
+
version: 3.0.0.beta4
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
35
53
|
description: |-
|
36
54
|
This gem adds a few methods to switch between locales,
|
37
55
|
and a helper to be used with jquery tabs or some other js tabbing behavior,
|
@@ -51,10 +69,8 @@ files:
|
|
51
69
|
- README.rdoc
|
52
70
|
- Rakefile
|
53
71
|
- VERSION
|
54
|
-
- language_switcher.gemspec
|
55
72
|
- lib/language_switcher.rb
|
56
73
|
- spec/language_switcher_spec.rb
|
57
|
-
- spec/spec.opts
|
58
74
|
- spec/spec_helper.rb
|
59
75
|
has_rdoc: true
|
60
76
|
homepage: http://github.com/teonimesic/language_switcher
|
data/language_switcher.gemspec
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{language_switcher}
|
8
|
-
s.version = "0.0.0"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Stefano Diem Benatti"]
|
12
|
-
s.date = %q{2010-07-10}
|
13
|
-
s.description = %q{This gem adds a few methods to switch between locales,
|
14
|
-
and a helper to be used with jquery tabs or some other js tabbing behavior,
|
15
|
-
to be able to change locales within a view for Rails}
|
16
|
-
s.email = %q{stefano.diem@gmail.com}
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE",
|
19
|
-
"README.rdoc"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".document",
|
23
|
-
".gitignore",
|
24
|
-
"LICENSE",
|
25
|
-
"README.rdoc",
|
26
|
-
"Rakefile",
|
27
|
-
"VERSION",
|
28
|
-
"language_switcher.gemspec",
|
29
|
-
"lib/language_switcher.rb",
|
30
|
-
"spec/language_switcher_spec.rb",
|
31
|
-
"spec/spec.opts",
|
32
|
-
"spec/spec_helper.rb"
|
33
|
-
]
|
34
|
-
s.homepage = %q{http://github.com/teonimesic/language_switcher}
|
35
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
-
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.7}
|
38
|
-
s.summary = %q{A gem to easily handling switching between I18n locales}
|
39
|
-
s.test_files = [
|
40
|
-
"spec/spec_helper.rb",
|
41
|
-
"spec/language_switcher_spec.rb"
|
42
|
-
]
|
43
|
-
|
44
|
-
if s.respond_to? :specification_version then
|
45
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
-
s.specification_version = 3
|
47
|
-
|
48
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
50
|
-
else
|
51
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
52
|
-
end
|
53
|
-
else
|
54
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|