smartling_xcode 0.1.5 → 0.1.6
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/bin/smartling_xcode +2 -2
- data/lib/smartling_xcode.rb +6 -0
- data/lib/smartling_xcode/backend.rb +48 -20
- data/lib/smartling_xcode/version.rb +1 -1
- data/lib/smartling_xcode/xcode.rb +19 -9
- 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: ac0f92fc6ca6cfe0e3d5a53537ee75a73de59907
|
4
|
+
data.tar.gz: b51eb2b809d3603b0605562ae4f99ab3dfd95bca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f7eed95202dc8d3c0300518e3951acf462273b56da5b78563cefe7a8f647c97ebdfd4875130ac75b697a95aa84d7f403654621b113b078e95d5a93403f67cca
|
7
|
+
data.tar.gz: 2a6b48f94b520dfb83706527584c869356fdcb0514bd9630c6048570f8b31c68b1d93ba357abae84a44ba1dab6b440e84528fc100fd0aeec83c1c2e689942618
|
data/bin/smartling_xcode
CHANGED
@@ -19,7 +19,7 @@ ARGV.each do |arg|
|
|
19
19
|
sl.sandbox = true
|
20
20
|
|
21
21
|
# Commands
|
22
|
-
when 'init', 'extract', 'push' then command = arg
|
22
|
+
when 'init', 'extract', 'push', 'getversion' then command = arg
|
23
23
|
|
24
24
|
else
|
25
25
|
if command.nil?
|
@@ -28,7 +28,7 @@ ARGV.each do |arg|
|
|
28
28
|
sl.version = arg
|
29
29
|
version_is_next = false
|
30
30
|
else
|
31
|
-
sl.
|
31
|
+
sl.projectPath = arg
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/smartling_xcode.rb
CHANGED
@@ -29,5 +29,11 @@ module SmartlingXcode
|
|
29
29
|
api.pushStringsFromFiles(files, @version)
|
30
30
|
puts "\nYour files are now available in the Files section of your Smartling project."
|
31
31
|
end
|
32
|
+
|
33
|
+
def getversion
|
34
|
+
project = Xcodeproj::Project.find(@projectPath)
|
35
|
+
@version = project.getVersion
|
36
|
+
puts "Version #{@version} will be used."
|
37
|
+
end
|
32
38
|
end
|
33
39
|
end
|
@@ -75,7 +75,6 @@ module SmartlingXcode
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def pushStringsFromFiles(files, version)
|
78
|
-
sl = fileApi()
|
79
78
|
files.each do |f|
|
80
79
|
|
81
80
|
# Check if file exists
|
@@ -84,29 +83,58 @@ module SmartlingXcode
|
|
84
83
|
next
|
85
84
|
end
|
86
85
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
86
|
+
if f.to_s.end_with?(".strings")
|
87
|
+
pushStringsFile(f, version)
|
88
|
+
elsif
|
89
|
+
pushStringsdictFile(f, version)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def pushStringsFile(f, version)
|
95
|
+
sl = fileApi()
|
96
|
+
|
97
|
+
# Check if file contains at least one string
|
98
|
+
file = File.open(f)
|
99
|
+
line = file.read.scrub.tr("\000", '').gsub(/\s+/, "")
|
100
|
+
if !line.include?('=')
|
101
|
+
puts "No strings in #{f}"
|
102
|
+
return
|
103
|
+
end
|
104
|
+
|
105
|
+
remote_path = "/#{version}/#{f.to_s.split('/').last}"
|
106
|
+
|
107
|
+
# Upload
|
108
|
+
begin
|
109
|
+
res = sl.upload(f.to_s, remote_path, "ios", {:authorize => true})
|
110
|
+
if res
|
111
|
+
puts "Uploaded #{res['stringCount']} strings from #{f}"
|
112
|
+
end
|
113
|
+
rescue Exception => e
|
114
|
+
puts "⚠️ Upload failed for #{f}"
|
115
|
+
if e.message
|
116
|
+
puts e.message
|
93
117
|
end
|
118
|
+
end
|
119
|
+
end
|
94
120
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
121
|
+
def pushStringsdictFile(f, version)
|
122
|
+
sl = fileApi()
|
123
|
+
remote_path = "/#{version}/#{f.to_s.split('/').last}"
|
124
|
+
|
125
|
+
# Upload
|
126
|
+
begin
|
127
|
+
res = sl.upload(f.to_s, remote_path, "stringsdict", {:authorize => true})
|
128
|
+
if res
|
129
|
+
puts "Uploaded #{f}"
|
130
|
+
end
|
131
|
+
rescue Exception => e
|
132
|
+
puts "⚠️ Upload failed for #{f}"
|
133
|
+
if e.message
|
134
|
+
puts e.message
|
108
135
|
end
|
109
136
|
end
|
110
137
|
end
|
138
|
+
|
111
139
|
end
|
112
140
|
end
|
@@ -7,11 +7,17 @@ module Xcodeproj
|
|
7
7
|
def self.find(path)
|
8
8
|
# Get .xcodeproj path
|
9
9
|
if path.nil?
|
10
|
-
|
11
|
-
path = "./#{project_file}"
|
10
|
+
path = './'
|
12
11
|
end
|
13
12
|
|
14
|
-
if
|
13
|
+
if File.exist?(path)
|
14
|
+
if !path.end_with?(".xcodeproj")
|
15
|
+
project_file = Dir.entries(path).select {|f| f.end_with?(".xcodeproj") }.first
|
16
|
+
path = "#{path}/#{project_file}".gsub("//", "/")
|
17
|
+
end
|
18
|
+
|
19
|
+
puts "Using project #{path}"
|
20
|
+
|
15
21
|
# Open project
|
16
22
|
begin
|
17
23
|
return Xcodeproj::Project.open(path)
|
@@ -46,9 +52,9 @@ module Xcodeproj
|
|
46
52
|
strings_files.push(output_path)
|
47
53
|
end
|
48
54
|
|
49
|
-
# Loop on .strings files
|
55
|
+
# Loop on .strings and .stringsdict files
|
50
56
|
self.files.select{|f|
|
51
|
-
f.path.end_with?(".strings"
|
57
|
+
Project.fromBase(f.path) && f.path.end_with?(".strings", ".stringsdict")
|
52
58
|
}.each do |f|
|
53
59
|
strings_files.push(f.real_path)
|
54
60
|
end
|
@@ -57,11 +63,12 @@ module Xcodeproj
|
|
57
63
|
end
|
58
64
|
|
59
65
|
def getVersion
|
66
|
+
puts "Looking for an app version number to use for the strings files upload..."
|
60
67
|
versions = []
|
61
68
|
self.files.select{|f| f.path.end_with?(".plist")}.each do |f|
|
62
69
|
contents = Xcodeproj::Plist.read_from_path(f.real_path)
|
63
70
|
if contents['CFBundleShortVersionString']
|
64
|
-
versions.push({:version => contents['CFBundleShortVersionString'], :file => f.
|
71
|
+
versions.push({:version => contents['CFBundleShortVersionString'], :file => f.hierarchy_path})
|
65
72
|
end
|
66
73
|
end
|
67
74
|
|
@@ -71,13 +78,16 @@ module Xcodeproj
|
|
71
78
|
version = STDIN.gets.chomp
|
72
79
|
return version
|
73
80
|
when 1
|
74
|
-
|
81
|
+
file = versions.first
|
82
|
+
version = file[:version]
|
83
|
+
puts "Using #{version} found in #{file[:file]}"
|
84
|
+
return version
|
75
85
|
else
|
76
|
-
puts "Multiple Info.plist files found."
|
86
|
+
puts "Multiple Info.plist files found. Please select which version number to use:"
|
77
87
|
versions.each_with_index do |v, i|
|
78
88
|
puts "#{i}. #{v[:version]} from #{v[:file]}"
|
79
89
|
end
|
80
|
-
puts "
|
90
|
+
puts "Selection: "
|
81
91
|
choice = nil
|
82
92
|
while choice.nil?
|
83
93
|
choice = STDIN.gets.chomp.to_i
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartling_xcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emilien Huet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|