i18n-globals 0.0.1 → 0.0.3
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.
- checksums.yaml +6 -14
- data/README.md +39 -21
- data/Rakefile +1 -2
- data/i18n-globals.gemspec +11 -11
- data/lib/i18n-globals.rb +1 -1
- data/lib/i18n/globals.rb +3 -1
- data/lib/i18n/globals/version.rb +1 -1
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
YWQ3ODNjMTJkZjhjYTBiYTlmNGYzOTAzYmMzOWRiNDg2MTI3NzU4ZWU0MjBi
|
10
|
-
ZTllMTA2NDFiMjJjN2YwZWJiY2U2ZjA0YWZkN2Q2NDY4NTZiODNjYTA2OTFm
|
11
|
-
ODZhZWVjMWY0ZjMzMDNlNDg4N2Q0ZmQzNWU0OTdhNTQwMTdjYzk=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
Njc2NTVjMDU1ZjFjZGY3NmFhY2U4ZDJlMzE5ODMzZDlhZDM4MzI5YTYyMDcz
|
14
|
-
YWUyNGYxYWE1NzJkMzBmMDJlYzIwMjY5ZDEyZWJjYzNjZGJjN2Q4MGFlN2Iz
|
15
|
-
ZjU1OTJjODMzOTA3Y2I4NjZkNWYxZDZiZWY2ZjRjODA2NGNmZWU=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7d765960ad18fac95916f33fe6deddbb77ebbb9c
|
4
|
+
data.tar.gz: 94fa82665572fe58bd2855c8877a6275b9ef55ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0183907d11954efddea421599aa03fe44c5648f519712d018943b9046509dc6334090a54313d09411d131f3d81319651b813b4276c9801da457caed927172c5e
|
7
|
+
data.tar.gz: 98b53d32f9691c89acb705833e392c63d160665eae83e5df5ec067146ea57db13924ee63ee7421952a86441a077bad8e93937339a513b2be89de7027f17ea232
|
data/README.md
CHANGED
@@ -10,54 +10,72 @@ Extends the Ruby I18n gem with global variables. The globals will be available f
|
|
10
10
|
|
11
11
|
Add this line to your application's Gemfile:
|
12
12
|
|
13
|
-
|
13
|
+
```ruby
|
14
|
+
gem 'i18n-globals'
|
15
|
+
```
|
14
16
|
|
15
17
|
And then execute:
|
16
18
|
|
17
|
-
|
19
|
+
```sh
|
20
|
+
$ bundle
|
21
|
+
```
|
18
22
|
|
19
23
|
Or install it yourself as:
|
20
24
|
|
21
|
-
|
25
|
+
```sh
|
26
|
+
$ gem install i18n-globals
|
27
|
+
```
|
22
28
|
|
23
29
|
## Usage
|
24
30
|
|
25
31
|
Add your global variables to the `I18n.config.globals` hash:
|
26
32
|
|
27
|
-
|
33
|
+
```ruby
|
34
|
+
I18n.config.globals[:company] = 'Initech'
|
35
|
+
```
|
28
36
|
|
29
37
|
Your global variables will then be automatically interpolated into every translation:
|
30
38
|
|
31
|
-
|
32
|
-
|
39
|
+
```ruby
|
40
|
+
# If the value of 'greeting' is 'Welcome to %{company}!'
|
41
|
+
I18n.t 'greeting' # Returns 'Welcome to Initech!'
|
42
|
+
```
|
33
43
|
|
34
44
|
You can override the globals:
|
35
45
|
|
36
|
-
|
46
|
+
```ruby
|
47
|
+
I18n.t 'greeting', company: 'Initrode' # Returns 'Welcome to Initrode!'
|
48
|
+
```
|
37
49
|
|
38
50
|
It's also possible to mix globals and ordinary variables:
|
39
51
|
|
40
|
-
|
41
|
-
|
52
|
+
```ruby
|
53
|
+
# If the value of 'signature' is '%{president}, President of %{company}'
|
54
|
+
I18n.t 'signature', president: 'Bill Lumbergh' # Returns 'Bill Lumbergh, President of Initech'
|
55
|
+
```
|
42
56
|
|
43
|
-
If you're using Rails, it can be useful to specify your globals in a `
|
57
|
+
If you're using Rails, it can be useful to specify your globals in a `before_action`:
|
44
58
|
|
45
|
-
|
46
|
-
|
59
|
+
```ruby
|
60
|
+
class EmployeesController < ApplicationController
|
61
|
+
before_action :set_i18n_globals
|
47
62
|
|
48
|
-
|
63
|
+
# ...
|
49
64
|
|
50
|
-
|
65
|
+
private
|
51
66
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
67
|
+
def set_i18n_globals
|
68
|
+
I18n.config.globals[:company] = Company.current.name
|
69
|
+
end
|
70
|
+
end
|
71
|
+
```
|
56
72
|
|
57
|
-
Now you can interpolate the `
|
73
|
+
Now you can interpolate the `company` variable into every translation in your template:
|
58
74
|
|
59
|
-
|
60
|
-
|
75
|
+
```html_ruby
|
76
|
+
<%= t 'greeting' %>
|
77
|
+
<%= t 'signature', president: 'Bill Lumbergh' %>
|
78
|
+
```
|
61
79
|
|
62
80
|
## Contributing
|
63
81
|
|
data/Rakefile
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'bundler/gem_tasks'
|
data/i18n-globals.gemspec
CHANGED
@@ -4,22 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'i18n/globals/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'i18n-globals'
|
8
8
|
spec.version = I18n::Globals::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary = %q{Adds support for I18n global variables, which will be available for interpolation into every translation.}
|
12
|
-
spec.description = %q{Extends the Ruby I18n gem with global variables. The globals will be available for interpolation in every translation without explicitly specifying them in a call to I18n.translate. The variables can be accessed through I18n.config.globals.}
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Attila Horvath']
|
10
|
+
spec.email = ['hun.ati500@gmail.com']
|
11
|
+
spec.summary = %q{ Adds support for I18n global variables, which will be available for interpolation into every translation.}
|
12
|
+
spec.description = %q{ Extends the Ruby I18n gem with global variables. The globals will be available for interpolation in every translation without explicitly specifying them in a call to I18n.translate. The variables can be accessed through I18n.config.globals.}
|
13
|
+
spec.homepage = 'https://github.com/attilahorvath/i18n-globals'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
23
|
|
24
|
-
spec.add_runtime_dependency
|
24
|
+
spec.add_runtime_dependency 'i18n'
|
25
25
|
end
|
data/lib/i18n-globals.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'i18n/globals'
|
data/lib/i18n/globals.rb
CHANGED
data/lib/i18n/globals/version.rb
CHANGED
metadata
CHANGED
@@ -1,67 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-globals
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Attila Horvath
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: i18n
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description: Extends the Ruby I18n gem with global variables. The globals will be
|
55
|
+
description: " Extends the Ruby I18n gem with global variables. The globals will be
|
56
56
|
available for interpolation in every translation without explicitly specifying them
|
57
|
-
in a call to I18n.translate. The variables can be accessed through I18n.config.globals.
|
57
|
+
in a call to I18n.translate. The variables can be accessed through I18n.config.globals."
|
58
58
|
email:
|
59
59
|
- hun.ati500@gmail.com
|
60
60
|
executables: []
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
|
-
- .gitignore
|
64
|
+
- ".gitignore"
|
65
65
|
- Gemfile
|
66
66
|
- LICENSE.txt
|
67
67
|
- README.md
|
@@ -80,17 +80,17 @@ require_paths:
|
|
80
80
|
- lib
|
81
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.4.6
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Adds support for I18n global variables, which will be available for interpolation
|