icapps-translations 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +21 -0
- data/README.md +3 -2
- data/Rakefile +1 -2
- data/icapps-translations.gemspec +10 -10
- data/lib/icapps/translations/cli.rb +2 -2
- data/lib/icapps/translations/configuration.rb +20 -9
- data/lib/icapps/translations/http.rb +2 -2
- data/lib/icapps/translations/import/base.rb +2 -2
- data/lib/icapps/translations/import/gradle.rb +7 -4
- data/lib/icapps/translations/import/xcode.rb +2 -2
- data/lib/icapps/translations/version.rb +1 -1
- data/lib/icapps/translations.rb +12 -12
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dd2178741324fa58e7936b8807d41bdda6ec28a
|
4
|
+
data.tar.gz: a86b14558053d326198c1d2dc913e810124249e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1df6931a9b3cad88373fd51f62108fa4e4f810d58d61ccb19116a9d7448455cb05b77babb41474abf55831b10eac69ff5dd49e82648ee33d553fe2f91ec493d
|
7
|
+
data.tar.gz: be7e24477c232b132b4097ff123a2997dd298c50dcee80d30ca24cf83b27bf322d996de73a3e541ddd9370362f4fb053453ea1eb4530bfb53c4fa26e9b342089
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2015-10-13 11:47:22 +0200 using RuboCop version 0.29.1.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
Metrics/AbcSize:
|
9
|
+
Max: 21
|
10
|
+
|
11
|
+
Metrics/LineLength:
|
12
|
+
Max: 143
|
13
|
+
|
14
|
+
Metrics/MethodLength:
|
15
|
+
Max: 12
|
16
|
+
|
17
|
+
Style/Documentation:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Style/GuardClause:
|
21
|
+
Enabled: false
|
data/README.md
CHANGED
@@ -39,5 +39,6 @@ Then build the gem by running the following commands:
|
|
39
39
|
1. Fork it ( https://github.com/icapps/translations/fork )
|
40
40
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
41
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
-
4.
|
43
|
-
5.
|
42
|
+
4. Run `rubycop` in order to be compliant to our coding style.
|
43
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
6. Create a new Pull Request
|
data/Rakefile
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'bundler/gem_tasks'
|
data/icapps-translations.gemspec
CHANGED
@@ -4,21 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'icapps/translations/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'icapps-translations'
|
8
8
|
spec.version = Icapps::Translations::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
9
|
+
spec.authors = ['Jelle Vandebeeck']
|
10
|
+
spec.email = ['jelle.vandebeeck@icapps.com']
|
11
|
+
spec.summary = 'Import translations from the iCapps translations portal.'
|
12
12
|
spec.homepage = 'https://github.com/icapps/translations'
|
13
|
-
spec.license =
|
13
|
+
spec.license = 'MIT'
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
16
|
-
spec.executables = spec.files.grep(
|
17
|
-
spec.test_files = spec.files.grep(
|
18
|
-
spec.require_paths = [
|
16
|
+
spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)/)
|
18
|
+
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.add_development_dependency
|
21
|
-
spec.add_development_dependency
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
21
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
22
22
|
|
23
23
|
spec.add_dependency 'thor', '~> 0.19'
|
24
24
|
spec.add_dependency 'colorize', '~> 0.7'
|
@@ -4,9 +4,10 @@ require 'yaml'
|
|
4
4
|
module Icapps
|
5
5
|
module Translations
|
6
6
|
class Configuration
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
attr_reader :url
|
8
|
+
attr_reader :filename
|
9
|
+
attr_reader :project_key
|
10
|
+
attr_reader :default_language
|
10
11
|
|
11
12
|
class << self
|
12
13
|
def create
|
@@ -15,12 +16,12 @@ module Icapps
|
|
15
16
|
return
|
16
17
|
end
|
17
18
|
|
18
|
-
File.open(path,
|
19
|
+
File.open(path, 'w') { |f| f.write(initial_content.to_yaml) }
|
19
20
|
puts "[MESSAGE] Configuration created at '#{path}'.".colorize(:green)
|
20
21
|
end
|
21
22
|
|
22
23
|
def exists?
|
23
|
-
File.
|
24
|
+
File.exist?(path)
|
24
25
|
end
|
25
26
|
|
26
27
|
def path
|
@@ -36,6 +37,15 @@ module Icapps
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def initial_content
|
40
|
+
::Icapps::Translations.android? ? android_initial_content : common_initial_content
|
41
|
+
end
|
42
|
+
|
43
|
+
def android_initial_content
|
44
|
+
common_initial_content.merge!(filename: 'strings.xml',
|
45
|
+
default_language: 'en')
|
46
|
+
end
|
47
|
+
|
48
|
+
def common_initial_content
|
39
49
|
{
|
40
50
|
url: 'http://your_url.com',
|
41
51
|
filename: 'Localizable.strings',
|
@@ -59,11 +69,12 @@ module Icapps
|
|
59
69
|
def read_config
|
60
70
|
puts "[VERBOSE] Reading the config file at '#{Configuration.path}'.".colorize(:white) if Configuration.options[:verbose]
|
61
71
|
|
62
|
-
params = YAML
|
72
|
+
params = YAML.load File.open(Configuration.path)
|
63
73
|
if params
|
64
|
-
@filename
|
65
|
-
@url
|
66
|
-
@project_key
|
74
|
+
@filename = params[:filename]
|
75
|
+
@url = params[:url]
|
76
|
+
@project_key = params[:project_key]
|
77
|
+
@default_language = params[:default_language]
|
67
78
|
end
|
68
79
|
end
|
69
80
|
end
|
@@ -6,13 +6,13 @@ module Icapps
|
|
6
6
|
module Translations
|
7
7
|
class Http
|
8
8
|
class << self
|
9
|
-
def authenticated_response(path, is_json=false)
|
9
|
+
def authenticated_response(path, is_json = false)
|
10
10
|
uri = URI("#{config.url}/#{path}")
|
11
11
|
puts "[VERBOSE] Connecting to url '#{uri}'.".colorize(:white) if options[:verbose]
|
12
12
|
|
13
13
|
http = Net::HTTP.new(uri.host, uri.port)
|
14
14
|
request = Net::HTTP::Get.new(uri)
|
15
|
-
request.add_field
|
15
|
+
request.add_field 'Authorization', "Token token=#{config.project_key}"
|
16
16
|
response = http.request(request)
|
17
17
|
is_json ? JSON.parse(response.body) : response.body
|
18
18
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'colorize'
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'icapps/translations/http'
|
4
4
|
|
5
5
|
module Icapps
|
6
6
|
module Translations
|
@@ -14,7 +14,7 @@ module Icapps
|
|
14
14
|
puts "[VERBOSE] There are currently #{languages_json.count} language(s) for this project.".colorize(:white) if options[:verbose]
|
15
15
|
|
16
16
|
languages_json.each { |language| fetch_language_file language }
|
17
|
-
puts
|
17
|
+
puts '[MESSAGE] Finished importing translation.'.colorize(:green)
|
18
18
|
end
|
19
19
|
|
20
20
|
def options
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'colorize'
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'icapps/translations/http'
|
4
|
+
require 'icapps/translations/import/base'
|
5
5
|
|
6
6
|
module Icapps
|
7
7
|
module Translations
|
@@ -27,9 +27,12 @@ module Icapps
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
+
def default_language
|
31
|
+
config.default_language || 'en'
|
32
|
+
end
|
33
|
+
|
30
34
|
def values_name(short_name)
|
31
|
-
if short_name ==
|
32
|
-
# Default language is English.
|
35
|
+
if short_name == default_language
|
33
36
|
'values'
|
34
37
|
else
|
35
38
|
# Android requires the country code to be prefixed with an 'r'.
|
data/lib/icapps/translations.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'icapps/translations/version'
|
2
|
+
require 'icapps/translations/cli'
|
3
|
+
require 'icapps/translations/import/xcode'
|
4
|
+
require 'icapps/translations/import/gradle'
|
5
5
|
|
6
6
|
module Icapps
|
7
7
|
module Translations
|
@@ -17,23 +17,23 @@ module Icapps
|
|
17
17
|
config.validate
|
18
18
|
|
19
19
|
# Import the files.
|
20
|
-
if
|
21
|
-
puts
|
20
|
+
if xcode?
|
21
|
+
puts '[VERBOSE] Detected an Xcode project.'.colorize(:white) if options[:verbose]
|
22
22
|
Import::Xcode.import
|
23
|
-
elsif
|
24
|
-
puts
|
23
|
+
elsif android?
|
24
|
+
puts '[VERBOSE] Detected an Android project with a .gradle file.'.colorize(:white) if options[:verbose]
|
25
25
|
Import::Gradle.import
|
26
26
|
else
|
27
27
|
abort '[ERROR] No Xcode or Android gradle file detected.'.colorize(:red) unless @project_key
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
Dir.glob(
|
31
|
+
def android?
|
32
|
+
Dir.glob('**/*.gradle').count > 0
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
Dir.glob(
|
35
|
+
def xcode?
|
36
|
+
Dir.glob('**/*.xcodeproj').count > 0
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icapps-translations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jelle Vandebeeck
|
@@ -75,6 +75,7 @@ extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
|
+
- ".rubocop.yml"
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.md
|