bisu 1.4.4 → 1.4.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33b84e9bf0f3646a3679b0f9dddf54d8fc037fe3
4
- data.tar.gz: d3ef51a9fb26c9f0850a215fbfc2f86bd128b7e7
3
+ metadata.gz: ea9e6d2accc2fafbdeed0a092b5ed21997ea66ab
4
+ data.tar.gz: 0a785a6712aedc9aac39f8849efb83eff5c5882b
5
5
  SHA512:
6
- metadata.gz: efeae832bf35b4dea2bd76933527260ed93d8da737ff6e7a8d386351531dab1b362ddcf2563cf630429920e2ec43c4a3e8dbd6ee33f107531c6bc5e3be3aef5b
7
- data.tar.gz: d3aef119028db40c390020ed8f3f16c26adc364928e1e3ed150e6d75b114d9197728cdb3440955d59e5aad40a8076cfeedf1edb91b50461c4c8df44bfa68069a
6
+ metadata.gz: 8a09a27574016692e26546b12f786d3489f72bb4ae486a005693f222107e76462f72927fe8a3296888e406fa0d12e3f47d5c5b1c30d6f5620054171a178e7c14
7
+ data.tar.gz: 710006d6f544ee38d1fb72f1eb38c0c278d1a64fc7c59824198adff88d465c710354ee816631fa99b2377b2b6b7b73c5aa7f5c6abbf1587ebf3048968bb69e72
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  `Bisu` adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [1.4.5](https://github.com/hole19/bisu/releases/tag/v1.4.5)
6
+ Released on 2017/06/26
7
+
8
+ #### Added
9
+ - Fixes https://github.com/hole19/bisu/issues/3
10
+
5
11
  ## [1.4.4](https://github.com/hole19/bisu/releases/tag/v1.4.4)
6
12
  Released on 2017/03/13
7
13
 
@@ -17,16 +17,16 @@ module Bisu
17
17
  end
18
18
  end
19
19
 
20
- @keys = keys
20
+ @keys = Hash[keys.map { |k,v| [k.downcase, v] }]
21
21
  end
22
22
 
23
23
  def has_language?(language)
24
- @keys.include?(language)
24
+ @keys.include?(language&.downcase)
25
25
  end
26
26
 
27
27
  def localize(language, key)
28
28
  if has_language?(language)
29
- @keys[language][key]
29
+ @keys[language&.downcase][key]
30
30
  else
31
31
  nil
32
32
  end
data/lib/bisu/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Bisu
2
- VERSION = '1.4.4'
3
- VERSION_UPDATED_AT = '2017-03-13'
2
+ VERSION = '1.4.5'
3
+ VERSION_UPDATED_AT = '2017-06-26'
4
4
  end
@@ -44,6 +44,10 @@ describe Bisu::Dictionary do
44
44
  it "returns false if that language does not exist in any key" do
45
45
  expect(dict.has_language?("lang-no-available")).to be false
46
46
  end
47
+
48
+ it "returns true if that language is in another case" do
49
+ expect(dict.has_language?("Lang2")).to be true
50
+ end
47
51
  end
48
52
 
49
53
  describe "#localize" do
@@ -64,5 +68,9 @@ describe Bisu::Dictionary do
64
68
  it "returns nil when language is not available" do
65
69
  expect(dict.localize("finish", "kCray")).to be nil
66
70
  end
71
+
72
+ it "localizes a key when the language is in another case" do
73
+ expect(dict.localize("krioLo", "kCray")).to eq "Bo sta crazy!"
74
+ end
67
75
  end
68
76
  end
@@ -1,6 +1,6 @@
1
1
  describe Bisu::Localizer do
2
- let(:language) { "portuguese" }
3
- let(:locale) { "PT-PT" }
2
+ let(:language) { "Portuguese" }
3
+ let(:locale) { "pt-PT" }
4
4
 
5
5
  let(:keys) { {
6
6
  language => {
@@ -16,7 +16,7 @@ describe Bisu::Localizer do
16
16
  "kAmpersand" => "Não sabes nada João das Neves & Pícaros",
17
17
  "kAtSign" => "\@johnsnow sabes alguma coisa?"
18
18
  },
19
- "english" => {
19
+ "English" => {
20
20
  "kMissingTransKey" => "You know little John Snow"
21
21
  }
22
22
  } }
@@ -27,8 +27,8 @@ describe Bisu::Localizer do
27
27
  shared_examples_for "a localizer" do
28
28
  it { expect { localizer }.not_to raise_error }
29
29
 
30
- def translates(text, fallback: nil, to:)
31
- translation = localizer.localize(text, language, locale, fallback)
30
+ def translates(text, fallback: nil, to:, lang: nil)
31
+ translation = localizer.localize(text, lang || language, locale, fallback)
32
32
  expect(translation).to eq to
33
33
  end
34
34
 
@@ -40,9 +40,10 @@ describe Bisu::Localizer do
40
40
  it { translates("this special key: $specialKLocale$", to: "this special key: #{locale}") }
41
41
 
42
42
  it { translates("this key: $kTranslationKey$", to: "this key: Não sabes nada João das Neves") }
43
+ it { translates("this key: $kTranslationKey$", to: "this key: Não sabes nada João das Neves", lang: "portuguese") }
43
44
  it { translates("this unknown key: $kUnknownKey$", to: "this unknown key: $kUnknownKey$") }
44
45
  it { translates("this key with missing translations: $kMissingTransKey$", to: "this key with missing translations: $kMissingTransKey$") }
45
- it { translates("this key with missing translations: $kMissingTransKey$", fallback: "english", to: "this key with missing translations: You know little John Snow") }
46
+ it { translates("this key with missing translations: $kMissingTransKey$", fallback: "English", to: "this key with missing translations: You know little John Snow") }
46
47
  it { translates("these 2 keys: $kTranslationKey$, $kTranslationKey2$", to: "these 2 keys: Não sabes nada João das Neves, Naaada!") }
47
48
 
48
49
  it { translates("1 parameter: $k1ParameterKey$", to: "1 parameter: Não sabes nada %{name}") }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bisu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - joaoffcosta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-13 00:00:00.000000000 Z
11
+ date: 2017-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safe_yaml