locca 0.9.3 → 0.9.4
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/bin/locca +13 -1
- data/lib/locca.rb +28 -14
- data/lib/locca/actions/{sync_action.rb → onesky_sync_action.rb} +19 -15
- data/lib/locca/genstrings.rb +4 -1
- data/lib/locca/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bb1bf664519519f97a3250a89d70ef348a0efa90
|
|
4
|
+
data.tar.gz: 8b82a46b329742f94474f86ee2d6d1c41b01da38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d76dabd3da74919b09647e9ab6f0d5ce673d184d870ef656da73413c3f01b3bae7dba35690f4e027baca9d8366003584925c64e6f2255be6d853c4bd2861bb9a
|
|
7
|
+
data.tar.gz: ec1c116543af7a0ba1f2bddc62922efcc816b357437ac71e1d5d054a2326f1899fba753e3b84368973899252f3cd5af8b81dc90b8aab18b47b2f3befa9c7a037
|
data/bin/locca
CHANGED
|
@@ -60,7 +60,7 @@ command :merge do |c|
|
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
desc 'Sync translations with external translation service'
|
|
63
|
+
desc 'Sync (fetch, merge and upload new) translations with external translation service'
|
|
64
64
|
command :sync do |c|
|
|
65
65
|
c.action do |global_options, options, args|
|
|
66
66
|
work_dir = global_options['work-dir'.to_sym]
|
|
@@ -72,6 +72,18 @@ command :sync do |c|
|
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
+
desc 'Fetch and merge translations from external translation service'
|
|
76
|
+
command :fetch do |c|
|
|
77
|
+
c.action do |global_options, options, args|
|
|
78
|
+
work_dir = global_options['work-dir'.to_sym]
|
|
79
|
+
if not work_dir
|
|
80
|
+
work_dir = Dir.getwd
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
$locca.fetch(project_in_dir(work_dir))
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
75
87
|
desc 'Translate the untranslated'
|
|
76
88
|
command :translate do |c|
|
|
77
89
|
c.action do |global_options, options, args|
|
data/lib/locca.rb
CHANGED
|
@@ -33,7 +33,7 @@ require 'locca/config_validator'
|
|
|
33
33
|
|
|
34
34
|
require 'locca/actions/build_action'
|
|
35
35
|
require 'locca/actions/merge_action'
|
|
36
|
-
require 'locca/actions/
|
|
36
|
+
require 'locca/actions/onesky_sync_action'
|
|
37
37
|
require 'locca/actions/translate_action'
|
|
38
38
|
|
|
39
39
|
require 'locca/sync/onesky'
|
|
@@ -57,12 +57,7 @@ module Locca
|
|
|
57
57
|
raise 'Can\'t initialize Locca with nil project'
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
collection_builder = collection_builder()
|
|
62
|
-
collections_generator = CollectionsGenerator.new(genstrings, collection_builder)
|
|
63
|
-
|
|
64
|
-
action = BuildAction.new(project, collection_builder, collection_writer(), collections_generator, collection_merger())
|
|
65
|
-
action.execute()
|
|
60
|
+
build_action(project).execute()
|
|
66
61
|
end
|
|
67
62
|
|
|
68
63
|
def merge(src_file, dst_file)
|
|
@@ -75,14 +70,15 @@ module Locca
|
|
|
75
70
|
raise 'Can\'t initialize Locca with nil project'
|
|
76
71
|
end
|
|
77
72
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
collections_generator = CollectionsGenerator.new(genstrings, collection_builder)
|
|
81
|
-
|
|
82
|
-
onesky = Onesky.new(project.config_value_for_key('onesky_project_id'), project.config_value_for_key('onesky_public_key'), project.config_value_for_key('onesky_secret_key'))
|
|
73
|
+
one_sky_action(project).sync()
|
|
74
|
+
end
|
|
83
75
|
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
def fetch(project)
|
|
77
|
+
if not project
|
|
78
|
+
raise 'Can\'t initialize Locca with nil project'
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
one_sky_action(project).fetch()
|
|
86
82
|
end
|
|
87
83
|
|
|
88
84
|
def translate(project, lang = nil)
|
|
@@ -99,6 +95,24 @@ module Locca
|
|
|
99
95
|
action.execute()
|
|
100
96
|
end
|
|
101
97
|
|
|
98
|
+
def build_action(project)
|
|
99
|
+
genstrings = Genstrings.new()
|
|
100
|
+
collection_builder = collection_builder()
|
|
101
|
+
collections_generator = CollectionsGenerator.new(genstrings, collection_builder)
|
|
102
|
+
|
|
103
|
+
return BuildAction.new(project, collection_builder, collection_writer(), collections_generator, collection_merger())
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def one_sky_action(project)
|
|
107
|
+
genstrings = Genstrings.new()
|
|
108
|
+
collection_builder = collection_builder()
|
|
109
|
+
collections_generator = CollectionsGenerator.new(genstrings, collection_builder)
|
|
110
|
+
|
|
111
|
+
onesky = Onesky.new(project.config_value_for_key('onesky_project_id'), project.config_value_for_key('onesky_public_key'), project.config_value_for_key('onesky_secret_key'))
|
|
112
|
+
|
|
113
|
+
return OneskySyncAction.new(project, onesky, collection_builder(), collection_writer(), collections_generator, collection_merger())
|
|
114
|
+
end
|
|
115
|
+
|
|
102
116
|
def collection_builder()
|
|
103
117
|
parser = Babelyoda::StringsParser.new(Babelyoda::StringsLexer.new())
|
|
104
118
|
return CollectionBuilder.new(File, parser)
|
|
@@ -30,24 +30,24 @@
|
|
|
30
30
|
require 'locca/collection_merger'
|
|
31
31
|
|
|
32
32
|
module Locca
|
|
33
|
-
class
|
|
34
|
-
def initialize(project, collection_builder, collection_writer, collections_generator, collection_merger
|
|
33
|
+
class OneskySyncAction
|
|
34
|
+
def initialize(project, onesky, collection_builder, collection_writer, collections_generator, collection_merger)
|
|
35
35
|
@project = project
|
|
36
36
|
@collections_generator = collections_generator
|
|
37
37
|
@collection_merger = collection_merger
|
|
38
38
|
@collection_builder = collection_builder
|
|
39
39
|
@collection_writer = collection_writer
|
|
40
40
|
@onesky = onesky
|
|
41
|
-
end
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
@langs = @project.langs()
|
|
43
|
+
@generated_collections = @collections_generator.generate(@project.code_dir())
|
|
44
|
+
end
|
|
46
45
|
|
|
46
|
+
def fetch()
|
|
47
47
|
# 1
|
|
48
|
-
generated_collections.each do |generated_collection|
|
|
49
|
-
langs.each do |lang|
|
|
50
|
-
print "
|
|
48
|
+
@generated_collections.each do |generated_collection|
|
|
49
|
+
@langs.each do |lang|
|
|
50
|
+
print "[*] fetch: #{lang}/#{generated_collection.name}.strings\n"
|
|
51
51
|
data = @onesky.fetch_translations(lang, "#{generated_collection.name}.strings")
|
|
52
52
|
fetched_collection = @collection_builder.collection_from_datastring(data)
|
|
53
53
|
|
|
@@ -55,16 +55,20 @@ module Locca
|
|
|
55
55
|
local_collection = @collection_builder.collection_at_path(local_collection_path)
|
|
56
56
|
|
|
57
57
|
# 2
|
|
58
|
-
print "
|
|
58
|
+
print "[*] merge: onesky -> #{lang}/#{generated_collection.name}.strings\n"
|
|
59
59
|
@collection_merger.merge(fetched_collection, local_collection, CollectionMerger::ACTION_ADD | CollectionMerger::ACTION_UPDATE)
|
|
60
60
|
@collection_writer.write_to_path(local_collection, local_collection_path)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def sync()
|
|
66
|
+
fetch()
|
|
63
67
|
|
|
64
68
|
# 3
|
|
65
|
-
generated_collections.each do |generated_collection|
|
|
66
|
-
langs.each do |lang|
|
|
67
|
-
print "
|
|
69
|
+
@generated_collections.each do |generated_collection|
|
|
70
|
+
@langs.each do |lang|
|
|
71
|
+
print "[*] merge: code -> #{lang}/#{generated_collection.name}.strings\n"
|
|
68
72
|
|
|
69
73
|
collection_path = @project.path_for_collection(generated_collection.name, lang)
|
|
70
74
|
collection = @collection_builder.collection_at_path(collection_path)
|
|
@@ -74,8 +78,8 @@ module Locca
|
|
|
74
78
|
end
|
|
75
79
|
|
|
76
80
|
# 4
|
|
77
|
-
generated_collections.each do |generated_collection|
|
|
78
|
-
print "
|
|
81
|
+
@generated_collections.each do |generated_collection|
|
|
82
|
+
print "[*] upload: #{@project.base_lang}/#{generated_collection.name}.strings\n"
|
|
79
83
|
collection_path = @project.path_for_collection(generated_collection.name, @project.base_lang())
|
|
80
84
|
@onesky.upload_file(collection_path)
|
|
81
85
|
end
|
data/lib/locca/genstrings.rb
CHANGED
|
@@ -32,7 +32,10 @@ module Locca
|
|
|
32
32
|
command = "find #{code_dir} -iname \"*.m\" -or -iname \"*.mm\" -or -iname \"*.c\" | xargs genstrings -o '#{tmp_dir}'"
|
|
33
33
|
stdout, stderr, status = Open3.capture3(command)
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
stderr = stderr.strip
|
|
36
|
+
if stderr.length > 0
|
|
37
|
+
STDERR.puts()
|
|
38
|
+
end
|
|
36
39
|
|
|
37
40
|
if status.success?
|
|
38
41
|
Dir.glob(File.join(tmp_dir, '*.strings')) do |filename|
|
data/lib/locca/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: locca
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shurakov Evgeny
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-08-
|
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|
|
@@ -107,7 +107,7 @@ files:
|
|
|
107
107
|
- lib/babelyoda/strings_parser.rb
|
|
108
108
|
- lib/locca/actions/build_action.rb
|
|
109
109
|
- lib/locca/actions/merge_action.rb
|
|
110
|
-
- lib/locca/actions/
|
|
110
|
+
- lib/locca/actions/onesky_sync_action.rb
|
|
111
111
|
- lib/locca/actions/translate_action.rb
|
|
112
112
|
- lib/locca/collection.rb
|
|
113
113
|
- lib/locca/collection_builder.rb
|