bisu 1.10.1 → 1.10.2
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/CHANGELOG.md +12 -0
- data/README.md +1 -0
- data/generic.translatable.yml +1 -0
- data/lib/bisu/config.rb +1 -0
- data/lib/bisu/source/google_sheet.rb +3 -2
- data/lib/bisu/version.rb +1 -1
- data/lib/bisu.rb +13 -2
- data/spec/fixtures/sample.translatable.yml +1 -0
- data/spec/fixtures/sample_google_response.csv +1 -1
- data/spec/lib/bisu/config_spec.rb +2 -1
- data/spec/lib/bisu/source/google_sheet_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd090e1e936ebc979392e5ba1cb44657bf0c716fdadbc1566f3aafa8252ff3dd
|
4
|
+
data.tar.gz: 89b8897c02e0ef9eba1945c125b43e4dff1fc38db73017d2eeca8b3ebb16674c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 521148f8d23cb2bc308eab074f90c2b964cee468a3fa65594504153d834b4878fd4b1dc9fcc96c7a04064e909b534bc6cafec49b199164d3b5d8310f215f8e36
|
7
|
+
data.tar.gz: a011abe84e8c72ef2ad755f64595141f03acbd7367b70c321fb867f059f3891debd4878545acfaa8bb7f59b5ea1562aae3683430d7613d05244249af6ce67315
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
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.10.2](https://github.com/hole19/bisu/releases/tag/v1.10.2)
|
6
|
+
Released on 2021/08/30
|
7
|
+
|
8
|
+
#### Fixed
|
9
|
+
- Fixes bug where we were assuming "key" would always be the translations-key column title
|
10
|
+
|
11
|
+
## [1.10.1](https://github.com/hole19/bisu/releases/tag/v1.10.1)
|
12
|
+
Released on 2021/08/30
|
13
|
+
|
14
|
+
#### Fixed
|
15
|
+
- Crash caused by an unexpected redirect
|
16
|
+
|
5
17
|
## [1.10.0](https://github.com/hole19/bisu/releases/tag/v1.10.0)
|
6
18
|
Released on 2021/08/30
|
7
19
|
|
data/README.md
CHANGED
data/generic.translatable.yml
CHANGED
data/lib/bisu/config.rb
CHANGED
@@ -4,8 +4,9 @@ require "csv"
|
|
4
4
|
module Bisu
|
5
5
|
module Source
|
6
6
|
class GoogleSheet
|
7
|
-
def initialize(url)
|
7
|
+
def initialize(url, keys_column)
|
8
8
|
@url = url
|
9
|
+
@keys_column = keys_column
|
9
10
|
end
|
10
11
|
|
11
12
|
def to_i18
|
@@ -20,7 +21,7 @@ module Bisu
|
|
20
21
|
|
21
22
|
csv.each do |row|
|
22
23
|
languages.each do |lang|
|
23
|
-
hash[lang][row[
|
24
|
+
hash[lang][row[@keys_column]] = row[lang] unless row[lang].nil?
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
data/lib/bisu/version.rb
CHANGED
data/lib/bisu.rb
CHANGED
@@ -59,7 +59,7 @@ module Bisu
|
|
59
59
|
source =
|
60
60
|
case config[:type]
|
61
61
|
when "google_sheet"
|
62
|
-
Bisu::Source::GoogleSheet.new(config[:url])
|
62
|
+
Bisu::Source::GoogleSheet.new(config[:url], config[:keys_column])
|
63
63
|
when "one_sky"
|
64
64
|
Bisu::Source::OneSky.new(config[:api_key], config[:api_secret], config[:project_id], config[:file_name])
|
65
65
|
when "url"
|
@@ -70,7 +70,7 @@ module Bisu
|
|
70
70
|
|
71
71
|
save_to_path = options[:dictionary_save_path]
|
72
72
|
if save_to_path && file = open_file(save_to_path, "w", false)
|
73
|
-
file.write(source.to_json)
|
73
|
+
file.write(deep_force_encoding(source).to_json)
|
74
74
|
file.flush
|
75
75
|
file.close
|
76
76
|
end
|
@@ -149,4 +149,15 @@ module Bisu
|
|
149
149
|
|
150
150
|
true
|
151
151
|
end
|
152
|
+
|
153
|
+
def deep_force_encoding(hash)
|
154
|
+
hash.each do |_, value|
|
155
|
+
case value
|
156
|
+
when String
|
157
|
+
value.force_encoding(Encoding::UTF_8)
|
158
|
+
when Hash
|
159
|
+
deep_force_encoding(value)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
152
163
|
end
|
@@ -6,6 +6,7 @@ describe Bisu::Config do
|
|
6
6
|
dictionary: {
|
7
7
|
type: "google_sheet",
|
8
8
|
url: "https://abc1234567890",
|
9
|
+
keys_column: "key name",
|
9
10
|
},
|
10
11
|
translate: [
|
11
12
|
{ in: "path/to/file/to/1.ext.translatable",
|
@@ -36,7 +37,7 @@ describe Bisu::Config do
|
|
36
37
|
describe "#dictionary" do
|
37
38
|
subject(:dictionary) { config.dictionary }
|
38
39
|
|
39
|
-
it { should eq({ type: "google_sheet", url: "https://abc1234567890" }) }
|
40
|
+
it { should eq({ type: "google_sheet", url: "https://abc1234567890", keys_column: "key name" }) }
|
40
41
|
|
41
42
|
context "when given a OneSky type dictionary" do
|
42
43
|
before do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Bisu::Source::GoogleSheet do
|
2
|
-
subject(:to_i18) { Bisu::Source::GoogleSheet.new(url).to_i18 }
|
2
|
+
subject(:to_i18) { Bisu::Source::GoogleSheet.new(url, "key name").to_i18 }
|
3
3
|
|
4
4
|
let(:url) { "https://docs.google.com/spreadsheets/d/e/2PACX-1vTm6yu_zfbxKizC-PvUE1HVFCsplmiyz0s0qLSIGeokA7KtS3BgtqaA79CsfYfPsXH6xzUaP8HDTcj8/pub?gid=0&single=true&output=csv" }
|
5
5
|
let(:response) { File.read("spec/fixtures/sample_google_response.csv") }
|