i18n_scope 0.1.3 → 0.1.4
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/README +59 -0
- data/Rakefile +3 -17
- metadata +14 -12
data/README
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
I18nScope
|
2
|
+
=========
|
3
|
+
|
4
|
+
Make I18n into a callable object, which can be passed around.
|
5
|
+
|
6
|
+
Install
|
7
|
+
=======
|
8
|
+
|
9
|
+
gem "i18n_scope"
|
10
|
+
|
11
|
+
Example
|
12
|
+
=======
|
13
|
+
|
14
|
+
Instead of having to go
|
15
|
+
|
16
|
+
I18n.t("some.aspect.of.my.app.title")
|
17
|
+
I18n.t("some.aspect.of.my.app.subtitle")
|
18
|
+
I18n.t("some.aspect.of.my.app.sections.first")
|
19
|
+
I18n.t("some.aspect.of.my.app.sections.second")
|
20
|
+
|
21
|
+
We can scope I18n once, and pass it around.
|
22
|
+
|
23
|
+
i18n = I18n.scoped("some.aspect.of.my.app")
|
24
|
+
i18n.t("title")
|
25
|
+
i18n.t("subtitle")
|
26
|
+
i18n.t("sections.first")
|
27
|
+
i18n.t("sections.second")
|
28
|
+
|
29
|
+
Or we can use a block syntax
|
30
|
+
|
31
|
+
I18n.scoped("some.aspect.of.my.app") do |i18n|
|
32
|
+
i18n.t("title")
|
33
|
+
end
|
34
|
+
|
35
|
+
And we can nest these
|
36
|
+
|
37
|
+
I18n.scoped("some.aspect.of.my.app") do |i18n|
|
38
|
+
i18n.t("title")
|
39
|
+
i18n.scoped("sections") do |i18n|
|
40
|
+
i18n.t("first")
|
41
|
+
i18n.t("second")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
We don't even have to call :t
|
46
|
+
|
47
|
+
i18n = I18n.scoped("some.aspect.of.my.app")
|
48
|
+
i18n.title # to_s will return the translated value
|
49
|
+
|
50
|
+
And I forgot to say, we don't need to use strings at all
|
51
|
+
|
52
|
+
i18n = I18n.scoped.some.aspect.of.my.app
|
53
|
+
i18n.title
|
54
|
+
|
55
|
+
sections = i18n.sections
|
56
|
+
sections.first
|
57
|
+
sections.second
|
58
|
+
|
59
|
+
Copyright (c) 2010 [Matthew Rudy Jacobs], released under the MIT license
|
data/Rakefile
CHANGED
@@ -22,19 +22,7 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
22
22
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
23
|
end
|
24
24
|
|
25
|
-
require "rubygems"
|
26
25
|
require "rake/gempackagetask"
|
27
|
-
require "rake/rdoctask"
|
28
|
-
|
29
|
-
require "rake/testtask"
|
30
|
-
Rake::TestTask.new do |t|
|
31
|
-
t.libs << "test"
|
32
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
33
|
-
t.verbose = true
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
task :default => ["test"]
|
38
26
|
|
39
27
|
# This builds the actual gem. For details of what all these options
|
40
28
|
# mean, and other ones you can add, check the documentation here:
|
@@ -45,17 +33,15 @@ spec = Gem::Specification.new do |s|
|
|
45
33
|
|
46
34
|
# Change these as appropriate
|
47
35
|
s.name = "i18n_scope"
|
48
|
-
s.version = "0.1.
|
36
|
+
s.version = "0.1.4"
|
49
37
|
s.summary = "Magic scoping for I18n"
|
50
38
|
s.author = "Matthew Rudy Jacobs"
|
51
39
|
s.email = "MatthewRudyJacobs@gmail.com"
|
52
40
|
s.homepage = "http://github.com/matthewrudy/i18n_scope"
|
53
41
|
|
54
42
|
s.has_rdoc = true
|
55
|
-
|
56
|
-
|
57
|
-
# s.extra_rdoc_files = %w(README)
|
58
|
-
# s.rdoc_options = %w(--main README)
|
43
|
+
s.extra_rdoc_files = %w(README)
|
44
|
+
s.rdoc_options = %w(--main README)
|
59
45
|
|
60
46
|
# Add any extra files to include in the gem (like your README)
|
61
47
|
s.files = %w(Rakefile) + Dir.glob("{test,lib}/**/*")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_scope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthew Rudy Jacobs
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-09 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -38,21 +38,23 @@ executables: []
|
|
38
38
|
|
39
39
|
extensions: []
|
40
40
|
|
41
|
-
extra_rdoc_files:
|
42
|
-
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README
|
43
43
|
files:
|
44
44
|
- Rakefile
|
45
|
-
- test/i18n_scope_test.rb
|
46
45
|
- test/test_helper.rb
|
47
|
-
-
|
46
|
+
- test/i18n_scope_test.rb
|
48
47
|
- lib/i18n_scope.rb
|
48
|
+
- lib/i18n/scope.rb
|
49
|
+
- README
|
49
50
|
has_rdoc: true
|
50
51
|
homepage: http://github.com/matthewrudy/i18n_scope
|
51
52
|
licenses: []
|
52
53
|
|
53
54
|
post_install_message:
|
54
|
-
rdoc_options:
|
55
|
-
|
55
|
+
rdoc_options:
|
56
|
+
- --main
|
57
|
+
- README
|
56
58
|
require_paths:
|
57
59
|
- lib
|
58
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -76,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
78
|
requirements: []
|
77
79
|
|
78
80
|
rubyforge_project:
|
79
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.4.1
|
80
82
|
signing_key:
|
81
83
|
specification_version: 3
|
82
84
|
summary: Magic scoping for I18n
|