haplo 2.4.4-java → 2.5.0-java

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d38c8194cc05037372ab34e9363c2628bfbb4ed51cc47e670c0619290120aab
4
- data.tar.gz: 5e883a919cc840ae0061d48a2dcffeab49162133ae7c7da08480b81692232198
3
+ metadata.gz: c4debe71fe91f237e4c8536a6f172b841ffedf5807e83c77aeabf44f5dd95d69
4
+ data.tar.gz: 0e8b43f580f7767466cf333bfa7f847d5f834bce7b950918125ebe65e5422135
5
5
  SHA512:
6
- metadata.gz: 07ce4f56cb7e9df0ad168cea69f1320cd4e7f9d391de6fb6f5dad5f7aa9224f6149764cacb67031ab87bb76e9b0bf03b8e17973384f9380eda346e4640c07cba
7
- data.tar.gz: 45c710d47c7edf13767d8a776da483e16ec4e3df344576fc927ae25acca2d31debf44ed993771b911c69c5e266b09414143eb9c674ee169f03fa23a00dbc6f7e
6
+ metadata.gz: 4f954ab6515de58158e0eacc826b6023bdcc53af299ac4a38fc59762f3dd184de177348024573fcd4e81bf506de02f75ff4a4ed2b06237c03708f8bdbf3ef1eb
7
+ data.tar.gz: 6fc846cc2827a1e9b925c5dcb8adbc3c96f7c27a9b7d850ce76dea176b5b887c6869bd78170621fc912dd54029f2019d99d433af5aedc3215c86e086254618a4
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
3
3
  files = Dir.glob("#{root_dir}/**/*.*").map { |x| x[root_dir.length + 1, x.length]}
4
4
 
5
5
  s.name = 'haplo'
6
- s.version = '2.4.4'
7
- s.date = '2019-09-24'
6
+ s.version = '2.5.0'
7
+ s.date = '2019-09-25'
8
8
  s.summary = "Haplo Plugin Tool"
9
9
  s.description = "Development tools for developing Haplo plugins, see https://haplo.org"
10
10
  s.licenses = ["MPL-2.0"]
Binary file
@@ -0,0 +1,46 @@
1
+
2
+ module PluginTool
3
+
4
+ def self.i18n_extract_text(plugins)
5
+ text = {}
6
+
7
+ # Get text from templates. This is exact, because each template is parsed.
8
+ parser_config = TemplateParserConfiguration.new
9
+ plugins.each do |plugin|
10
+ Dir.glob("#{plugin.plugin_dir}/template/**/*.hsvt").sort.each do |template|
11
+ template = Java::OrgHaploTemplateHtml::Parser.new(File.read(template), "extract", parser_config).parse()
12
+ template.extractTranslatedStrings().each do |string|
13
+ text[string] = string
14
+ end
15
+ end
16
+ end
17
+
18
+ # Get text from JS files, which isn't exact, because it just relies on convention and hopes for the best.
19
+ plugins.each do |plugin|
20
+ Dir.glob("#{plugin.plugin_dir}/js/**/*.js").sort.each do |js_file|
21
+ js = File.read(js_file)
22
+ [/\bi\['([^']+)'\]/, /\bi\["([^"]+)"\]/].each do |regexp|
23
+ js.scan(regexp) do
24
+ text[$1] = $1
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ # Last, add in any of the default locale's text, so where text is looked up by symbol, the translation is included.
31
+ plugins.each do |plugin|
32
+ ['global','local'].each do |scope|
33
+ maybe_strings = "#{plugin.plugin_dir}/i18n/#{scope}/#{plugin.default_locale_id}.template.json"
34
+ if File.exist?(maybe_strings)
35
+ strings = JSON.parse(File.read(maybe_strings))
36
+ strings.each do |k,v|
37
+ text[k] = v
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ puts JSON.pretty_generate(text)
44
+ end
45
+
46
+ end
@@ -29,6 +29,11 @@ module PluginTool
29
29
  attr_accessor :depend
30
30
  attr_accessor :loaded_plugin_id
31
31
 
32
+ def default_locale_id
33
+ # TODO: Other default locales
34
+ 'en'
35
+ end
36
+
32
37
  # ---------------------------------------------------------------------------------------------------------
33
38
 
34
39
  @@pending_apply = []
@@ -17,7 +17,7 @@ end
17
17
  PluginTool.try_load_custom
18
18
 
19
19
  WORKSPACE_FILE = 'workspace.json'
20
- LOCAL_ONLY_COMMANDS = {"license-key" => true, "pack" => true, "check" => true, "new" => true, "list" => true}
20
+ LOCAL_ONLY_COMMANDS = {"license-key" => true, "pack" => true, "check" => true, "new" => true, "list" => true, "extract-text" => true}
21
21
  NO_DEPENDENCY_COMMANDS = {"reset-db" => true}.merge(LOCAL_ONLY_COMMANDS)
22
22
  NO_DEPENDENCY_COMMANDS.delete('list')
23
23
  PLUGIN_SEARCH_PATH = ['.']
@@ -144,7 +144,7 @@ unless LOCAL_ONLY_COMMANDS[PLUGIN_TOOL_COMMAND]
144
144
  PluginTool.setup_auth(options)
145
145
  PluginTool.check_for_certificate_file
146
146
  application_info = PluginTool.get_application_info
147
- puts "Remote application name: #{(application_info["name"]||'').to_s.strip.gsub(/\s+/,' ')}"
147
+ STDERR.puts "Remote application name: #{(application_info["name"]||'').to_s.strip.gsub(/\s+/,' ')}"
148
148
  end
149
149
 
150
150
  if PLUGIN_TOOL_COMMAND == 'devtools'
@@ -171,6 +171,18 @@ if PLUGIN_TOOL_COMMAND == 'template-debugging'
171
171
  end
172
172
  end
173
173
 
174
+ if PLUGIN_TOOL_COMMAND == 'i18n-debugging'
175
+ disable = (ARGV[0] == 'disable')
176
+ puts disable ? "Disabling i18n debugging..." : "Enabling i18n debugging..."
177
+ if 'OK' == PluginTool.post("/api/development-plugin-loader/i18n-debugging?enable=#{disable ? '0' : '1'}")
178
+ puts "Done"
179
+ exit 0
180
+ else
181
+ puts "Error updating server"
182
+ exit 1
183
+ end
184
+ end
185
+
174
186
  # If the user didn't requested a plugin, try to use the application info to select the root plugin
175
187
  if requested_plugins.empty? && application_info
176
188
  application_root_plugin = application_info["config"]["applicationRootPlugin"]
@@ -291,7 +303,7 @@ if PLUGIN_TOOL_COMMAND == 'list'
291
303
  exit 0
292
304
  end
293
305
 
294
- puts "#{plugins.length} plugin#{plugins.length != 1 ? 's' : ''}"
306
+ STDERR.puts "#{plugins.length} plugin#{plugins.length != 1 ? 's' : ''}"
295
307
 
296
308
  # Custom behaviour for this repo?
297
309
  PluginTool.custom_behaviour.start(plugins, PLUGIN_TOOL_COMMAND, options, LOCAL_ONLY_COMMANDS[PLUGIN_TOOL_COMMAND])
@@ -304,6 +316,9 @@ when 'pack'
304
316
  when 'check'
305
317
  PluginTool.check_plugins(plugins)
306
318
  exit 0
319
+ when 'extract-text'
320
+ PluginTool.i18n_extract_text(plugins)
321
+ exit 0
307
322
  end
308
323
 
309
324
  # Set up local plugin objects against server
data/lib/run.rb CHANGED
@@ -70,4 +70,5 @@ require "#{PLUGIN_TOOL_ROOT_DIR}/lib/watchers.rb"
70
70
  require "#{PLUGIN_TOOL_ROOT_DIR}/lib/minimise.rb"
71
71
  require "#{PLUGIN_TOOL_ROOT_DIR}/lib/check.rb"
72
72
  require "#{PLUGIN_TOOL_ROOT_DIR}/lib/custom.rb"
73
+ require "#{PLUGIN_TOOL_ROOT_DIR}/lib/i18n_extract_text.rb"
73
74
  require "#{PLUGIN_TOOL_ROOT_DIR}/lib/plugin_tool.rb"
@@ -68,6 +68,10 @@ Commands:
68
68
  Enable or disable template debugging, including adding comments in generated HTML
69
69
  to indicate which templates were used.
70
70
 
71
+ i18n-debugging [disable]
72
+ Enable or disable internationalisation debugging, including indicating which text
73
+ in the user interface is translated.
74
+
71
75
  auth [SERVER]
72
76
  Authorise with server. SERVER can optionally include a non-default port number.
73
77
 
@@ -93,6 +97,10 @@ Commands:
93
97
  check
94
98
  Perform checks on the plugin as a quick test before it's submitted for review.
95
99
 
100
+ extract-text
101
+ Extract translatable text from templates, and attempt to extract text from JavaScript
102
+ files, and output a JSON data structure suitable for translation.
103
+
96
104
  license-key <application-id>
97
105
  Generate a license key to allow plugin installation by a client. The numeric
98
106
  application ID is displayed during plugin installation.
@@ -1 +1 @@
1
- ba15ef2
1
+ 861823a
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haplo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.4
4
+ version: 2.5.0
5
5
  platform: java
6
6
  authors:
7
7
  - Haplo Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-24 00:00:00.000000000 Z
11
+ date: 2019-09-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Development tools for developing Haplo plugins, see https://haplo.org
14
14
  email: client.services@haplo-services.com
@@ -27,6 +27,7 @@ files:
27
27
  - lib/haplo-templates.jar
28
28
  - lib/hmac.rb
29
29
  - lib/hsvt_parser_config.rb
30
+ - lib/i18n_extract_text.rb
30
31
  - lib/js.jar
31
32
  - lib/js_min.js
32
33
  - lib/js_syntax_test.js