lifft 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +48 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +2 -0
- data/bin/lifft +3 -0
- data/lib/lifft.rb +5 -0
- data/lib/lifft/cli.rb +174 -0
- data/lib/lifft/version.rb +3 -0
- data/lifft.gemspec +29 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 788b14726ef98b508f3ff744904afab67e768b8c
|
4
|
+
data.tar.gz: 06f4d9ad44a561eb6533f36b9b339cabc66c4e87
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1765d84e491923968312ef52b66ca245a4b2115e1480d475cce1beabf3ceee8451858da7af6a015fbb710bbb564c754f743b20b23d93a0ecc5f7bd637dec5dcf
|
7
|
+
data.tar.gz: 9f83de6aa7f19de803cc6dc3399f88b4568dbe36b84baf8ebc5c25d42c1f3f2400b267c63b8c7415167497d40d61b40669c6f31ec248537ca873c778beddaf7e
|
data/.gitignore
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
*.bundle
|
11
|
+
*.so
|
12
|
+
*.o
|
13
|
+
*.a
|
14
|
+
mkmf.log
|
15
|
+
*.gem
|
16
|
+
*.rbc
|
17
|
+
/.config
|
18
|
+
/coverage/
|
19
|
+
/InstalledFiles
|
20
|
+
/pkg/
|
21
|
+
/spec/reports/
|
22
|
+
/test/tmp/
|
23
|
+
/test/version_tmp/
|
24
|
+
/tmp/
|
25
|
+
|
26
|
+
## Specific to RubyMotion:
|
27
|
+
.dat*
|
28
|
+
.repl_history
|
29
|
+
build/
|
30
|
+
|
31
|
+
## Documentation cache and generated files:
|
32
|
+
/.yardoc/
|
33
|
+
/_yardoc/
|
34
|
+
/doc/
|
35
|
+
/rdoc/
|
36
|
+
|
37
|
+
## Environment normalisation:
|
38
|
+
/.bundle/
|
39
|
+
/lib/bundler/man/
|
40
|
+
|
41
|
+
# for a library or gem, you might want to ignore these files since the country is
|
42
|
+
# intended to run in multiple environments; otherwise, check them in:
|
43
|
+
# Gemfile.lock
|
44
|
+
# .ruby-version
|
45
|
+
# .ruby-gemset
|
46
|
+
|
47
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
48
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Benjamin Briggs
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Lifft
|
2
|
+
|
3
|
+
This is just a little helper for extracting Xliff files from an Xcode project and uploding them to the GetLocalization translation service.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'lifft'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install lifft
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
$ lifft update <the name of you GetLocalization project> --project <your.xcodeproj> -u <username> [-n (if it's new)]
|
24
|
+
|
25
|
+
$ lifft fetch <the name of you GetLocalization project> --project <your.xcodeproj> -u <username>
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/BenjaminBriggs/lifft/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/lifft
ADDED
data/lib/lifft.rb
ADDED
data/lib/lifft/cli.rb
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'zip'
|
4
|
+
require 'thread'
|
5
|
+
require 'io/console'
|
6
|
+
require 'tmpdir'
|
7
|
+
|
8
|
+
require 'thor'
|
9
|
+
require 'httmultiparty'
|
10
|
+
require 'iso-639'
|
11
|
+
|
12
|
+
require 'lifft'
|
13
|
+
|
14
|
+
Thread.abort_on_exception = true
|
15
|
+
|
16
|
+
module Lifft
|
17
|
+
class CLI < Thor
|
18
|
+
class_option :verbose, :type => :boolean, :aliases => "-v"
|
19
|
+
|
20
|
+
method_option :user, :required => true, :aliases => "-u"
|
21
|
+
method_option :project, :required => true, :type => :string
|
22
|
+
method_option :password, :aliases => "-p"
|
23
|
+
method_option :timeout, :type => :numeric, :default => 600, :aliases => "-t"
|
24
|
+
desc "fetch [PROJECT]", "Used to fetch the latest localisations"
|
25
|
+
def fetch(project)
|
26
|
+
|
27
|
+
projectName = options[:project]
|
28
|
+
username = options[:user]
|
29
|
+
|
30
|
+
# Check if we need to ask for a password
|
31
|
+
if options[:password]
|
32
|
+
password = options[:password]
|
33
|
+
else
|
34
|
+
print "Password:"
|
35
|
+
password = STDIN.noecho(&:gets).chomp
|
36
|
+
puts ""
|
37
|
+
end
|
38
|
+
|
39
|
+
if !options[:verbose] then
|
40
|
+
Thread.new do
|
41
|
+
#set up spinner
|
42
|
+
glyphs = ['|', '/', '-', "\\"]
|
43
|
+
while true
|
44
|
+
glyphs.each do |g|
|
45
|
+
print "\r#{g}"
|
46
|
+
sleep 0.15
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
auth = {:username => username, :password => password}
|
53
|
+
warningSuppressor = options[:verbose]? "" : " > /dev/null 2>&1"
|
54
|
+
|
55
|
+
Dir.glob("**/*.lproj/") do |langFolder|
|
56
|
+
|
57
|
+
lang = File.basename(langFolder).chomp(".lproj")
|
58
|
+
country = ISO_639.find_by_code(lang)
|
59
|
+
|
60
|
+
puts lang
|
61
|
+
|
62
|
+
if country.respond_to?(:english_name) then
|
63
|
+
puts "Fetching translations for #{country.english_name}." if options[:verbose]
|
64
|
+
else
|
65
|
+
puts "Fetching translations for #{lang}." if options[:verbose]
|
66
|
+
end
|
67
|
+
|
68
|
+
puts "https://api.getlocalization.com/#{project}/api/translations/file/en.xliff/#{lang}/" if options[:verbose]
|
69
|
+
puts "This may take a while!" if options[:verbose]
|
70
|
+
|
71
|
+
if options[:verbose] then
|
72
|
+
spinner = Thread.new do
|
73
|
+
#set up spinner
|
74
|
+
glyphs = ['|', '/', '-', "\\"]
|
75
|
+
while true
|
76
|
+
glyphs.each do |g|
|
77
|
+
print "\r#{g}"
|
78
|
+
sleep 0.15
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
tempfile = Tempfile.new("file")
|
85
|
+
|
86
|
+
begin
|
87
|
+
response = HTTParty.get("https://api.getlocalization.com/#{project}/api/translations/file/en.xliff/#{lang}/", :basic_auth => auth, :timeout => options[:timeout])
|
88
|
+
rescue
|
89
|
+
puts "Oh no, somthing fucked up."
|
90
|
+
return
|
91
|
+
else
|
92
|
+
spinner.exit if options[:verbose]
|
93
|
+
puts "\r" if options[:verbose]
|
94
|
+
if response.code == 200
|
95
|
+
puts "File downloaded" if options[:verbose]
|
96
|
+
tempfile.binmode # This might not be necessary depending on the zip file
|
97
|
+
tempfile.write(response.body)
|
98
|
+
puts "Importing the file" if options[:verbose]
|
99
|
+
system("xcodebuild -importLocalizations -localizationPath #{tempfile.path.chomp} -project #{projectName.chomp}"+warningSuppressor)
|
100
|
+
elsif response.code == 401
|
101
|
+
puts "The username or password are invailed"
|
102
|
+
return
|
103
|
+
else
|
104
|
+
puts "Bad response. Close but no cigar."
|
105
|
+
if country.respond_to?(:english_name) then
|
106
|
+
puts "Sorry #{country.english_name} not this time."
|
107
|
+
end
|
108
|
+
end
|
109
|
+
ensure
|
110
|
+
tempfile.close
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
method_option :user, :required => true, :aliases => "-u"
|
117
|
+
method_option :project, :required => true, :type => :string
|
118
|
+
method_option :password, :aliases => "-p"
|
119
|
+
method_option :new, :type => :boolean, :aliases => "-n"
|
120
|
+
desc "update [PROJECT]", "Used to send the latest localisations to get localization"
|
121
|
+
def update(project)
|
122
|
+
username = options[:user]
|
123
|
+
|
124
|
+
# Check if we need to ask for a password
|
125
|
+
if options[:password]
|
126
|
+
password = options[:password]
|
127
|
+
else
|
128
|
+
print "Password:"
|
129
|
+
password = STDIN.noecho(&:gets).chomp
|
130
|
+
puts ""
|
131
|
+
end
|
132
|
+
|
133
|
+
warningSuppressor = options[:verbose]? "" : " > /dev/null 2>&1"
|
134
|
+
|
135
|
+
if !options[:verbose] then
|
136
|
+
Thread.new do
|
137
|
+
# Set up spinner
|
138
|
+
glyphs = ['|', '/', '-', "\\"]
|
139
|
+
while true
|
140
|
+
glyphs.each do |g|
|
141
|
+
print "\r#{g}"
|
142
|
+
sleep 0.15
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
auth = {:username => username, :password => password}
|
149
|
+
|
150
|
+
projectName = options[:project]
|
151
|
+
|
152
|
+
dir = Dir.mktmpdir
|
153
|
+
|
154
|
+
system("xcodebuild -exportLocalizations -localizationPath #{dir.chomp} -project #{projectName.chomp}"+warningSuppressor)
|
155
|
+
|
156
|
+
body = {"file" => File.new(dir+"/en.xliff")}
|
157
|
+
|
158
|
+
if !options[:new]
|
159
|
+
# Update master
|
160
|
+
puts "Updateing " + "en.xliff" if options[:verbose]
|
161
|
+
response = HTTMultiParty.post("https://api.getlocalization.com/#{project}/api/update-master/", :basic_auth => auth, :query => body)
|
162
|
+
else
|
163
|
+
# Upload new master
|
164
|
+
puts "Creating " + "en.xliff" if options[:verbose]
|
165
|
+
response = HTTMultiParty.post("https://api.getlocalization.com/#{project}/api/create-master/ios/en/", :basic_auth => auth, :query => body)
|
166
|
+
end
|
167
|
+
|
168
|
+
puts "Upload complete with responce code #{response.code}" if options[:verbose]
|
169
|
+
puts "" if options[:verbose]
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
end
|
data/lifft.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lifft/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lifft"
|
8
|
+
spec.version = Lifft::VERSION
|
9
|
+
spec.authors = ["Benjamin Briggs"]
|
10
|
+
spec.email = ["ben@palringo.com"]
|
11
|
+
spec.summary = "Xliffs to GetLocalization"
|
12
|
+
spec.description = "A tool simple too for uploading Xliffs to GetLocalization"
|
13
|
+
spec.homepage = "https://github.com/BenjaminBriggs/lifft"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
|
24
|
+
spec.add_dependency "thor", '~> 0.19'
|
25
|
+
spec.add_dependency "json", '~> 1.8'
|
26
|
+
spec.add_dependency "httmultiparty", '~> 0.3'
|
27
|
+
spec.add_dependency "iso-639", '~>0.2'
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lifft
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Benjamin Briggs
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.19'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.19'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.8'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: httmultiparty
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.3'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: iso-639
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.2'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.2'
|
97
|
+
description: A tool simple too for uploading Xliffs to GetLocalization
|
98
|
+
email:
|
99
|
+
- ben@palringo.com
|
100
|
+
executables:
|
101
|
+
- lifft
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .gitignore
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/lifft
|
111
|
+
- lib/lifft.rb
|
112
|
+
- lib/lifft/cli.rb
|
113
|
+
- lib/lifft/version.rb
|
114
|
+
- lifft.gemspec
|
115
|
+
homepage: https://github.com/BenjaminBriggs/lifft
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.4.5
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Xliffs to GetLocalization
|
139
|
+
test_files: []
|