translation 1.16 → 1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/translation_io/client.rb +4 -0
- data/lib/translation_io/client/base_operation.rb +1 -1
- data/lib/translation_io/client/base_operation/save_special_yaml_files_step.rb +2 -1
- data/lib/translation_io/client/init_operation.rb +2 -1
- data/lib/translation_io/client/sync_operation.rb +10 -2
- data/lib/translation_io/tasks.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12113892c41a14c8d164e01d9d9c2339a92436f8
|
4
|
+
data.tar.gz: 403abefb4765377f59d145bb39fcfe477099cde3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c67cb77f2af77d56b26cfa9869196df3d62f478c3236a11cfdc5fa180d500c5795bbaab08a75920d5e88a1bd48c46a54d97e290dc48772b9ef1920d54582e7a6
|
7
|
+
data.tar.gz: 196ada47e46d5bebdb347b314ca02f3035018341b18d9d57fa4ef39943705588546b1c96173af53ab0f543e1eb7bdaac4b8b788733806f371c6dc768405db555
|
data/README.md
CHANGED
@@ -38,6 +38,7 @@ Table of contents
|
|
38
38
|
* [Change the current locale](#change-the-current-locale)
|
39
39
|
* [Globally](#globally)
|
40
40
|
* [Locally](#locally)
|
41
|
+
* [Continuous Integration](#continuous-integration)
|
41
42
|
* [Advanced Configuration Options](#advanced-configuration-options)
|
42
43
|
* [Disable GetText](#disable-gettext)
|
43
44
|
* [Ignored YAML keys](#ignored-yaml-keys)
|
@@ -262,6 +263,18 @@ You can call it several times in the same page if you want to switch between lan
|
|
262
263
|
|
263
264
|
More examples here: https://translation.io/blog/rails-i18n-with-locale
|
264
265
|
|
266
|
+
## Continuous Integration
|
267
|
+
|
268
|
+
If you want fresh translations in your Continuous Integration workflow, you may find yourself calling `bundle exec rake translation:sync` very frequently.
|
269
|
+
|
270
|
+
Since this task can't be concurrently executed (we have a [mutex](https://en.wikipedia.org/wiki/Mutual_exclusion) strategy with a queue but it returns an error under heavy load), we implemented this threadsafe readonly task:
|
271
|
+
|
272
|
+
```bash
|
273
|
+
$ bundle exec rake translation:sync_readonly
|
274
|
+
```
|
275
|
+
|
276
|
+
This task will prevent your CI to fail and still provide new translations. But be aware that it won't send new keys from your code to Translation.io so you still need to call `bundle exec rake translation:sync` at some point during development.
|
277
|
+
|
265
278
|
## Advanced Configuration Options
|
266
279
|
|
267
280
|
The `TranslationIO.configure` block in `config/initializers/translation.rb` can take several optional configuration options.
|
@@ -28,7 +28,7 @@ module TranslationIO
|
|
28
28
|
|
29
29
|
http = Net::HTTP.new(uri.host, uri.port)
|
30
30
|
http.use_ssl = uri.scheme == 'https'
|
31
|
-
http.read_timeout =
|
31
|
+
http.read_timeout = 20 * 60 # 20 minutes
|
32
32
|
|
33
33
|
request = Net::HTTP::Post.new(uri.request_uri)
|
34
34
|
request.set_form_data(params)
|
@@ -49,7 +49,8 @@ module TranslationIO
|
|
49
49
|
params["yaml_data_#{target_locale}"] = File.read(yaml_path)
|
50
50
|
end
|
51
51
|
|
52
|
-
TranslationIO.info "Collecting YAML localization entries"
|
52
|
+
TranslationIO.info "Collecting YAML localization entries from server."
|
53
|
+
|
53
54
|
uri = URI("#{TranslationIO.client.endpoint}/projects/#{TranslationIO.client.api_key}/fill_yaml_localizations")
|
54
55
|
parsed_response = BaseOperation.perform_request(uri, params)
|
55
56
|
|
@@ -35,7 +35,8 @@ module TranslationIO
|
|
35
35
|
warn_source_locale_unfound(source_locale, all_used_yaml_locales)
|
36
36
|
warn_target_locale_unfound(target_locales, all_used_yaml_locales)
|
37
37
|
|
38
|
-
TranslationIO.info "Sending data to server (
|
38
|
+
TranslationIO.info "Sending data to server (it may take some time, please be patient. Sync will be faster)."
|
39
|
+
|
39
40
|
uri = URI("#{client.endpoint}/projects/#{client.api_key}/init")
|
40
41
|
parsed_response = BaseOperation.perform_request(uri, params)
|
41
42
|
|
@@ -7,6 +7,7 @@ module TranslationIO
|
|
7
7
|
def run(options = {})
|
8
8
|
purge = options.fetch(:purge, false)
|
9
9
|
show_purgeable = options.fetch(:show_purgeable, false)
|
10
|
+
readonly = options.fetch(:readonly, false)
|
10
11
|
|
11
12
|
config = TranslationIO.config
|
12
13
|
|
@@ -35,6 +36,12 @@ module TranslationIO
|
|
35
36
|
params['purge'] = 'true'
|
36
37
|
end
|
37
38
|
|
39
|
+
if readonly
|
40
|
+
params['readonly'] = 'true'
|
41
|
+
end
|
42
|
+
|
43
|
+
TranslationIO.info "Sending data to server (it may take some time, please be patient)."
|
44
|
+
|
38
45
|
uri = URI("#{client.endpoint}/projects/#{client.api_key}/sync")
|
39
46
|
parsed_response = BaseOperation.perform_request(uri, params)
|
40
47
|
|
@@ -53,8 +60,9 @@ module TranslationIO
|
|
53
60
|
end
|
54
61
|
|
55
62
|
def display_unused_segments(parsed_response, show_purgeable, purge)
|
56
|
-
|
57
|
-
|
63
|
+
unused_segments = parsed_response['unused_segments'] || []
|
64
|
+
yaml_unused_segments = unused_segments.select { |unused_segment| unused_segment['kind'] == 'yaml' }
|
65
|
+
gettext_unused_segments = unused_segments.select { |unused_segment| unused_segment['kind'] == 'gettext' }
|
58
66
|
|
59
67
|
yaml_size = yaml_unused_segments.size
|
60
68
|
gettext_size = gettext_unused_segments.size
|
data/lib/translation_io/tasks.rb
CHANGED
@@ -38,6 +38,13 @@ namespace :translation do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
desc "Sync translations but only get translated segments without changing anything on Translation.io (it allows concurrent syncing for CI)."
|
42
|
+
task :sync_readonly => :environment do
|
43
|
+
if client_ready?
|
44
|
+
TranslationIO.client.sync_readonly
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
41
48
|
def client_ready?
|
42
49
|
if TranslationIO.client
|
43
50
|
true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: translation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.17'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Hoste
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gettext
|