xlocalize 0.2.6 → 0.3.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/xlocalize/executor.rb +5 -5
- data/lib/xlocalize/version.rb +1 -1
- data/lib/xlocalize/xliff.rb +12 -3
- data/lib/xlocalize.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e9711c270d3b8f1436b0b740d56adc3cf167316
|
4
|
+
data.tar.gz: fc2ef80a45346002dc7fe9d188f038df232b33d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 136703bed8b27bced211d7e073990a3e2f38f8f593e50cdfd15c754b87abcae20ed41293142f05c4d4363f12f416c77682ac213ad8c355fb00a57565d2031ada
|
7
|
+
data.tar.gz: e9a79bec1f3466ff2e5b98fdcdf41123724d640bfe6ef102d3db20752957f1f1614a88fe8aaf9963aaba16722b2b8a2a0700758329f319b0315bb4d86cb45d3a
|
data/lib/xlocalize/executor.rb
CHANGED
@@ -15,7 +15,7 @@ module Xlocalize
|
|
15
15
|
return "#{locale}.xliff"
|
16
16
|
end
|
17
17
|
|
18
|
-
def export_master(wti, project,
|
18
|
+
def export_master(wti, project, targets, excl_prefix, master_lang)
|
19
19
|
master_file_name = locale_file_name(master_lang)
|
20
20
|
|
21
21
|
# hacky way to finish xcodebuild -exportLocalizations script, because
|
@@ -28,8 +28,8 @@ module Xlocalize
|
|
28
28
|
sleep(1)
|
29
29
|
end
|
30
30
|
|
31
|
-
purelyze(master_lang,
|
32
|
-
push_master_file(wti, master_lang, master_file_name)
|
31
|
+
purelyze(master_lang, targets, excl_prefix, project)
|
32
|
+
push_master_file(wti, master_lang, master_file_name) if !wti.nil?
|
33
33
|
end
|
34
34
|
|
35
35
|
def push_master_file(wti, master_lang, master_file_name)
|
@@ -49,12 +49,12 @@ module Xlocalize
|
|
49
49
|
end if !wti.nil?
|
50
50
|
end
|
51
51
|
|
52
|
-
def purelyze(locale,
|
52
|
+
def purelyze(locale, targets, excl_prefix, project)
|
53
53
|
locale_file_name = locale_file_name(locale)
|
54
54
|
doc = Nokogiri::XML(open(locale_file_name))
|
55
55
|
|
56
56
|
puts "Removing all files not matching required targets" if $VERBOSE
|
57
|
-
doc.filter_not_target_files(
|
57
|
+
doc.filter_not_target_files(targets)
|
58
58
|
puts "Removing trans-unit's having reserverd prefix in their sources" if $VERBOSE
|
59
59
|
doc.filter_trans_units(excl_prefix)
|
60
60
|
puts "Filtering plurals" if $VERBOSE
|
data/lib/xlocalize/version.rb
CHANGED
data/lib/xlocalize/xliff.rb
CHANGED
@@ -2,14 +2,23 @@ require 'nokogiri'
|
|
2
2
|
require 'plist'
|
3
3
|
require 'pathname'
|
4
4
|
|
5
|
+
class String
|
6
|
+
def start_with_either?(prefixes)
|
7
|
+
prefixes.each do |prefix|
|
8
|
+
return true if start_with?(prefix)
|
9
|
+
end
|
10
|
+
return false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
5
14
|
module Xlocalize
|
6
15
|
class ::Nokogiri::XML::Document
|
7
16
|
|
8
|
-
def filter_not_target_files(
|
9
|
-
|
17
|
+
def filter_not_target_files(targets)
|
18
|
+
prefixes = targets.map { |t| "#{t}/" }
|
10
19
|
self.xpath("//xmlns:file").each { |node|
|
11
20
|
fname = node["original"]
|
12
|
-
node.remove if !fname.
|
21
|
+
node.remove if !fname.start_with_either?(prefixes) || !fname.include?(".lproj/")
|
13
22
|
}
|
14
23
|
end
|
15
24
|
|
data/lib/xlocalize.rb
CHANGED
@@ -13,19 +13,19 @@ module Xlocalize
|
|
13
13
|
c.description = 'Export localized strings from Xcode project'
|
14
14
|
c.option '--wti_key STRING', String, 'Webtranslateit API key'
|
15
15
|
c.option '--project STRING', String, 'Path to project file'
|
16
|
-
c.option '--
|
16
|
+
c.option '--targets ARRAY', Array, 'Target in the project'
|
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.action do |_, options|
|
20
20
|
if options.project.nil? or
|
21
|
-
options.
|
21
|
+
options.targets.nil? or
|
22
22
|
options.excl_prefix.nil? or
|
23
23
|
options.master_lang.nil?
|
24
24
|
raise 'Missing parameter'
|
25
25
|
end
|
26
26
|
|
27
27
|
wti = WebtranslateIt.new(options.wti_key) if !options.wti_key.nil?
|
28
|
-
Executor.new.export_master(wti, options.project, options.
|
28
|
+
Executor.new.export_master(wti, options.project, options.targets, options.excl_prefix, options.master_lang)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
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.
|
4
|
+
version: 0.3.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: 2017-
|
11
|
+
date: 2017-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|