getlocal 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/bin/getLocal +3 -0
- data/getlocal.gemspec +29 -0
- data/lib/getlocal/cli.rb +179 -0
- data/lib/getlocal/version.rb +3 -0
- data/lib/getlocal.rb +5 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 74bf4766eb1564a037138eb4dc873f7201e45d08
|
4
|
+
data.tar.gz: 41975b5930c66b9fa9ccff8e610a6888c32d4ab0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cae4576a76bf16f306f537532a5670297705046baba5dba08bd64315f8fa6fdc6d155995ad4bc1789c88cba91e2d2015cb66ffee58eefdf20460e586f8915872
|
7
|
+
data.tar.gz: 4d6da4574fd4f2f353231eacd4015e516d84a03ded7c941ab7e2f4dd7f5ba73ccd130b8983c52380e6963ae5263272a0fbaade2e639241ac6d7f95b93e7bf752
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 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,49 @@
|
|
1
|
+
# Getlocal
|
2
|
+
|
3
|
+
A simple tool to help updating an xcode projects localizations useing the getlocalization.com API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'getlocal'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install getlocal
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
This tool should be called from the project folder that conatians your Base.lproj folder.
|
22
|
+
To upload all your strings files to getlocalization.com
|
23
|
+
|
24
|
+
$ getLocal update myproject -u me@example.com
|
25
|
+
|
26
|
+
To download all the translation files
|
27
|
+
|
28
|
+
$ getLocal update myproject -u me@example.com
|
29
|
+
|
30
|
+
I've written this to work with the folder structure that I use for all my projects. If you have a different folder structure this may not work for you.
|
31
|
+
It assumes your project looks a little like this:
|
32
|
+
|
33
|
+
- myProject.xcodeproj
|
34
|
+
- project_folder // Call get local from here
|
35
|
+
- Base.lproj
|
36
|
+
- Localizable.strings // This is your master copy
|
37
|
+
- Storyboard.storyboard
|
38
|
+
- Storyboard.strings // and so is this
|
39
|
+
- en.lproj
|
40
|
+
- Localizable.strings
|
41
|
+
- Storyboard.strings
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it ( https://github.com/BenjaminBriggs/getlocal/fork )
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/getLocal
ADDED
data/getlocal.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 'getlocal/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "getlocal"
|
8
|
+
spec.version = Getlocal::VERSION
|
9
|
+
spec.authors = ["Benjamin Briggs"]
|
10
|
+
spec.email = ["ben.briggs@me.com"]
|
11
|
+
spec.summary = "A simple tool to make keeping GetLocalisation up to date"
|
12
|
+
spec.description = "This is a in house tool developed by Palringo to help interface with the GetLocaization API"
|
13
|
+
spec.homepage = ""
|
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.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "thor"
|
25
|
+
spec.add_dependency "json"
|
26
|
+
spec.add_dependency "httmultiparty"
|
27
|
+
spec.add_dependency "rubyzip"
|
28
|
+
|
29
|
+
end
|
data/lib/getlocal/cli.rb
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'zip'
|
4
|
+
require 'thread'
|
5
|
+
require 'io/console'
|
6
|
+
|
7
|
+
require 'thor'
|
8
|
+
require 'httmultiparty'
|
9
|
+
|
10
|
+
require 'getlocal'
|
11
|
+
|
12
|
+
Thread.abort_on_exception = true
|
13
|
+
|
14
|
+
module Getlocal
|
15
|
+
class CLI < Thor
|
16
|
+
class_option :verbose, :type => :boolean, :aliases => "-v"
|
17
|
+
|
18
|
+
method_option :user, :required => true, :aliases => "-u"
|
19
|
+
method_option :password, :aliases => "-p"
|
20
|
+
desc "fetch [PROJECT]", "Used to fetch the latest localisations"
|
21
|
+
def fetch(project)
|
22
|
+
|
23
|
+
# Check if we are in the right place
|
24
|
+
if Dir.glob('*.lproj').empty?
|
25
|
+
puts "Wrong directory please select the directory that contains the .lproj folders"
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
29
|
+
username = options[:user]
|
30
|
+
|
31
|
+
# Check if we need to ask for a password
|
32
|
+
if options[:password]
|
33
|
+
password = options[:password]
|
34
|
+
else
|
35
|
+
print "Password:"
|
36
|
+
password = STDIN.noecho(&:gets).chomp
|
37
|
+
puts ""
|
38
|
+
end
|
39
|
+
|
40
|
+
if !options[:verbose] then
|
41
|
+
Thread.new do
|
42
|
+
#set up spinner
|
43
|
+
glyphs = ['|', '/', '-', "\\"]
|
44
|
+
while true
|
45
|
+
glyphs.each do |g|
|
46
|
+
print "\r#{g}"
|
47
|
+
sleep 0.15
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
auth = {:username => username, :password => password}
|
54
|
+
|
55
|
+
puts "Fetching the zip. This may take a while" if options[:verbose]
|
56
|
+
|
57
|
+
zipfile = Tempfile.new("file")
|
58
|
+
|
59
|
+
begin
|
60
|
+
response = HTTParty.get("https://api.getlocalization.com/#{project}/api/translations/zip/", :basic_auth => auth, :timeout => 600)
|
61
|
+
rescue
|
62
|
+
puts "Oh no, somthing fucked up."
|
63
|
+
return
|
64
|
+
else
|
65
|
+
if response.code == 200
|
66
|
+
puts "Zip downloaded" if options[:verbose]
|
67
|
+
zipfile.binmode # This might not be necessary depending on the zip file
|
68
|
+
zipfile.write(response.body)
|
69
|
+
elsif response.code == 401
|
70
|
+
puts "The username or password are invailed"
|
71
|
+
return
|
72
|
+
else
|
73
|
+
puts "Bad response. Close but no cigar."
|
74
|
+
return
|
75
|
+
end
|
76
|
+
ensure
|
77
|
+
zipfile.close
|
78
|
+
end
|
79
|
+
|
80
|
+
puts "Extracting the zip" if options[:verbose]
|
81
|
+
Zip::File.open(zipfile.path) do |zipFile|
|
82
|
+
# Handle entries one by one
|
83
|
+
zipFile.each do |entry|
|
84
|
+
# Extract to correct location
|
85
|
+
pathComponents = entry.name.split("/")
|
86
|
+
|
87
|
+
destFolder = pathComponents[0] + '.lproj'
|
88
|
+
destFile = pathComponents[1]
|
89
|
+
|
90
|
+
destPath = destFolder + '/' + destFile
|
91
|
+
|
92
|
+
if Dir.exists?(destFolder)
|
93
|
+
puts "Extracting #{destFile} to #{destPath}" if options[:verbose]
|
94
|
+
File.delete(destPath) if File.exist?(destPath)
|
95
|
+
entry.extract(destPath)
|
96
|
+
else
|
97
|
+
puts destFolder + " folder not found. Couldn't import " + destFile if options[:verbose]
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
method_option :user, :required => true, :aliases => "-u"
|
106
|
+
method_option :password, :aliases => "-p"
|
107
|
+
desc "update [PROJECT]", "Used to send the latest localisations to get localization"
|
108
|
+
def update(project)
|
109
|
+
username = options[:user]
|
110
|
+
|
111
|
+
# Check if we need to ask for a password
|
112
|
+
if options[:password]
|
113
|
+
password = options[:password]
|
114
|
+
else
|
115
|
+
print "Password:"
|
116
|
+
password = STDIN.noecho(&:gets).chomp
|
117
|
+
puts ""
|
118
|
+
end
|
119
|
+
|
120
|
+
if !options[:verbose] then
|
121
|
+
Thread.new do
|
122
|
+
#set up spinner
|
123
|
+
glyphs = ['|', '/', '-', "\\"]
|
124
|
+
while true
|
125
|
+
glyphs.each do |g|
|
126
|
+
print "\r#{g}"
|
127
|
+
sleep 0.15
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
auth = {:username => username, :password => password}
|
134
|
+
|
135
|
+
puts "Requesting the list of master files" if options[:verbose]
|
136
|
+
response = HTTParty.get("https://api.getlocalization.com/#{project}/api/list-master/json/", :basic_auth => auth)
|
137
|
+
if response.code == 200 then
|
138
|
+
parsedResponse = JSON.parse(response.body)
|
139
|
+
if parsedResponse['success'] == "1"
|
140
|
+
puts "Recived list" if options[:verbose]
|
141
|
+
currentMasterFiles = parsedResponse['master_files']
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
responceCodes = []
|
146
|
+
|
147
|
+
Dir.glob("Base.lproj/*.strings") do |stringFilePath|
|
148
|
+
|
149
|
+
alreadyExists = currentMasterFiles.include?(stringFilePath.gsub("Base.lproj/", ""))
|
150
|
+
|
151
|
+
body = {"file" => File.new(stringFilePath)}
|
152
|
+
|
153
|
+
puts "Uploading " + stringFilePath if options[:verbose]
|
154
|
+
|
155
|
+
if alreadyExists
|
156
|
+
# Update master
|
157
|
+
response = HTTMultiParty.post("https://api.getlocalization.com/#{project}/api/update-master/", :basic_auth => auth, :query => body)
|
158
|
+
responceCodes << response.code
|
159
|
+
else
|
160
|
+
#Upload new master
|
161
|
+
response = HTTMultiParty.post("https://api.getlocalization.com/#{project}/api/create-master/ios/en/", :basic_auth => auth, :query => body)
|
162
|
+
responceCodes << response.code
|
163
|
+
end
|
164
|
+
|
165
|
+
puts "Upload complete with responce code " + response.code if options[:verbose]
|
166
|
+
puts "" if options[:verbose]
|
167
|
+
end
|
168
|
+
|
169
|
+
if responceCodes.include?(400)
|
170
|
+
puts "The request was malformed please try again"
|
171
|
+
elsif responceCodes.include?(404)
|
172
|
+
puts "The username or password are invailed"
|
173
|
+
else
|
174
|
+
puts ""
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
data/lib/getlocal.rb
ADDED
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: getlocal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Benjamin Briggs
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-09 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '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'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
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'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubyzip
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: This is a in house tool developed by Palringo to help interface with
|
98
|
+
the GetLocaization API
|
99
|
+
email:
|
100
|
+
- ben.briggs@me.com
|
101
|
+
executables:
|
102
|
+
- getLocal
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- .gitignore
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/getLocal
|
112
|
+
- getlocal.gemspec
|
113
|
+
- lib/getlocal.rb
|
114
|
+
- lib/getlocal/cli.rb
|
115
|
+
- lib/getlocal/version.rb
|
116
|
+
homepage: ''
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.0.14
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: A simple tool to make keeping GetLocalisation up to date
|
140
|
+
test_files: []
|