i18n-migrations 1.1.2 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/bin/i18n-migrate +5 -2
- data/i18n-migrations.gemspec +1 -1
- data/lib/i18n/migrations/crowd_translate_client.rb +42 -13
- data/lib/i18n/migrations/locale.rb +0 -1
- data/lib/i18n/migrations/migration_factory.rb +5 -1
- data/lib/i18n/migrations/migrator.rb +1 -1
- data/lib/i18n/migrations/version.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0f8d5372c9541fdf212f771cbf6fa9f8159fb4f6fb5dab37beca63862cf2deb
|
4
|
+
data.tar.gz: 6f6d8dc7c053da0500415dbe8999bd015eec3023d92898c177b54af5962b4fc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 905e9f53dda1e46c7a169ffe869260854964fa323baf030d71f8c9d76d16ba40db658b0235da346256123c8a3e21d0805beef3c055c6efc733e8070a02f0403f
|
7
|
+
data.tar.gz: f3f1cec60dfb164bc0d61e9a81004eb9ebd527568613af170f9d3429e15bf9ddc1803f8258476c5c621e299e3ee87354067e361e34ee29b37937dc8ee74827f3
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.6.
|
1
|
+
ruby-2.6.5
|
data/Gemfile
CHANGED
data/bin/i18n-migrate
CHANGED
@@ -46,10 +46,10 @@ case ARGV.shift
|
|
46
46
|
force = extract_option('-f')
|
47
47
|
migrator.push(ARGV[0] || 'all', force)
|
48
48
|
|
49
|
-
when '
|
49
|
+
when 'ct-pull'
|
50
50
|
migrator.exp_pull(ARGV[0] || 'all')
|
51
51
|
|
52
|
-
when '
|
52
|
+
when 'ct-push'
|
53
53
|
force = extract_option('-f')
|
54
54
|
migrator.exp_push(ARGV[0] || 'all', force)
|
55
55
|
|
@@ -84,6 +84,9 @@ Commands:
|
|
84
84
|
new_locale - Copy your current main locale file to a new language, translating all keys.
|
85
85
|
version - Print version of locales.
|
86
86
|
|
87
|
+
ct-pull - Pull from CrowdTranslate
|
88
|
+
ct-push - Push to CrowdTranslate
|
89
|
+
|
87
90
|
i18n-migrations version #{I18n::Migrations::VERSION}
|
88
91
|
USAGE
|
89
92
|
end
|
data/i18n-migrations.gemspec
CHANGED
@@ -1,21 +1,38 @@
|
|
1
|
-
require '
|
1
|
+
require 'faraday'
|
2
2
|
|
3
3
|
module I18n
|
4
4
|
module Migrations
|
5
5
|
class CrowdTranslateClient
|
6
|
+
def initialize
|
7
|
+
token = ENV['CROWD_TRANSLATE_API_TOKEN']
|
8
|
+
raise("You must define CROWD_TRANSLATE_API_TOKEN in order to talk to Crowd Translate") unless token.present?
|
9
|
+
|
10
|
+
server = ENV['CROWD_TRANSLATE_SERVER'] || 'https://crowd-translate.herokuapp.com'
|
11
|
+
@faraday = Faraday.new(
|
12
|
+
url: "#{server}/api/v1",
|
13
|
+
headers: { 'X-CrowdTranslateApiToken' => token },
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
6
17
|
def sync_migrations(migrations)
|
7
18
|
local_versions = migrations.all_versions
|
8
|
-
remote_versions = JSON.parse(get('
|
19
|
+
remote_versions = JSON.parse(get('migrations.json'))
|
9
20
|
|
10
21
|
if (extra_versions = remote_versions - local_versions).present?
|
11
22
|
raise("You may not upload migrations to the server because it has migrations not found locally: " +
|
12
|
-
|
23
|
+
"#{extra_versions.join(', ')}")
|
13
24
|
end
|
14
25
|
|
15
26
|
if (versions_to_add = local_versions - remote_versions).present?
|
16
27
|
versions_to_add.each do |version|
|
17
|
-
|
18
|
-
|
28
|
+
begin
|
29
|
+
put("migrations/#{version}.json",
|
30
|
+
migration: { ruby_file: migrations.get_migration(version: version) })
|
31
|
+
rescue
|
32
|
+
puts "There was an error updating migration:".red
|
33
|
+
puts " #{migrations.migration_file(version: version)}".bold
|
34
|
+
raise
|
35
|
+
end
|
19
36
|
end
|
20
37
|
end
|
21
38
|
end
|
@@ -25,20 +42,32 @@ module I18n
|
|
25
42
|
end
|
26
43
|
|
27
44
|
def get_locale_file(locale_code)
|
28
|
-
get("
|
45
|
+
get("locales/#{locale_code}.yml")
|
29
46
|
end
|
30
47
|
|
31
48
|
private
|
32
49
|
|
33
|
-
def get(
|
34
|
-
|
35
|
-
|
50
|
+
def get(path)
|
51
|
+
puts "GET #{path}".bold
|
52
|
+
parse_response @faraday.get path
|
36
53
|
end
|
37
54
|
|
38
|
-
def put(
|
39
|
-
|
40
|
-
|
41
|
-
|
55
|
+
def put(path, params = {})
|
56
|
+
puts "PUT #{path} #{params}".bold
|
57
|
+
parse_response @faraday.put path, params
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse_response(response)
|
61
|
+
if response.success?
|
62
|
+
response.body
|
63
|
+
else
|
64
|
+
error = begin
|
65
|
+
JSON.parse(response.body)['error']
|
66
|
+
rescue
|
67
|
+
response.body
|
68
|
+
end
|
69
|
+
raise error
|
70
|
+
end
|
42
71
|
end
|
43
72
|
end
|
44
73
|
end
|
@@ -12,7 +12,11 @@ module I18n
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def get_migration(version:)
|
15
|
-
File.read(
|
15
|
+
File.read(migration_file(version: version))
|
16
|
+
end
|
17
|
+
|
18
|
+
def migration_file(version:)
|
19
|
+
File.join(@migration_dir, "#{version}.rb")
|
16
20
|
end
|
17
21
|
|
18
22
|
def play_migration(version:, locale:, data:, notes:, dictionary:, direction:)
|
@@ -11,7 +11,7 @@ require 'i18n/migrations/locale'
|
|
11
11
|
require 'i18n/migrations/migration_factory'
|
12
12
|
require 'i18n/migrations/crowd_translate_client'
|
13
13
|
|
14
|
-
CONCURRENT_THREADS =
|
14
|
+
CONCURRENT_THREADS = 3
|
15
15
|
|
16
16
|
# this class knows how to do all the things the cli needs done.
|
17
17
|
# it mostly delegates to locale to do it, often asking multiple locales to do the same thing
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Lightsmith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: faraday
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -106,7 +106,6 @@ files:
|
|
106
106
|
- ".gitignore"
|
107
107
|
- ".i18n-migrations.default.yml"
|
108
108
|
- ".rspec"
|
109
|
-
- ".ruby-gemset"
|
110
109
|
- ".ruby-version"
|
111
110
|
- ".travis.yml"
|
112
111
|
- CODE_OF_CONDUCT.md
|
@@ -152,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
151
|
- !ruby/object:Gem::Version
|
153
152
|
version: '0'
|
154
153
|
requirements: []
|
155
|
-
rubygems_version: 3.0.
|
154
|
+
rubygems_version: 3.0.6
|
156
155
|
signing_key:
|
157
156
|
specification_version: 4
|
158
157
|
summary: Migrations for doing i18n.
|