smartling_xcode 0.1.1 → 0.1.2
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 +31 -16
- data/lib/smartling_xcode/backend.rb +8 -3
- data/lib/smartling_xcode/version.rb +1 -1
- data/lib/smartling_xcode/xcode.rb +34 -0
- data/lib/smartling_xcode.rb +8 -4
- 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: 53fca9c7b7ea263102d71839d84c897eeef271e4
|
4
|
+
data.tar.gz: 667cc5a69305e6c6ab0ddc9db1a96ea116a95d89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8964deb3083a1c24892da436234c07bdc1033e939696279e072f3fa7079d4cf1db3899dd54e817d16f76d470bd6eabef57457f366cf3ba73db1f9953017bb6d2
|
7
|
+
data.tar.gz: dd0d473efce5db5908b8a9360600a2348225316f949f57d8c15b36a2d29c73463f6429960e1d6451e1b808383bcebabf11b93e929f335f60b297bc03a47e1b32
|
data/bin/smartling_xcode
CHANGED
@@ -4,33 +4,45 @@ require "smartling_xcode"
|
|
4
4
|
|
5
5
|
# Parse options
|
6
6
|
USAGE = <<ENDUSAGE
|
7
|
-
Smartling utility to extract strings from an Xcode project
|
7
|
+
Smartling utility to extract strings from an Xcode project
|
8
|
+
and add them to a Smartling project.
|
8
9
|
Version #{SmartlingXcode::VERSION}
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
smartling_xcode -v/--version
|
11
|
+
Usage:
|
12
|
+
smartling_xcode command [project_path] [-v version]
|
13
|
+
smartling_xcode -h/--help
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
Commands:
|
16
|
+
init Configure the current folder with Smartling
|
17
|
+
project credentials to be able to push
|
18
|
+
strings.
|
19
|
+
extract Extract all strings from the Xcode project
|
20
|
+
and print out the list of .strings files.
|
21
|
+
push Extract all strings from the Xcode project
|
22
|
+
and send them to your Smartling project.
|
19
23
|
|
20
|
-
|
21
|
-
|
24
|
+
Options:
|
25
|
+
project_path Specify a path for the Xcode project.
|
26
|
+
Uses the first .xcodeproj file in the
|
27
|
+
current directory by default.
|
28
|
+
-v version Specify an app version for the strings
|
29
|
+
files upload. Uses the version found in
|
30
|
+
the project's info.plist file by default,
|
31
|
+
but will prompt for a choice if multiple
|
32
|
+
plist files are found.
|
22
33
|
|
23
34
|
ENDUSAGE
|
24
35
|
|
25
36
|
# Parse CLI arguments
|
26
37
|
project_path = nil
|
27
38
|
command = nil
|
39
|
+
version = nil
|
40
|
+
version_is_next = false
|
28
41
|
ARGV.each do |arg|
|
29
42
|
case arg
|
30
43
|
# Flags
|
31
|
-
when '-v'
|
32
|
-
|
33
|
-
Kernel.exit(0)
|
44
|
+
when '-v'
|
45
|
+
version_is_next = true
|
34
46
|
when '-h', '--help'
|
35
47
|
puts USAGE
|
36
48
|
Kernel.exit(0)
|
@@ -41,13 +53,16 @@ ARGV.each do |arg|
|
|
41
53
|
else
|
42
54
|
if command.nil?
|
43
55
|
Kernel.abort(USAGE)
|
44
|
-
|
56
|
+
elsif version_is_next
|
57
|
+
version = arg
|
58
|
+
version_is_next = false
|
59
|
+
else
|
45
60
|
project_path = arg
|
46
61
|
end
|
47
62
|
end
|
48
63
|
end
|
49
64
|
|
50
|
-
result = SmartlingXcode.execute(command, project_path)
|
65
|
+
result = SmartlingXcode.execute(command, project_path, version)
|
51
66
|
if result != 0
|
52
67
|
Kernel.abort(USAGE)
|
53
68
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'smartling'
|
2
2
|
require 'json'
|
3
|
+
require 'shellwords'
|
3
4
|
|
4
5
|
module SmartlingXcode
|
5
6
|
CREDFILE = './.smartling.json'
|
@@ -53,11 +54,13 @@ module SmartlingXcode
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
|
-
def self.pushStringsFromFiles(files, creds)
|
57
|
+
def self.pushStringsFromFiles(files, version, creds)
|
57
58
|
sl = Smartling::File.new(:apiKey => creds['api_key'], :projectId => creds['project_id'])
|
58
59
|
files.each do |f|
|
60
|
+
|
59
61
|
# Check if file exists
|
60
|
-
if !File.exist?(f)
|
62
|
+
if !f || !File.exist?(f)
|
63
|
+
puts "File not found #{f}"
|
61
64
|
next
|
62
65
|
end
|
63
66
|
|
@@ -69,9 +72,11 @@ module SmartlingXcode
|
|
69
72
|
next
|
70
73
|
end
|
71
74
|
|
75
|
+
remote_path = "/#{version}/#{f.to_s.split('/').last}"
|
76
|
+
|
72
77
|
# Upload
|
73
78
|
begin
|
74
|
-
res = sl.upload(f,
|
79
|
+
res = sl.upload(f.to_s, remote_path, "ios", {:approved => true})
|
75
80
|
if res
|
76
81
|
puts "Uploaded #{res['stringCount']} strings from #{f}"
|
77
82
|
end
|
@@ -54,4 +54,38 @@ module SmartlingXcode
|
|
54
54
|
|
55
55
|
return strings_files
|
56
56
|
end
|
57
|
+
|
58
|
+
def self.getVersion(project)
|
59
|
+
versions = []
|
60
|
+
project.files.select{|f| f.path.end_with?(".plist")}.each do |f|
|
61
|
+
contents = Xcodeproj::Plist.read_from_path(f.real_path)
|
62
|
+
if contents['CFBundleShortVersionString']
|
63
|
+
versions.push({:version => contents['CFBundleShortVersionString'], :file => f.path})
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
case versions.count
|
68
|
+
when 0
|
69
|
+
puts "No app version found in project.\nPlease enter a version number:"
|
70
|
+
version = STDIN.gets.chomp
|
71
|
+
return version
|
72
|
+
when 1
|
73
|
+
return versions.first[:version]
|
74
|
+
else
|
75
|
+
puts "Multiple Info.plist files found."
|
76
|
+
versions.each do |v, i|
|
77
|
+
puts "#{i}. #{v[:version]} from #{:file}"
|
78
|
+
end
|
79
|
+
puts "Please select which version number to use:"
|
80
|
+
choice = nil
|
81
|
+
while choice.nil?
|
82
|
+
choice = STDIN.gets.chomp.to_i
|
83
|
+
if choice < versions.count
|
84
|
+
return versions[choice][:version]
|
85
|
+
end
|
86
|
+
choice = nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
57
91
|
end
|
data/lib/smartling_xcode.rb
CHANGED
@@ -3,21 +3,25 @@ require "smartling_xcode/backend"
|
|
3
3
|
require "smartling_xcode/version"
|
4
4
|
|
5
5
|
module SmartlingXcode
|
6
|
-
def self.execute(command, project_path)
|
6
|
+
def self.execute(command, project_path, version)
|
7
7
|
# Execute commands
|
8
8
|
case command
|
9
9
|
when 'init'
|
10
10
|
requestCredentials
|
11
11
|
return 0
|
12
12
|
when 'extract'
|
13
|
-
files = extract
|
13
|
+
files = extract(openProject(project_path))
|
14
14
|
puts "\nOutput:"
|
15
15
|
puts files
|
16
16
|
return 0
|
17
17
|
when 'push'
|
18
18
|
creds = loadCredentials
|
19
|
-
|
20
|
-
|
19
|
+
project = openProject(project_path)
|
20
|
+
files = extract(project)
|
21
|
+
if version.nil?
|
22
|
+
version = getVersion(project)
|
23
|
+
end
|
24
|
+
pushStringsFromFiles(files, version, creds)
|
21
25
|
puts "\nYour files are now available in the Files section of your Smartling project."
|
22
26
|
return 0
|
23
27
|
else
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emilien Huet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|