crowdin-cli 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/crowdin-cli +21 -24
- data/lib/crowdin-cli/version.rb +1 -1
- metadata +3 -3
data/bin/crowdin-cli
CHANGED
@@ -7,16 +7,7 @@ require 'zip/zip'
|
|
7
7
|
require 'crowdin-api'
|
8
8
|
require 'crowdin-cli'
|
9
9
|
|
10
|
-
#
|
11
|
-
#require 'crowdin-cli'
|
12
|
-
#rescue LoadError
|
13
|
-
# STDERR.puts "In development, you need to use `bundle exec bin/crowdin-cli` to run your app"
|
14
|
-
# STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
|
15
|
-
# STDERR.puts "Feel free to remove this message from bin/crowdin-cli now"
|
16
|
-
# exit 64
|
17
|
-
#end
|
18
|
-
|
19
|
-
# Ця хуїта повертає структуру директорій на сервері
|
10
|
+
# повертає структуру директорій на сервері
|
20
11
|
#
|
21
12
|
def walk_remote_tree(files, root = '/', result = { dirs: [], files: [] })
|
22
13
|
files.each do |node|
|
@@ -33,7 +24,6 @@ def walk_remote_tree(files, root = '/', result = { dirs: [], files: [] })
|
|
33
24
|
end
|
34
25
|
|
35
26
|
|
36
|
-
# Хуйня... хулі
|
37
27
|
# Повертає локальну структуру директорій
|
38
28
|
# На вході масив файлів, наприклад:
|
39
29
|
# ['/path/to/admin/en.xml', '/path/to/user/settings/strings.xml']
|
@@ -69,6 +59,16 @@ def unzip_file(file, dest)
|
|
69
59
|
end
|
70
60
|
end
|
71
61
|
|
62
|
+
def android_locale_code(locale_code)
|
63
|
+
locale_code = case locale_code
|
64
|
+
when 'he-IL' then 'iw-IL'
|
65
|
+
when 'yi-DE' then 'ji-DE'
|
66
|
+
when 'id-ID' then 'in-ID'
|
67
|
+
else locale_code
|
68
|
+
end
|
69
|
+
return locale_code.sub('-', '-r')
|
70
|
+
end
|
71
|
+
|
72
72
|
|
73
73
|
###
|
74
74
|
include GLI::App
|
@@ -109,10 +109,6 @@ command :upload do |c|
|
|
109
109
|
c.desc 'Upload source files'
|
110
110
|
c.command :sources do |c|
|
111
111
|
c.action do |global_options, options, args|
|
112
|
-
|
113
|
-
c.desc 'defines whether to add files if there is the same file previously added'
|
114
|
-
c.switch [:upload_duplicates]
|
115
|
-
|
116
112
|
project_info = @crowdin.project_info(:json)
|
117
113
|
project_info = JSON.parse(project_info)
|
118
114
|
|
@@ -145,14 +141,12 @@ command :upload do |c|
|
|
145
141
|
# Update existing files in Crowdin project
|
146
142
|
#
|
147
143
|
# array containing elements common to the two arrays
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
@crowdin.update_file([] << file)
|
155
|
-
end
|
144
|
+
update_files = local_project_tree[:files] & remote_project_tree[:files]
|
145
|
+
files_for_upload = local_files.select{ |file| update_files.include?(file[:dest]) }
|
146
|
+
files_for_upload.map{ |file| file.keep_if{ |k, v| [:source, :dest].include?(k) } }
|
147
|
+
files_for_upload.each do |file|
|
148
|
+
puts "Update file `#{file[:dest]}`"
|
149
|
+
@crowdin.update_file([] << file)
|
156
150
|
end
|
157
151
|
|
158
152
|
# Add new files to Crowdin project
|
@@ -236,7 +230,7 @@ command :upload do |c|
|
|
236
230
|
'%locale%' => lang['locale'],
|
237
231
|
'%locale_with_underscore%' => lang['locale'].gsub('-', '_'),
|
238
232
|
'%original_file_name%' => original_file_name,
|
239
|
-
'%android_code%' => '
|
233
|
+
'%android_code%' => android_locale_code(lang['locale']),
|
240
234
|
'%original_path%' => original_path,
|
241
235
|
'%file_extension%' => file_extension,
|
242
236
|
'%file_name%' => file_extension,
|
@@ -279,6 +273,9 @@ command :download do |c|
|
|
279
273
|
c.flag :l, :language, :default_value => 'all'
|
280
274
|
|
281
275
|
c.action do |global_options ,options, args|
|
276
|
+
# use export API method before to download the most recent translations
|
277
|
+
@crowdin.export_translations
|
278
|
+
|
282
279
|
language = options[:language]
|
283
280
|
|
284
281
|
file = Tempfile.new(language)
|
data/lib/crowdin-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crowdin-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - '='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 0.0.
|
101
|
+
version: 0.0.3
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - '='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0.0.
|
109
|
+
version: 0.0.3
|
110
110
|
description:
|
111
111
|
email: anton.linux@gmail.com
|
112
112
|
executables:
|