i18n-migrations 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4d01adcb15a5984163cc175fbd044377722a00894ec47bddde58d809ceb6179
4
- data.tar.gz: 50b65ac56c6a5947c8f63a28f0c0b828002d1606cc8c018dcfd9ae911443b56f
3
+ metadata.gz: 21f147cba399eb84cceba91a2973b74727ab79860bb3abf0afb5ba9d6c711009
4
+ data.tar.gz: 3389c9810857757574618474ca4d1eed0e7d63c6b34d5bb3356a166e06faf32c
5
5
  SHA512:
6
- metadata.gz: edc8b29b0caba7fc2777b025e229bb9e01bee80ed6797ae4652053dc4dc82cc5d91486e9eb57c315f503a2cecc34c5332ba8e37a361c4e8efc3fd332c9de0664
7
- data.tar.gz: 832badb95a3490dc496caf1e3a938dd9335cc3279cd6e79a63291934d4f2ad5640890a3a1b41a71b5c9b7f4e17d61327f3b9d992782b350b6b7abc9ba1eba390
6
+ metadata.gz: e0ddd991774e877eb260f39772648ddbdfeacdf98015201c9df2fa010613bbbaa2e78af302dc946c682b49c8ddee8457d9a0d093a8d8a744a8b2e7c9f58e5c6c
7
+ data.tar.gz: 4eebcacbc1e59674eb3001fbc7e7e169b503cf0b1cd768420db045776aa34ba6664c1017bb42618a5443206cbd694b0a2a45cccf3b62cf4a7339c77098b35c3b
@@ -4,36 +4,44 @@ migration_dir: i18n/migrate
4
4
  # this is where your locale files will live (en.yml, es.yml, etc). it will be relative to your config file
5
5
  locales_dir: config/locales
6
6
 
7
- # choose either google_spreadsheets or crowd_translate as a backend
8
- backend: google_spreadsheets
9
-
10
- # number of threads to concurrently perform migration operations for locales (optional)
11
- # concurrency: 4
12
-
13
- # number of threads to concurrently perform push operation for locales (optional)
14
- # push_concurrency: 4
15
-
16
- # seconds to wait time between push operations per thread, can be used to avoid API throttling (optional)
17
- # wait_seconds: 0
18
-
19
7
  # this is the locale you will be translating from
20
8
  main_locale: en
21
9
 
22
- # put all other locales you want to use here, if they don't already exist, add them with i18n-migrations new-locale es
10
+ # put all other locales you want to use here, if they don't already exist, add them with i18n-migrations new_locale es
11
+ # each locale needs:
12
+ # name: Spanish
13
+ # # a spreadsheet that translators will use to do their work, these are the links to them
14
+ # google_spreadsheet: https://docs.google.com/spreadsheets/d/ID/edit
15
+ # # these are strings that should not show up in our translations. As in translations of proper nouns.
16
+ # do_not_translate:
17
+ # - Aula Transparente
18
+ # - clase transparente
23
19
  other_locales:
24
- - es
20
+ es:
21
+ name: Spanish
22
+ # google_spreadsheet: https://docs.google.com/spreadsheets/d/1SpxQWX3l4pwW9tyKhfo2VPemhn6olJYTPV0dudknpRE/edit
23
+ do_not_translate: # put things like your product name here along with any possible mistranslations
24
+ "I18n Migrations":
25
+ - I18n Migraciones
25
26
 
26
27
  # you need a service account key in order to access google spreadsheets. This is the path to it, relative to your config file
27
28
  google_service_account_key_path: i18n/google_drive_key.json
28
29
 
29
- # each locale will have a spreadsheet that translators will use to do their work, these are the links to them
30
- google_spreadsheets:
31
- es: https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit
30
+ # choose either google_spreadsheets or crowd_translate as a backend
31
+ backend: google_spreadsheets
32
+
33
+ # if you are using crowd translate, uncomment these lines and make sure they are correct
34
+ # crowd_translate_server_url: https://crowd-translate.herokuapp.com/c/X
35
+ # crowd_translate_api_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxx
32
36
 
33
37
  # this is your api key to use google translate
34
38
  google_translate_api_key: [INSERT_GOOGLE_TRANSLATE_API_KEY]
35
39
 
36
- # put things like your product name here along with any possible mistranslations
37
- do_not_translate:
38
- "I18n Migrations":
39
- - I18n Migraciones
40
+ # number of threads to concurrently perform migration operations for locales (optional)
41
+ # concurrency: 4
42
+
43
+ # number of threads to concurrently perform push operation for locales (optional)
44
+ # push_concurrency: 4
45
+
46
+ # seconds to wait time between push operations per thread, can be used to avoid API throttling (optional)
47
+ # wait_seconds: 0
@@ -6,8 +6,9 @@ module I18n
6
6
  class CrowdTranslateBackend
7
7
  attr_reader :client
8
8
 
9
- def initialize
10
- @client = CrowdTranslateClient.new
9
+ def initialize(config)
10
+ @client = CrowdTranslateClient.new(api_token: config.crowd_translate_api_token,
11
+ server_url: config.crowd_translate_server_url)
11
12
  end
12
13
 
13
14
  def pull(locale)
@@ -5,14 +5,10 @@ module I18n
5
5
  module Migrations
6
6
  module Backends
7
7
  class CrowdTranslateClient
8
- def initialize
9
- token = ENV['CROWD_TRANSLATE_API_TOKEN']
10
- raise("You must define CROWD_TRANSLATE_API_TOKEN in order to talk to Crowd Translate") unless token.present?
11
-
12
- server = ENV['CROWD_TRANSLATE_SERVER'] || 'https://crowd-translate.herokuapp.com'
8
+ def initialize(api_token:, server_url:)
13
9
  @faraday = Faraday.new(
14
- url: "#{server}/api/v1",
15
- headers: { 'X-CrowdTranslateApiToken' => token },
10
+ url: File.join(server_url, '/api/v1'),
11
+ headers: { 'X-CrowdTranslateApiToken' => api_token },
16
12
  )
17
13
  end
18
14
 
@@ -52,6 +52,14 @@ module I18n
52
52
  get_value([:other_locales, locale, :google_spreadsheet])
53
53
  end
54
54
 
55
+ def crowd_translate_api_token
56
+ get_value(:crowd_translate_api_token)
57
+ end
58
+
59
+ def crowd_translate_server_url
60
+ get_value(:crowd_translate_server_url)
61
+ end
62
+
55
63
  def do_not_translate(locale)
56
64
  return {} if locale.to_s == main_locale
57
65
 
@@ -141,7 +141,7 @@ end
141
141
 
142
142
  private def backend
143
143
  @backend ||= if config.crowd_translate?
144
- Backends::CrowdTranslateBackend.new
144
+ Backends::CrowdTranslateBackend.new(config)
145
145
  else
146
146
  Backends::GoogleSpreadsheetsBackend.new(config)
147
147
  end
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module Migrations
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
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.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Lightsmith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-10 00:00:00.000000000 Z
11
+ date: 2020-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler