zendesk_apps_tools 1.2.1 → 1.2.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.
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
Given /^an app directory "(.*?)" exists$/ do |app_dir|
|
2
4
|
@app_dir = app_dir
|
3
5
|
FileUtils.rm_rf(@app_dir)
|
@@ -40,6 +42,13 @@ Then /^the app file "(.*?)" is created with:$/ do |file, content|
|
|
40
42
|
File.read(file).chomp.gsub(' ', '').should == content.gsub(' ', '')
|
41
43
|
end
|
42
44
|
|
45
|
+
Then /^the fixture "(.*?)" is used for "(.*?)"$/ do |fixture, app_file|
|
46
|
+
fixture_file = File.join('features', 'fixtures', fixture)
|
47
|
+
app_file_path = File.join(@app_dir, app_file)
|
48
|
+
|
49
|
+
FileUtils.cp(fixture_file, app_file_path)
|
50
|
+
end
|
51
|
+
|
43
52
|
|
44
53
|
Then /^the zip file should exist in directory "(.*?)"$/ do |path|
|
45
54
|
Dir[path + '/app-*.zip'].size.should == 1
|
data/features/translate.feature
CHANGED
@@ -11,23 +11,26 @@ Feature: Translate app strings
|
|
11
11
|
|
12
12
|
Scenario: Generate template yaml from en.json
|
13
13
|
Given an app is created in directory "tmp/aruba"
|
14
|
+
And the fixture "quote_character_translation.json" is used for "translations/en.json"
|
14
15
|
When I run "cd tmp/aruba && zat translate create" command with the following details:
|
15
16
|
| package name | test_package |
|
16
17
|
Then the app file "tmp/aruba/translations/en.yml" is created with:
|
17
18
|
"""
|
18
19
|
---
|
19
|
-
title: John Test App
|
20
|
+
title: "John Test App"
|
20
21
|
packages:
|
21
22
|
- default
|
22
23
|
- app_test_package
|
24
|
+
|
23
25
|
parts:
|
24
26
|
- translation:
|
25
|
-
key: txt.apps.test_package.app.description
|
26
|
-
title:
|
27
|
-
value: Play the famous zen tunes in your help desk.
|
27
|
+
key: "txt.apps.test_package.app.description"
|
28
|
+
title: ""
|
29
|
+
value: "Play the famous zen tunes in your help desk."
|
28
30
|
- translation:
|
29
|
-
key: txt.apps.test_package.app.name
|
30
|
-
title:
|
31
|
-
value: Buddha Machine
|
31
|
+
key: "txt.apps.test_package.app.name"
|
32
|
+
title: ""
|
33
|
+
value: "Buddha \"Machine\""
|
34
|
+
|
32
35
|
"""
|
33
36
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'json'
|
3
|
-
require 'yaml'
|
4
3
|
require 'zendesk_apps_tools/common'
|
5
4
|
require 'zendesk_apps_tools/locale_identifier'
|
6
5
|
|
@@ -10,6 +9,7 @@ module ZendeskAppsTools
|
|
10
9
|
include Thor::Actions
|
11
10
|
include ZendeskAppsTools::Common
|
12
11
|
|
12
|
+
CHARACTERS_TO_ESCAPE = %w[ " ]
|
13
13
|
LOCALE_ENDPOINT = "https://support.zendesk.com/api/v2/locales.json"
|
14
14
|
|
15
15
|
desc 'create', 'Create Zendesk translation file from en.json'
|
@@ -93,20 +93,19 @@ module ZendeskAppsTools
|
|
93
93
|
translations = user_translations.keys.inject({}) do |translations, key|
|
94
94
|
translations.merge( get_translations_for(user_translations, key) )
|
95
95
|
end
|
96
|
+
@escaped_translations = escape_values(translations)
|
96
97
|
|
97
|
-
|
98
|
+
@app_name = app_name
|
99
|
+
@package_name = package
|
100
|
+
template(File.join(Translate.source_root, 'templates/translation.erb.tt'), "translations/en.yml")
|
98
101
|
end
|
99
102
|
|
100
|
-
def
|
103
|
+
def escape_values(translations)
|
101
104
|
result = {}
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
translation_item['translation']['key'] = "txt.apps.#{package_name}.#{key}"
|
107
|
-
translation_item['translation']['title'] = ''
|
108
|
-
translation_item['translation']['value'] = value
|
109
|
-
translation_item
|
105
|
+
translations.each do |key, value|
|
106
|
+
CHARACTERS_TO_ESCAPE.each do |char|
|
107
|
+
result[key] = value.gsub(char, "\\#{char}")
|
108
|
+
end
|
110
109
|
end
|
111
110
|
|
112
111
|
result
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: "<%= @app_name %>"
|
3
|
+
packages:
|
4
|
+
- default
|
5
|
+
- app_<%= @package_name %>
|
6
|
+
|
7
|
+
parts:
|
8
|
+
<% @escaped_translations.each do |key, value| -%>
|
9
|
+
- translation:
|
10
|
+
key: "txt.apps.<%= @package_name %>.<%= key %>"
|
11
|
+
title: ""
|
12
|
+
value: "<%= value %>"
|
13
|
+
<% 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: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-07-
|
15
|
+
date: 2013-07-15 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: thor
|
@@ -165,9 +165,11 @@ files:
|
|
165
165
|
- app_template/manifest.json.tt
|
166
166
|
- app_template/templates/layout.hdbs
|
167
167
|
- app_template/translations/en.json
|
168
|
+
- templates/translation.erb.tt
|
168
169
|
- README.md
|
169
170
|
- LICENSE
|
170
171
|
- features/clean.feature
|
172
|
+
- features/fixtures/quote_character_translation.json
|
171
173
|
- features/new.feature
|
172
174
|
- features/package.feature
|
173
175
|
- features/step_definitions/app_steps.rb
|
@@ -201,6 +203,7 @@ specification_version: 3
|
|
201
203
|
summary: Tools to help you develop Zendesk Apps.
|
202
204
|
test_files:
|
203
205
|
- features/clean.feature
|
206
|
+
- features/fixtures/quote_character_translation.json
|
204
207
|
- features/new.feature
|
205
208
|
- features/package.feature
|
206
209
|
- features/step_definitions/app_steps.rb
|