zendesk_apps_tools 1.1.3 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,20 +15,19 @@ Feature: Translate app strings
15
15
  | package name | test_package |
16
16
  Then the app file "tmp/aruba/translations/en.yml" is created with:
17
17
  """
18
- title: "John Test App"
18
+ ---
19
+ title: John Test App
19
20
  packages:
20
21
  - default
21
22
  - app_test_package
22
-
23
23
  parts:
24
24
  - translation:
25
- key: "txt.apps.test_package.app.description"
26
- title: ""
27
- value: "Play the famous zen tunes in your help desk."
25
+ key: txt.apps.test_package.app.description
26
+ title: ''
27
+ value: Play the famous zen tunes in your help desk.
28
28
  - translation:
29
- key: "txt.apps.test_package.app.name"
30
- title: ""
31
- value: "Buddha Machine"
32
-
29
+ key: txt.apps.test_package.app.name
30
+ title: ''
31
+ value: Buddha Machine
33
32
  """
34
33
 
@@ -7,7 +7,7 @@ module ZendeskAppsTools
7
7
 
8
8
  get '/app.js' do
9
9
  content_type 'text/javascript'
10
- ZendeskAppsSupport::Package.new(settings.root).readified_js(nil, 0, "http://localhost:#{settings.port}", settings.parameters)
10
+ ZendeskAppsSupport::Package.new(settings.root).readified_js(nil, 0, "http://localhost:#{settings.port}/", settings.parameters)
11
11
  end
12
12
 
13
13
  end
@@ -1,5 +1,6 @@
1
1
  require 'thor'
2
2
  require 'json'
3
+ require 'yaml'
3
4
  require 'zendesk_apps_tools/common'
4
5
  require 'zendesk_apps_tools/locale_identifier'
5
6
 
@@ -89,13 +90,26 @@ module ZendeskAppsTools
89
90
 
90
91
  def write_yaml(app_name, package)
91
92
  user_translations = JSON.parse(File.open('translations/en.json').read)
92
- @translations = user_translations.keys.inject({}) do |translations, key|
93
+ translations = user_translations.keys.inject({}) do |translations, key|
93
94
  translations.merge( get_translations_for(user_translations, key) )
94
95
  end
95
96
 
96
- @app_name = app_name
97
- @package_name = package
98
- template(File.join(Translate.source_root, 'templates/translation.erb.tt'), "translations/en.yml")
97
+ create_file("translations/en.yml", YAML.dump(yaml_structure(app_name, package, translations)))
98
+ end
99
+
100
+ def yaml_structure(app_name, package_name, translations)
101
+ result = {}
102
+ result['title'] = app_name
103
+ result['packages'] = ['default', "app_#{package_name}"]
104
+ result['parts'] = translations.map do |key, value|
105
+ translation_item = { 'translation' => {} }
106
+ translation_item['translation']['key'] = "txt.apps.#{package_name}.#{key}"
107
+ translation_item['translation']['title'] = ''
108
+ translation_item['translation']['value'] = value
109
+ translation_item
110
+ end
111
+
112
+ result
99
113
  end
100
114
 
101
115
  def get_translations_for(scope, scope_key, keys = [], translations = {})
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.1.3
4
+ version: 1.2.1
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-06-19 00:00:00.000000000 Z
15
+ date: 2013-07-12 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: thor
@@ -85,7 +85,7 @@ dependencies:
85
85
  requirements:
86
86
  - - ~>
87
87
  - !ruby/object:Gem::Version
88
- version: 1.1.4
88
+ version: 1.2.0
89
89
  type: :runtime
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
@@ -93,7 +93,7 @@ dependencies:
93
93
  requirements:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: 1.1.4
96
+ version: 1.2.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: cucumber
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -165,7 +165,6 @@ 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
169
168
  - README.md
170
169
  - LICENSE
171
170
  - features/clean.feature
@@ -196,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
195
  version: 1.3.6
197
196
  requirements: []
198
197
  rubyforge_project:
199
- rubygems_version: 1.8.24
198
+ rubygems_version: 1.8.25
200
199
  signing_key:
201
200
  specification_version: 3
202
201
  summary: Tools to help you develop Zendesk Apps.
@@ -1,12 +0,0 @@
1
- title: "<%= @app_name %>"
2
- packages:
3
- - default
4
- - app_<%= @package_name %>
5
-
6
- parts:
7
- <% @translations.each do |key, value| -%>
8
- - translation:
9
- key: "txt.apps.<%= @package_name %>.<%= key %>"
10
- title: ""
11
- value: "<%= value %>"
12
- <% end %>