i18n 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -10
- data/lib/i18n/backend/base.rb +0 -1
- data/lib/i18n/backend/simple.rb +8 -4
- data/lib/i18n/version.rb +1 -1
- metadata +8 -5
- data/lib/i18n/core_ext/kernel/suppress_warnings.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e56b50c83ab6291a1321b462814b80ad73d74d01cb77c25ab6a1d948c8737afc
|
4
|
+
data.tar.gz: 23d1ac1b19a36a2543e063f612170f45be6d404d2ff258c611c75be159dde98c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b555490dcb1c101f72f04f6ce9f257070da32021906355f7ccf96ee8ef62d33fda682e75bfb634d91c13afc72fa2d6f74135721a0df40c473edb083cf0a04360
|
7
|
+
data.tar.gz: 810d9280d42cf03d60d4251371bad79f602799b786660413e00b8f4d351a81c70b0ad7f4223ac276d0600721139e367b2b39a656f6d60335993bcc46d30abafb
|
data/README.md
CHANGED
@@ -4,9 +4,52 @@
|
|
4
4
|
|
5
5
|
Ruby Internationalization and localization solution.
|
6
6
|
|
7
|
-
|
7
|
+
Currently maintained by @radar.
|
8
8
|
|
9
|
-
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
### Rails
|
12
|
+
|
13
|
+
You will most commonly use this library within a Rails app.
|
14
|
+
|
15
|
+
[See the Rails Guide](http://guides.rubyonrails.org/i18n.html) for an example of its usage.
|
16
|
+
|
17
|
+
### Ruby (without Rails)
|
18
|
+
|
19
|
+
If you want to use this library without Rails, you can simply add `i18n` to your `Gemfile`:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'i18n'
|
23
|
+
```
|
24
|
+
|
25
|
+
Then configure I18n with some translations, and a default locale:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
I18n.load_path << Dir[File.expand_path("config/locales") + "/*.yml"]
|
29
|
+
I18n.default_locale = :en # (note that `en` is already the default!)
|
30
|
+
```
|
31
|
+
|
32
|
+
A simple translation file in your project might live at `config/locales/en.yml` and look like:
|
33
|
+
|
34
|
+
```yml
|
35
|
+
en:
|
36
|
+
test: "This is a test"
|
37
|
+
```
|
38
|
+
|
39
|
+
You can then access this translation by doing:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
I18n.t(:test)
|
43
|
+
```
|
44
|
+
|
45
|
+
You can switch locales in your project by setting `I18n.locale` to a different value:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
I18n.locale = :de
|
49
|
+
I18n.t(:test) # => "Dies ist ein Test"
|
50
|
+
```
|
51
|
+
|
52
|
+
## Features
|
10
53
|
|
11
54
|
* translation and localization
|
12
55
|
* interpolation of values to translations (Ruby 1.9 compatible syntax)
|
@@ -19,7 +62,7 @@ Features:
|
|
19
62
|
* custom exception handlers
|
20
63
|
* extensible architecture with a swappable backend
|
21
64
|
|
22
|
-
Pluggable
|
65
|
+
## Pluggable Features
|
23
66
|
|
24
67
|
* Cache
|
25
68
|
* Pluralization: lambda pluralizers stored as translation data
|
@@ -27,7 +70,7 @@ Pluggable features:
|
|
27
70
|
* [Gettext support](https://github.com/svenfuchs/i18n/wiki/Gettext)
|
28
71
|
* Translation metadata
|
29
72
|
|
30
|
-
Alternative
|
73
|
+
## Alternative Backend
|
31
74
|
|
32
75
|
* Chain
|
33
76
|
* ActiveRecord (optionally: ActiveRecord::Missing and ActiveRecord::StoreProcs)
|
@@ -35,12 +78,6 @@ Alternative backends:
|
|
35
78
|
|
36
79
|
For more information and lots of resources see [the 'Resources' page on the wiki](https://github.com/svenfuchs/i18n/wiki/Resources).
|
37
80
|
|
38
|
-
## Installation
|
39
|
-
|
40
|
-
```
|
41
|
-
gem install i18n
|
42
|
-
```
|
43
|
-
|
44
81
|
## Tests
|
45
82
|
|
46
83
|
You can run tests both with
|
data/lib/i18n/backend/base.rb
CHANGED
data/lib/i18n/backend/simple.rb
CHANGED
@@ -59,6 +59,14 @@ module I18n
|
|
59
59
|
super
|
60
60
|
end
|
61
61
|
|
62
|
+
def translations(do_init: false)
|
63
|
+
# To avoid returning empty translations,
|
64
|
+
# call `init_translations`
|
65
|
+
init_translations if do_init && !initialized?
|
66
|
+
|
67
|
+
@translations ||= {}
|
68
|
+
end
|
69
|
+
|
62
70
|
protected
|
63
71
|
|
64
72
|
def init_translations
|
@@ -66,10 +74,6 @@ module I18n
|
|
66
74
|
@initialized = true
|
67
75
|
end
|
68
76
|
|
69
|
-
def translations
|
70
|
-
@translations ||= {}
|
71
|
-
end
|
72
|
-
|
73
77
|
# Looks up a translation from the translations hash. Returns nil if
|
74
78
|
# either key is nil, or locale, scope or key do not exist as a key in the
|
75
79
|
# nested translations hash. Splits keys or scopes containing dots
|
data/lib/i18n/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Fuchs
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2018-
|
16
|
+
date: 2018-10-14 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: concurrent-ruby
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- lib/i18n/backend/transliterator.rb
|
63
63
|
- lib/i18n/config.rb
|
64
64
|
- lib/i18n/core_ext/hash.rb
|
65
|
-
- lib/i18n/core_ext/kernel/suppress_warnings.rb
|
66
65
|
- lib/i18n/core_ext/string/interpolate.rb
|
67
66
|
- lib/i18n/exceptions.rb
|
68
67
|
- lib/i18n/gettext.rb
|
@@ -135,7 +134,11 @@ files:
|
|
135
134
|
homepage: http://github.com/svenfuchs/i18n
|
136
135
|
licenses:
|
137
136
|
- MIT
|
138
|
-
metadata:
|
137
|
+
metadata:
|
138
|
+
bug_tracker_uri: https://github.com/svenfuchs/i18n/issues
|
139
|
+
changelog_uri: https://github.com/svenfuchs/i18n/releases
|
140
|
+
documentation_uri: https://guides.rubyonrails.org/i18n.html
|
141
|
+
source_code_uri: https://github.com/svenfuchs/i18n
|
139
142
|
post_install_message:
|
140
143
|
rdoc_options: []
|
141
144
|
require_paths:
|
@@ -152,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
155
|
version: 1.3.5
|
153
156
|
requirements: []
|
154
157
|
rubyforge_project: "[none]"
|
155
|
-
rubygems_version: 2.7.
|
158
|
+
rubygems_version: 2.7.6
|
156
159
|
signing_key:
|
157
160
|
specification_version: 4
|
158
161
|
summary: New wave Internationalization support for Ruby
|