bisu 1.8.0 → 1.9.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
  SHA256:
3
- metadata.gz: 2db1130663e6afdca1e4d1b22d34c5863db2f120cee81c1c802d69999b1c094b
4
- data.tar.gz: 6f0cfd04fd34bb489055eaa0211aa74691f50f32c5fb13d8b7a1559c68a0f25a
3
+ metadata.gz: 14ce8b0b059747d79f5a63fc910129774a634d015bf02563ac888dc80c735ed0
4
+ data.tar.gz: 5158d8f04815351d0850c52d948a2dcebb5bb267a8154e716c31d01334fdd379
5
5
  SHA512:
6
- metadata.gz: b2d8325f651a93ca9bc2edb7108af31ebc5d1e3d5e954c8a8890a1a7985d2afababe15166ca4d909984a0be453d6f6ad8965eb44b4e1588bd970bc0e3d9669af
7
- data.tar.gz: 67699cebd837fc150ae54b433fb3386d79617211ff988b64bca73d681cd8daaeb6202c1e84280d1cfcf39a906c0930272c9f5f237f8d1eb187d856b0494570af
6
+ metadata.gz: 2773ab4e5ea6f8b0f419650e2cd4f551dacfb43d438e892a98bb9ca317774a82c61122ad232de1cd1ede184178ac502352bc356702144b70f73b7912a23adcba
7
+ data.tar.gz: 1bae10ebc6fb6a915d2c2122b4ceff3341b426eb47543b9e1502242e47804aa9599ef3c22f4abd62b915177d83d4a0b6a3cf08f8e7fa4aaa5ae505a8c3538429
data/.rspec CHANGED
@@ -1,5 +1,4 @@
1
1
  --color
2
2
  --format documentation
3
3
  --profile
4
- --drb
5
4
  --require spec_helper
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.0
1
+ 2.7.3
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.9.0](https://github.com/hole19/bisu/releases/tag/v1.9.0)
6
+ Released on 2021/05/21
7
+
8
+ #### Added
9
+ - Adds a new option to surpress missing params when that's intentional: add "//ignore-params" to the end of the translation key
10
+
5
11
  ## [1.8.0](https://github.com/hole19/bisu/releases/tag/v1.8.0)
6
12
  Released on 2020/04/30
7
13
 
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
- ruby '2.5.0'
2
+ ruby '2.7.3'
3
3
 
4
4
  gem 'safe_yaml', '~> 1.0'
5
5
  gem 'colorize', '~> 0.7'
data/Gemfile.lock CHANGED
@@ -4,34 +4,35 @@ GEM
4
4
  addressable (2.7.0)
5
5
  public_suffix (>= 2.0.2, < 5.0)
6
6
  colorize (0.8.1)
7
- crack (0.4.3)
8
- safe_yaml (~> 1.0.0)
9
- diff-lcs (1.3)
7
+ crack (0.4.5)
8
+ rexml
9
+ diff-lcs (1.4.4)
10
10
  hashdiff (1.0.1)
11
- public_suffix (4.0.3)
12
- rake (13.0.1)
13
- rspec (3.9.0)
14
- rspec-core (~> 3.9.0)
15
- rspec-expectations (~> 3.9.0)
16
- rspec-mocks (~> 3.9.0)
17
- rspec-core (3.9.1)
18
- rspec-support (~> 3.9.1)
19
- rspec-expectations (3.9.0)
11
+ public_suffix (4.0.6)
12
+ rake (13.0.3)
13
+ rexml (3.2.5)
14
+ rspec (3.10.0)
15
+ rspec-core (~> 3.10.0)
16
+ rspec-expectations (~> 3.10.0)
17
+ rspec-mocks (~> 3.10.0)
18
+ rspec-core (3.10.1)
19
+ rspec-support (~> 3.10.0)
20
+ rspec-expectations (3.10.1)
20
21
  diff-lcs (>= 1.2.0, < 2.0)
21
- rspec-support (~> 3.9.0)
22
+ rspec-support (~> 3.10.0)
22
23
  rspec-its (1.3.0)
23
24
  rspec-core (>= 3.0.0)
24
25
  rspec-expectations (>= 3.0.0)
25
- rspec-mocks (3.9.1)
26
+ rspec-mocks (3.10.2)
26
27
  diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.9.0)
28
- rspec-support (3.9.2)
28
+ rspec-support (~> 3.10.0)
29
+ rspec-support (3.10.2)
29
30
  safe_yaml (1.0.5)
30
31
  webmock (1.24.6)
31
32
  addressable (>= 2.3.6)
32
33
  crack (>= 0.3.2)
33
34
  hashdiff
34
- xml-simple (1.1.5)
35
+ xml-simple (1.1.8)
35
36
 
36
37
  PLATFORMS
37
38
  ruby
@@ -46,7 +47,7 @@ DEPENDENCIES
46
47
  xml-simple (~> 1.1)
47
48
 
48
49
  RUBY VERSION
49
- ruby 2.5.0p0
50
+ ruby 2.7.3p183
50
51
 
51
52
  BUNDLED WITH
52
- 1.17.2
53
+ 2.1.4
data/README.md CHANGED
@@ -24,7 +24,7 @@ Usage
24
24
  1. Run: `bisu`
25
25
  1. That's it!*
26
26
 
27
- *given that someone already configured Bisu
27
+ \*_given that someone already configured Bisu_
28
28
 
29
29
  Setup your configuration file
30
30
  -----
@@ -32,15 +32,15 @@ module Bisu
32
32
  unless t.gsub!(l[:match], localized)
33
33
  Logger.warn("Could not find translation for #{l[:match]} in #{language}")
34
34
  end
35
+
36
+ unless @type.eql?(:ror) || l[:ignore_param_warn] == true
37
+ localized.scan(/%{[^}]+}/) { |match| Logger.error("Could not find translation param for #{match} in #{language}") }
38
+ end
35
39
  else
36
40
  Logger.warn("Could not find translation for #{l[:match]} in #{language}")
37
41
  end
38
42
  end
39
43
 
40
- unless @type.eql?(:ror)
41
- t.scan(/%{[^}]+}/) { |match| Logger.error("Could not find translation param for #{match} in #{language}") }
42
- end
43
-
44
44
  t
45
45
  end
46
46
 
@@ -57,7 +57,7 @@ module Bisu
57
57
  private
58
58
 
59
59
  def to_localize(text)
60
- all_matches = text.to_enum(:scan, /\$([^\$\{]+)(?:\{(.+)\})?\$/).map { Regexp.last_match }
60
+ all_matches = text.to_enum(:scan, /\$([^\$\{\/]+)(?:\{(.+)\})?(\/\/ignore-params)?\$/).map { Regexp.last_match }
61
61
  all_matches.map do |match|
62
62
  params = if match[2]
63
63
  params = match[2].split(",").map(&:strip).map do |param|
@@ -67,9 +67,12 @@ module Bisu
67
67
  Hash[params]
68
68
  end
69
69
 
70
- { match: match[0],
70
+ {
71
+ match: match[0],
71
72
  key: match[1],
72
- params: params || {} }
73
+ params: params || {},
74
+ ignore_param_warn: text.include?("//ignore-params")
75
+ }
73
76
  end
74
77
  end
75
78
 
data/lib/bisu/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Bisu
2
- VERSION = '1.8.0'
3
- VERSION_UPDATED_AT = '2020-04-30'
2
+ VERSION = '1.9.0'
3
+ VERSION_UPDATED_AT = '2021-05-21'
4
4
  end
@@ -1,4 +1,9 @@
1
1
  describe Bisu::Localizer do
2
+ def translates(text, fallbacks: [], to:, lang: nil)
3
+ translation = localizer.localize(text, lang || language, locale, fallbacks)
4
+ expect(translation).to eq to
5
+ end
6
+
2
7
  let(:language) { "Portuguese" }
3
8
  let(:locale) { "pt-PT" }
4
9
 
@@ -33,11 +38,6 @@ describe Bisu::Localizer do
33
38
  shared_examples_for "a localizer" do
34
39
  it { expect { localizer }.not_to raise_error }
35
40
 
36
- def translates(text, fallbacks: [], to:, lang: nil)
37
- translation = localizer.localize(text, lang || language, locale, fallbacks)
38
- expect(translation).to eq to
39
- end
40
-
41
41
  it { translates("a line with no key", to: "a line with no key") }
42
42
 
43
43
  it { translates("this special key: $specialKComment1$", to: "this special key: This file was automatically generated based on a translation template.") }
@@ -87,7 +87,7 @@ describe Bisu::Localizer do
87
87
  .and not_change { Bisu::Logger.summary[:error] }
88
88
  end
89
89
 
90
- it "throws an error when missing key parameters (expect on ruby on rails)" do
90
+ it "throws a error when missing key parameters (expect on ruby on rails)" do
91
91
  if type == :ror
92
92
  expect {
93
93
  localizer.localize("$k1ParameterKey$", language, locale)
@@ -114,6 +114,17 @@ describe Bisu::Localizer do
114
114
  }.to not_change { Bisu::Logger.summary[:warn] }
115
115
  .and change { Bisu::Logger.summary[:error] }.by(1)
116
116
  end
117
+
118
+ # non localizable text with params
119
+
120
+ it "does not try to translate params outside $$" do
121
+ translates("%{some_text}", to: "%{some_text}")
122
+
123
+ expect {
124
+ localizer.localize("%{some_text}", language, locale)
125
+ }.to not_change { Bisu::Logger.summary[:warn] }
126
+ .and not_change { Bisu::Logger.summary[:error] }
127
+ end
117
128
  end
118
129
 
119
130
  let(:type_dependent_defaults) { {
@@ -134,6 +145,33 @@ describe Bisu::Localizer do
134
145
  ) }
135
146
 
136
147
  it_behaves_like "a localizer"
148
+
149
+ context "when a parameter replacemnt was not defined" do
150
+ let(:line) { "1 parameter: $k1ParameterKey$" }
151
+ let(:expected) { "1 parameter: Não sabes nada %{name}" }
152
+
153
+ it { translates(line, to: expected) }
154
+
155
+ it "returns an error" do
156
+ expect {
157
+ localizer.localize(line, language, locale)
158
+ }.to not_change { Bisu::Logger.summary[:warn] }
159
+ .and change { Bisu::Logger.summary[:error] }.by(1)
160
+ end
161
+
162
+ context "when passing //ignore-params" do
163
+ let(:line) { "1 parameter: $k1ParameterKey//ignore-params$" }
164
+
165
+ it { translates(line, to: expected) }
166
+
167
+ it "does not return an error" do
168
+ expect {
169
+ localizer.localize(line, language, locale)
170
+ }.to not_change { Bisu::Logger.summary[:warn] }
171
+ .and not_change { Bisu::Logger.summary[:error] }
172
+ end
173
+ end
174
+ end
137
175
  end
138
176
 
139
177
  describe "of type Android" do
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.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - joaoffcosta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-30 00:00:00.000000000 Z
11
+ date: 2021-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safe_yaml
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.1.2
134
+ rubygems_version: 3.1.6
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: A localization automation service