bisu 1.8.0 → 1.9.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/.rspec +0 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +20 -19
- data/README.md +1 -1
- data/lib/bisu/localizer.rb +10 -7
- data/lib/bisu/version.rb +2 -2
- data/spec/lib/bisu/localizer_spec.rb +44 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14ce8b0b059747d79f5a63fc910129774a634d015bf02563ac888dc80c735ed0
|
4
|
+
data.tar.gz: 5158d8f04815351d0850c52d948a2dcebb5bb267a8154e716c31d01334fdd379
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2773ab4e5ea6f8b0f419650e2cd4f551dacfb43d438e892a98bb9ca317774a82c61122ad232de1cd1ede184178ac502352bc356702144b70f73b7912a23adcba
|
7
|
+
data.tar.gz: 1bae10ebc6fb6a915d2c2122b4ceff3341b426eb47543b9e1502242e47804aa9599ef3c22f4abd62b915177d83d4a0b6a3cf08f8e7fa4aaa5ae505a8c3538429
|
data/.rspec
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
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
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.
|
8
|
-
|
9
|
-
diff-lcs (1.
|
7
|
+
crack (0.4.5)
|
8
|
+
rexml
|
9
|
+
diff-lcs (1.4.4)
|
10
10
|
hashdiff (1.0.1)
|
11
|
-
public_suffix (4.0.
|
12
|
-
rake (13.0.
|
13
|
-
|
14
|
-
|
15
|
-
rspec-
|
16
|
-
rspec-
|
17
|
-
|
18
|
-
|
19
|
-
|
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.
|
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.
|
26
|
+
rspec-mocks (3.10.2)
|
26
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
-
rspec-support (~> 3.
|
28
|
-
rspec-support (3.
|
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.
|
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.
|
50
|
+
ruby 2.7.3p183
|
50
51
|
|
51
52
|
BUNDLED WITH
|
52
|
-
1.
|
53
|
+
2.1.4
|
data/README.md
CHANGED
data/lib/bisu/localizer.rb
CHANGED
@@ -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
|
-
{
|
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,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
|
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.
|
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:
|
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.
|
134
|
+
rubygems_version: 3.1.6
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: A localization automation service
|