mini_i18n 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a18d6e7a53f09252437f9557843123ec13e0838
4
- data.tar.gz: 07a9b806306b8d5fd249de308fda043f4f855b41
3
+ metadata.gz: 81feeddc633b545c465eea9b1c419d270956f597
4
+ data.tar.gz: c940b1d74bf3a8714c605b3f2365831cb2fbf054
5
5
  SHA512:
6
- metadata.gz: d2b2e9c69c77528d54bbd24d723441d0cbe009001855ce77fe69fe164738956ec021e5ccb6288adf588997c50735a305336b1da7ace3186f8239c9afedd3e4a1
7
- data.tar.gz: 0ae3f4faa23a0f81088d7180afa463b419f2309af6b0aedc715bb853208b4f7cd0bf91b4a3eecc2eabdb8037db00a83029fb35ed65925f2cc0b134340a2db9c8
6
+ metadata.gz: bf623e2f56bc7b856e5b570274cf27241ea48e1bc8df4439c8d0e703ba501fa95615b85c7f617ae37463dfcd5ce134d91aa0cf19e61c1818263a5bae1b1177a8
7
+ data.tar.gz: 74db4f15f394be6af3610f09d9155eafc929a8fad0862a644d7b7cbd08b63bec399bdfe11ab45f0ffb8d3a0cbde4264aaf963b25aad749f7f31faf1eab241164
@@ -1,3 +1,3 @@
1
1
  module MiniI18n
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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 = valid_locale?(new_locale) || 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
- _translations = YAML.load_file(file)
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
 
@@ -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.1.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-17 00:00:00.000000000 Z
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: Minimalist I18n library
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