xlocalize 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa7fbd8d30e2a08b01bb26ce46700e69b71933a7
4
- data.tar.gz: 1154a3d87abef4595417e4810fcd5664bc6c2dc9
3
+ metadata.gz: 7d55b509bd7c5475b9b5cc70a573ed36a87914b1
4
+ data.tar.gz: aef43cb75f4ded93db5befee7e3f256f47a8c1ae
5
5
  SHA512:
6
- metadata.gz: 480ca68941c6fea0bf101adf2f276f5644147600772b40a68f54a45306770cedd6b59f99a90c925778666bf86ac45b59fa6d3585675f7721702e98a49ec58635
7
- data.tar.gz: 7faf6415c3a9169ebf396c95cdd535b754f9ea013a6e86f67414d21aed04d8c76747b48828fe4b34bcdfc3df0d04d0e556fe1e08e274d2ae735b2f31259829ce
6
+ metadata.gz: 558a2654398fdf15574e9c498c4826ae6d6ef503886b850c0fdfe66a98e50c11c26ca91a6d80cf3850c9b2c33e87c97dadd5989f08f87c253bbcbd5c56a041d9
7
+ data.tar.gz: 7edd77a3d0a20827ab7dac5409fefad4e5add3d36fa6bc925e7b135a89e6dd1d9c2f36dc1000c326adf760fe5798e3efa432bb55ed5eb4e5356196f45510ffec
@@ -1,3 +1,7 @@
1
+ ## [v0.7.0](https://github.com/viktorasl/xlocalize/releases/tag/0.7.0)
2
+
3
+ * [70ef86f](https://github.com/viktorasl/xlocalize/commit/70ef86f6d8b5d64e100445635a46d92080437646) Provide allowed cryptic units via config file
4
+
1
5
  ## [v0.6.0](https://github.com/viktorasl/xlocalize/releases/tag/0.6.0)
2
6
 
3
7
  * [17ffefc](https://github.com/viktorasl/xlocalize/commit/17ffefcc94272385091cef087e7df18a407897a8) Xliff merging before upload
@@ -17,8 +17,10 @@ module Xlocalize
17
17
  c.option '--excl_prefix STRING', String, 'Exclude strings having specified prefix'
18
18
  c.option '--master_lang STRING', String, 'Master language of the project'
19
19
  c.option '--exclude_units ARRAY', Array, 'Translation unit IDs to exclude'
20
+ c.option '--no-cryptic', 'Disallow cryptic translation units'
20
21
  c.action do |_, options|
21
22
  options.default :exclude_units => []
23
+ no_cryptic = !(options.no_cryptic.nil? ? true : options.no_cryptic)
22
24
 
23
25
  if options.project.nil? or
24
26
  options.targets.nil? or
@@ -28,7 +30,7 @@ module Xlocalize
28
30
  end
29
31
 
30
32
  wti = WebtranslateIt.new(options.wti_key) if !options.wti_key.nil?
31
- Executor.new.export_master(wti, options.project, options.targets, options.excl_prefix, options.master_lang, options.exclude_units)
33
+ Executor.new.export_master(wti, options.project, options.targets, options.excl_prefix, options.master_lang, options.exclude_units, no_cryptic)
32
34
  end
33
35
  end
34
36
  end
@@ -18,7 +18,7 @@ module Xlocalize
18
18
  return "#{locale}.xliff"
19
19
  end
20
20
 
21
- def export_master(wti, project, targets, excl_prefix, master_lang, exclude_units=[])
21
+ def export_master(wti, project, targets, excl_prefix, master_lang, exclude_units=[], no_cryptic)
22
22
  master_file_name = locale_file_name(master_lang)
23
23
 
24
24
  File.delete(master_file_name) if File.exist?(master_file_name)
@@ -37,6 +37,20 @@ module Xlocalize
37
37
  end
38
38
 
39
39
  purelyze(master_lang, targets, excl_prefix, project, filer_ui_duplicates=Helper.xcode_at_least?(9.3), exclude_units)
40
+ if no_cryptic then
41
+ config_fname = '.xlocalize.yml'
42
+ config = (YAML.load_file(config_fname) if File.file?(config_fname)) || {}
43
+ allow_cryptic = config['allow_cryptic'] || {}
44
+
45
+ doc = Nokogiri::XML(File.open(locale_file_name(master_lang)))
46
+ cryptic_trans_units = doc.cryptic_trans_units(allow_cryptic)
47
+ if !cryptic_trans_units.empty? then
48
+ err_msg = "Found cryptic translation units\n"
49
+ err_msg += cryptic_trans_units.map { |fname, units| "#{fname}" + "\n " + units.join("\n ") }.join("\n")
50
+ raise err_msg
51
+ end
52
+ end
53
+
40
54
  if wti then
41
55
  original_doc = Nokogiri::XML(wti.pull(master_lang)['xliff'])
42
56
  Nokogiri::XML(File.open(master_file_name)).merge_on_top_of(original_doc)
@@ -1,4 +1,4 @@
1
1
  module Xlocalize
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  DESCRIPTION = "Xcode localizations import/export helper tool"
4
4
  end
@@ -98,5 +98,20 @@ module Xlocalize
98
98
  end
99
99
  }
100
100
  end
101
+
102
+ def cryptic_trans_units(exclude)
103
+ file_units = {}
104
+ cryptic_pattern = /[a-zA-Z0-9]{3}-[a-zA-Z0-9]{2}-[a-zA-Z0-9]{3}/
105
+ self.xpath("//xmlns:file").each do |node|
106
+ fname = node["original"]
107
+ all_units = node.css('body > trans-unit').map { |unit| unit['id'] }
108
+ cryptic_units = all_units.select do |key|
109
+ is_excluded = (exclude[fname] || []).include?(key)
110
+ !is_excluded && (key =~ cryptic_pattern)
111
+ end
112
+ file_units[fname] = cryptic_units if cryptic_units.any?
113
+ end
114
+ return file_units
115
+ end
101
116
  end
102
117
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlocalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktoras Laukevičius
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-08 00:00:00.000000000 Z
11
+ date: 2018-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri