mini_i18n 0.1.0 → 0.2.0
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 +4 -4
- data/lib/mini_i18n/version.rb +1 -1
- data/lib/mini_i18n.rb +2 -3
- data/spec/mini_i18n_spec.rb +18 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81feeddc633b545c465eea9b1c419d270956f597
|
4
|
+
data.tar.gz: c940b1d74bf3a8714c605b3f2365831cb2fbf054
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf623e2f56bc7b856e5b570274cf27241ea48e1bc8df4439c8d0e703ba501fa95615b85c7f617ae37463dfcd5ce134d91aa0cf19e61c1818263a5bae1b1177a8
|
7
|
+
data.tar.gz: 74db4f15f394be6af3610f09d9155eafc929a8fad0862a644d7b7cbd08b63bec399bdfe11ab45f0ffb8d3a0cbde4264aaf963b25aad749f7f31faf1eab241164
|
data/lib/mini_i18n/version.rb
CHANGED
data/lib/mini_i18n.rb
CHANGED
@@ -14,7 +14,7 @@ module MiniI18n
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def default_locale=(new_locale)
|
17
|
-
@@default_locale =
|
17
|
+
@@default_locale = available_locale?(new_locale) || default_locale
|
18
18
|
end
|
19
19
|
|
20
20
|
def default_available_locales
|
@@ -47,8 +47,7 @@ module MiniI18n
|
|
47
47
|
|
48
48
|
def load_translations(path)
|
49
49
|
Dir[path].each do |file|
|
50
|
-
|
51
|
-
_translations.each do |locale, values|
|
50
|
+
YAML.load_file(file).each do |locale, values|
|
52
51
|
locale = locale.to_s
|
53
52
|
@@available_locales << locale unless available_locale?(locale)
|
54
53
|
|
data/spec/mini_i18n_spec.rb
CHANGED
@@ -16,6 +16,24 @@ RSpec.describe MiniI18n do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
describe 'default_locale=' do
|
20
|
+
it 'defaults to default_locale if locale is not valid' do
|
21
|
+
MiniI18n.default_locale = :foo
|
22
|
+
|
23
|
+
expect(MiniI18n.default_locale).to eq :en
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'locale' do
|
28
|
+
it 'allows to change locale globally' do
|
29
|
+
MiniI18n.locale = :en
|
30
|
+
expect(MiniI18n.t(:hello)).to eq 'hello'
|
31
|
+
|
32
|
+
MiniI18n.locale = :es
|
33
|
+
expect(MiniI18n.t(:hello)).to eq 'hola'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
19
37
|
describe 'translate' do
|
20
38
|
it "simple key" do
|
21
39
|
expect(MiniI18n.t(:hello)).to eq 'hello'
|
@@ -55,14 +73,4 @@ RSpec.describe MiniI18n do
|
|
55
73
|
expect(MiniI18n.t('fallback', locale: :es)).to eq 'fallback'
|
56
74
|
end
|
57
75
|
end
|
58
|
-
|
59
|
-
describe 'locale' do
|
60
|
-
it 'allows to change locale globally' do
|
61
|
-
MiniI18n.locale = :en
|
62
|
-
expect(MiniI18n.t(:hello)).to eq 'hello'
|
63
|
-
|
64
|
-
MiniI18n.locale = :es
|
65
|
-
expect(MiniI18n.t(:hello)).to eq 'hola'
|
66
|
-
end
|
67
|
-
end
|
68
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- markets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -103,7 +103,7 @@ rubyforge_project:
|
|
103
103
|
rubygems_version: 2.6.13
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
|
-
summary:
|
106
|
+
summary: Minimalistic I18n library for Ruby
|
107
107
|
test_files:
|
108
108
|
- spec/fixtures/locales/en.yml
|
109
109
|
- spec/fixtures/locales/multiple.yml
|