zendesk_apps_tools 2.8.4 → 2.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/lib/zendesk_apps_tools/translate.rb +38 -16
- data/lib/zendesk_apps_tools/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7f07cc7695763e79c8c6ae5b9b61fcb3d5d5f30
|
4
|
+
data.tar.gz: 5d42c9fb5a891eeeb23869f8fff121561c76902c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f48d8d0c53e507a3df7ab019d5da9a0e455e6778ee103d70fd012a633cfaa7bcfcbf87bb72a8e6ebce411e100f9e0200d26496a4556b6a8184a328524b6c779
|
7
|
+
data.tar.gz: b761831cb58b10c27daa177e39d8a912a2078472a6d4ac35c875aef4121907683d4b95949c1d53c35a02c98a1d1db6e0e8af3c593273b8016a966dacc1e2cd63
|
@@ -33,19 +33,7 @@ module ZendeskAppsTools
|
|
33
33
|
desc 'to_json', 'Convert Zendesk translation yml to I18n formatted json'
|
34
34
|
shared_options(except: [:clean])
|
35
35
|
def to_json
|
36
|
-
require 'yaml'
|
37
36
|
setup_path(options[:path]) if options[:path]
|
38
|
-
en_yml = YAML.load_file("#{destination_root}/translations/en.yml")
|
39
|
-
package = /^txt.apps.([^\.]+)/.match(en_yml['parts'][0]['translation']['key'])[1]
|
40
|
-
translations = en_yml['parts'].map { |part| part['translation'] }
|
41
|
-
translations.select! do |translation|
|
42
|
-
obsolete = translation['obsolete']
|
43
|
-
next true unless obsolete
|
44
|
-
Date.parse(obsolete.to_s) > Date.today
|
45
|
-
end
|
46
|
-
en_hash = array_to_nested_hash(translations)['txt']['apps'][package]
|
47
|
-
en_hash['app']['package'] = package
|
48
|
-
|
49
37
|
write_json('translations/en.json', en_hash)
|
50
38
|
end
|
51
39
|
|
@@ -76,9 +64,9 @@ module ZendeskAppsTools
|
|
76
64
|
def pseudotranslate
|
77
65
|
setup_path(options[:path]) if options[:path]
|
78
66
|
|
79
|
-
package =
|
67
|
+
package = package_name(error_out: true)
|
80
68
|
|
81
|
-
pseudo = build_pseudotranslation(
|
69
|
+
pseudo = build_pseudotranslation(en_hash, package)
|
82
70
|
write_json('translations/fr.json', pseudo)
|
83
71
|
end
|
84
72
|
|
@@ -177,7 +165,7 @@ module ZendeskAppsTools
|
|
177
165
|
require 'faraday'
|
178
166
|
|
179
167
|
if options[:locales]
|
180
|
-
content =
|
168
|
+
content = read_file(options[:locales])
|
181
169
|
locales = JSON.parse(content)
|
182
170
|
return locales.map do |locale|
|
183
171
|
{ 'locale' => locale, 'url' => "#{LOCALE_BASE_ENDPOINT}/#{locale}.json" }
|
@@ -194,9 +182,13 @@ module ZendeskAppsTools
|
|
194
182
|
end
|
195
183
|
end
|
196
184
|
|
185
|
+
def read_file(path)
|
186
|
+
File.read(File.expand_path(path))
|
187
|
+
end
|
188
|
+
|
197
189
|
def package_name_for_update
|
198
190
|
options[:package_name] ||
|
199
|
-
|
191
|
+
package_name(error_out: options[:unattended]) ||
|
200
192
|
get_value_from_stdin('What is the package name for this app? (without leading app_)',
|
201
193
|
valid_regex: /^[a-z_]+$/,
|
202
194
|
error_msg: 'Invalid package name, try again:')
|
@@ -209,11 +201,41 @@ module ZendeskAppsTools
|
|
209
201
|
end
|
210
202
|
end
|
211
203
|
|
204
|
+
def en_yaml
|
205
|
+
@en_yaml ||= begin
|
206
|
+
path = "#{destination_root}/translations/en.yml"
|
207
|
+
require 'yaml'
|
208
|
+
YAML.load_file(path) if File.exist? path
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def en_hash
|
213
|
+
@en_hash ||= begin
|
214
|
+
return nil unless en_yaml
|
215
|
+
package = /^txt.apps.([^\.]+)/.match(en_yaml['parts'][0]['translation']['key'])[1]
|
216
|
+
translations = en_yaml['parts'].map { |part| part['translation'] }
|
217
|
+
translations.select! do |translation|
|
218
|
+
obsolete = translation['obsolete']
|
219
|
+
next true unless obsolete
|
220
|
+
Date.parse(obsolete.to_s) > Date.today
|
221
|
+
end
|
222
|
+
en_hash = array_to_nested_hash(translations)['txt']['apps'][package]
|
223
|
+
en_hash['app']['package'] = package
|
224
|
+
en_hash
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
212
228
|
def package_name_from_json(error_out: false)
|
213
229
|
package = en_json && en_json['app']['package']
|
214
230
|
return package if package
|
215
231
|
say_error_and_exit 'No package defined inside en.json!' if error_out
|
216
232
|
end
|
233
|
+
|
234
|
+
def package_name(error_out: false)
|
235
|
+
package = en_hash && en_hash['app']['package']
|
236
|
+
return package if package
|
237
|
+
say_error_and_exit 'No package defined inside en.yml!' if error_out
|
238
|
+
end
|
217
239
|
end
|
218
240
|
end
|
219
241
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zendesk_apps_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James A. Rosen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-03-
|
14
|
+
date: 2018-03-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: thor
|
@@ -103,14 +103,14 @@ dependencies:
|
|
103
103
|
requirements:
|
104
104
|
- - "~>"
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version: 4.
|
106
|
+
version: 4.10.0
|
107
107
|
type: :runtime
|
108
108
|
prerelease: false
|
109
109
|
version_requirements: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
111
|
- - "~>"
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
version: 4.
|
113
|
+
version: 4.10.0
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: sinatra-cross_origin
|
116
116
|
requirement: !ruby/object:Gem::Requirement
|
@@ -321,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
321
321
|
version: 1.3.6
|
322
322
|
requirements: []
|
323
323
|
rubyforge_project:
|
324
|
-
rubygems_version: 2.
|
324
|
+
rubygems_version: 2.4.5.4
|
325
325
|
signing_key:
|
326
326
|
specification_version: 4
|
327
327
|
summary: Tools to help you develop Zendesk Apps.
|