transync 1.1.1 → 1.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49efb85a09f9890df8eba832d04c506230170c66
|
4
|
+
data.tar.gz: 7c49b7c23956526668d1dac41e33bc4fae6f5054
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5414c79018b18062005a39dbd9c439189fdc86e5c0870b8d5c2e6023e61379cfea363c50de03e0df1a7520c69c557fdaba91163be43cf8062ec0281768cfdb76
|
7
|
+
data.tar.gz: 6f3aa8575a1905f67f8597169d8d66c160c490c1038da9fbc5cd006e7895a33a419b4e4c35af1c5856ac9f57f8d8f50c90887d94ca7f28f582077d389db12e22
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'colorize'
|
1
2
|
require_relative '../transync_config'
|
2
3
|
|
3
4
|
class GdocTransReader
|
@@ -5,8 +6,8 @@ class GdocTransReader
|
|
5
6
|
|
6
7
|
# file represents tab in spreadsheet
|
7
8
|
def initialize(file)
|
8
|
-
@worksheet = TransyncConfig
|
9
|
-
abort("#{file} tab is not defined in GDoc") if @worksheet.nil?
|
9
|
+
@worksheet = TransyncConfig.worksheets.detect{ |w| w.title == file }
|
10
|
+
abort("\u{2717} '#{file}' tab is not defined in GDoc".colorize(:red)) if @worksheet.nil?
|
10
11
|
end
|
11
12
|
|
12
13
|
def translations(language)
|
data/lib/transync/runner.rb
CHANGED
@@ -22,7 +22,9 @@ module Transync
|
|
22
22
|
TransyncConfig::CONFIG['FILES'].each do |file|
|
23
23
|
xliff_files = XliffTransReader.new(PATH, file, TransyncConfig::CONFIG['LANGUAGES'])
|
24
24
|
puts "\u{2713} '#{file}' have all the keys for all languages in XLIFF files.".colorize(:green) if xliff_files.valid?
|
25
|
+
end
|
25
26
|
|
27
|
+
TransyncConfig::CONFIG['FILES'].each do |file|
|
26
28
|
TransyncConfig::CONFIG['LANGUAGES'].each do |language|
|
27
29
|
trans_sync = TranslationSync.new(PATH, 'test', file)
|
28
30
|
|
@@ -32,7 +34,6 @@ module Transync
|
|
32
34
|
puts "\u{2717} '#{file}.#{language}' XLIFF is NOT in sync with GDoc. See diff!".colorize(:red)
|
33
35
|
end
|
34
36
|
end
|
35
|
-
|
36
37
|
puts '----------'
|
37
38
|
end
|
38
39
|
end
|
data/lib/transync/sync/init.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
1
3
|
class Init
|
2
4
|
|
3
5
|
def initialize(path)
|
@@ -7,10 +9,10 @@ class Init
|
|
7
9
|
|
8
10
|
def run
|
9
11
|
@config['FILES'].each do |file|
|
10
|
-
worksheet = TransyncConfig
|
12
|
+
worksheet = TransyncConfig.worksheets.detect{ |s| s.title == file }
|
11
13
|
if worksheet.nil?
|
12
|
-
worksheet = TransyncConfig
|
13
|
-
|
14
|
+
worksheet = TransyncConfig.spreadsheet.add_worksheet(file)
|
15
|
+
puts "\u{2713} adding '#{file}' worksheet to spreadsheet with first row (key and languages)".colorize(:green)
|
14
16
|
end
|
15
17
|
|
16
18
|
worksheet[1, 1] = 'Key'
|
@@ -21,9 +23,9 @@ class Init
|
|
21
23
|
end
|
22
24
|
|
23
25
|
# re-init spreadsheet after new worksheets were created
|
24
|
-
TransyncConfig.
|
26
|
+
TransyncConfig.re_init
|
25
27
|
sync = TranslationSync.new(@path, 'x2g')
|
26
|
-
sync.run('x2g'
|
28
|
+
sync.run('x2g')
|
27
29
|
end
|
28
30
|
|
29
31
|
end
|
@@ -17,16 +17,17 @@ class TranslationSync
|
|
17
17
|
xliff_files = XliffTransReader.new(@path, file, @config['LANGUAGES'])
|
18
18
|
abort('Fix your Xliff translations by hand or run transync update!') unless xliff_files.valid?
|
19
19
|
|
20
|
+
gdoc_trans_reader = GdocTransReader.new(file)
|
21
|
+
gdoc_trans_writer = GdocTransWriter.new(gdoc_trans_reader.worksheet)
|
22
|
+
xliff_trans_writer = XliffTransWriter.new(@path, file)
|
23
|
+
|
20
24
|
@config['LANGUAGES'].each do |language|
|
21
25
|
trans_sync = TranslationSync.new(@path, direction, file)
|
22
26
|
trans_hash = trans_sync.sync(language, direction)
|
23
27
|
|
24
28
|
if direction == 'x2g'
|
25
|
-
gdoc_trans_reader = GdocTransReader.new(file)
|
26
|
-
gdoc_trans_writer = GdocTransWriter.new(gdoc_trans_reader.worksheet)
|
27
29
|
gdoc_trans_writer.write(trans_hash)
|
28
30
|
else
|
29
|
-
xliff_trans_writer = XliffTransWriter.new(@path, file)
|
30
31
|
xliff_trans_writer.write(trans_hash)
|
31
32
|
end
|
32
33
|
end
|
@@ -8,6 +8,9 @@ module TransyncConfig
|
|
8
8
|
WORKSHEET_COLUMNS = { key: 1 }
|
9
9
|
START_ROW = 2
|
10
10
|
|
11
|
+
@spreadsheet = nil
|
12
|
+
@worksheets = nil
|
13
|
+
|
11
14
|
def self.init_spreadsheet
|
12
15
|
session = GoogleDrive.login(CONFIG['GDOC']['email'], CONFIG['GDOC']['password'])
|
13
16
|
spreadsheet = session.spreadsheet_by_key(CONFIG['GDOC']['key'])
|
@@ -16,18 +19,33 @@ module TransyncConfig
|
|
16
19
|
return spreadsheet, worksheets
|
17
20
|
end
|
18
21
|
|
22
|
+
# This gets executed automatically when module is evaluated (required?)
|
19
23
|
begin
|
20
24
|
CONFIG = YAML.load(File.open('transync.yml'))
|
21
|
-
|
25
|
+
@spreadsheet, @worksheets = TransyncConfig.init_spreadsheet
|
26
|
+
|
27
|
+
# populate languages dynamically from settings yaml file
|
28
|
+
CONFIG['LANGUAGES'].each_with_index do |language, index|
|
29
|
+
key = language
|
30
|
+
value = index + 2
|
31
|
+
WORKSHEET_COLUMNS[key.to_sym] = value
|
32
|
+
end
|
22
33
|
rescue => e
|
23
34
|
p e.message
|
24
35
|
exit(1)
|
25
36
|
end
|
26
37
|
|
27
|
-
#
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
38
|
+
# used for init command after we create new tabs
|
39
|
+
def self.re_init
|
40
|
+
@spreadsheet, @worksheets = TransyncConfig.init_spreadsheet
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.worksheets
|
44
|
+
@worksheets
|
32
45
|
end
|
46
|
+
|
47
|
+
def self.spreadsheet
|
48
|
+
@spreadsheet
|
49
|
+
end
|
50
|
+
|
33
51
|
end
|
data/lib/transync/version.rb
CHANGED