lokalise_manager 4.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/LICENSE +1 -1
- data/README.md +3 -2
- data/lib/lokalise_manager/global_config.rb +3 -1
- data/lib/lokalise_manager/task_definitions/base.rb +6 -1
- data/lib/lokalise_manager/task_definitions/exporter.rb +1 -1
- data/lib/lokalise_manager/task_definitions/importer.rb +1 -1
- data/lib/lokalise_manager/version.rb +1 -1
- data/lib/lokalise_manager.rb +0 -1
- data/lokalise_manager.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e651c10cfc08624f8bbfe88970210ed7a9e012e8637cc8cbb61aa4328942016b
|
4
|
+
data.tar.gz: f0dea631f1afba287ff49ff7336a1d74030347feafbafb848e8e5f445d466df9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4792e56612597b654536c72b0c29550b15c9e3666da1422208d613e546cb2870b9749a7150111e40296bd5e2550ca9eacedc55715b0c28292eb1cff45eddf9c
|
7
|
+
data.tar.gz: 59cfbc87f48a4293fa064946d638b27510211d05bdd8dd5b9c4c63716455b55cdec851da5b2f35b4a4941d153639874bf87e2e34040cc433fe6a46ce978bc0c8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 5.1.0 (09-Feb-2024)
|
4
|
+
|
5
|
+
* Handle rare case when the server returns HTML instead of JSON which happens when too many requests are sent
|
6
|
+
|
7
|
+
## 5.0.0 (09-Nov-2023)
|
8
|
+
|
9
|
+
* **Breaking change**: require Ruby 3+. Version 2.7 has reached end-of-life and thus we are not planning to support it anymore. If you need support for Ruby 2.7, please stay on 4.0.0.
|
10
|
+
* **Potential breaking change**: lambda returned by the `lang_iso_inferer` method has been slightly enhanced. It now accepts not only the file data but also the full path to the file. Therefore, if you redefine the `lang_iso_inferer` option please make sure that the returned lambda accepts two params, not one. This way, you can be more flexible when inferring the locale. For example:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
lang_iso_inferer: ->(_data, path) { path.basename('.yml').to_s }
|
14
|
+
```
|
15
|
+
|
16
|
+
* Use ruby-lokalise-api v9.0.0
|
17
|
+
|
3
18
|
## 4.0.0 (27-Jul-2023)
|
4
19
|
|
5
20
|
* **Use ruby-lokalise-api version 8**. It should not introduce any breaking changes (as main methods have similar signatures) but you should be aware that v8 is a complete rewrite of the original SDK so please make sure your tests pass.
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|

|
4
4
|

|
5
5
|
[](https://coveralls.io/github/bodrovis/lokalise_manager?branch=master)
|
6
|
+
[](https://codeclimate.com/github/bodrovis/lokalise_manager/maintainability)
|
6
7
|

|
7
8
|
|
8
9
|
This gem provides [Lokalise](http://lokalise.com) integration for Ruby and allows to exchange translation files between your project and TMS easily. It relies on [ruby-lokalise-api](https://lokalise.github.io/ruby-lokalise-api) to send APIv2 requests.
|
@@ -13,7 +14,7 @@ If you are looking for a Rails integration, please check [lokalise_rails](https:
|
|
13
14
|
|
14
15
|
### Requirements
|
15
16
|
|
16
|
-
This gem requires Ruby
|
17
|
+
This gem requires Ruby 3.0+. You will also need to [setup a Lokalise account](https://app.lokalise.com/signup) and create a [translation project](https://docs.lokalise.com/en/articles/1400460-projects). Finally, you will need to generate a [read/write API token](https://docs.lokalise.com/en/articles/1929556-api-tokens) at your Lokalise profile.
|
17
18
|
|
18
19
|
Alternatively, you can utilize a token obtained via OAuth 2 flow. When using such a token, you'll have to set `:use_oauth2_token` option to `true` (see below).
|
19
20
|
|
@@ -202,7 +203,7 @@ If your translation files are not in YAML format, you will need to adjust the fo
|
|
202
203
|
* `file_ext_regexp` (`regexp`) — regular expression applied to file extensions to determine which files should be imported and exported. Defaults to `/\.ya?ml\z/i` (YAML files).
|
203
204
|
* `translations_loader` (`lambda` or `proc`) — loads translations data and makes sure they are valid before saving them to a translation file. Defaults to `->(raw_data) { YAML.safe_load raw_data }`. In the simplest case you may just return the data back, for example `-> (raw_data) { raw_data }`.
|
204
205
|
* `translations_converter` (`lambda` or `proc`) — converts translations data to a proper format before saving them to a translation file. Defaults to `->(raw_data) { YAML.dump(raw_data).gsub(/\\\\n/, '\n') }`. In the simplest case you may just return the data back, for example `-> (raw_data) { raw_data }`.
|
205
|
-
* `lang_iso_inferer` (`lambda` or `proc`) — infers language ISO code based on the translation file data before uploading it to Lokalise. Defaults to `->(data) { YAML.safe_load(data)&.keys&.first }`.
|
206
|
+
* `lang_iso_inferer` (`lambda` or `proc`) — infers language ISO code based on the translation file data and path before uploading it to Lokalise. Defaults to `->(data, _path) { YAML.safe_load(data)&.keys&.first }`. To infer locale based on the filename, you can use something like `->(_data, path) { path.basename('.yml').to_s }`. `path` is an instance of the `Pathname` class.
|
206
207
|
|
207
208
|
### Customizing JSON parser and network adapter
|
208
209
|
|
@@ -99,8 +99,10 @@ module LokaliseManager
|
|
99
99
|
end
|
100
100
|
|
101
101
|
# Infers lang ISO for the given translation file
|
102
|
+
# The lambda expects to accept the raw contents of the translation file
|
103
|
+
# and the full path to the file (instance of the `Pathname` class)
|
102
104
|
def lang_iso_inferer
|
103
|
-
@lang_iso_inferer || ->(data) { YAML.safe_load(data)&.keys&.first }
|
105
|
+
@lang_iso_inferer || ->(data, _path) { YAML.safe_load(data)&.keys&.first }
|
104
106
|
end
|
105
107
|
end
|
106
108
|
end
|
@@ -88,6 +88,11 @@ module LokaliseManager
|
|
88
88
|
"#{config.project_id}:#{config.branch}"
|
89
89
|
end
|
90
90
|
|
91
|
+
# In rare cases the server might return HTML instead of JSON.
|
92
|
+
# It happens when too many requests are being sent.
|
93
|
+
# Until this is fixed, we revert to this quick'n'dirty solution.
|
94
|
+
EXCEPTIONS = [JSON::ParserError, RubyLokaliseApi::Error::TooManyRequests].freeze
|
95
|
+
|
91
96
|
# Sends request with exponential backoff mechanism
|
92
97
|
def with_exp_backoff(max_retries)
|
93
98
|
return unless block_given?
|
@@ -95,7 +100,7 @@ module LokaliseManager
|
|
95
100
|
retries = 0
|
96
101
|
begin
|
97
102
|
yield
|
98
|
-
rescue
|
103
|
+
rescue *EXCEPTIONS => e
|
99
104
|
raise(e.class, "Gave up after #{retries} retries") if retries >= max_retries
|
100
105
|
|
101
106
|
sleep 2**retries
|
@@ -84,7 +84,7 @@ module LokaliseManager
|
|
84
84
|
initial_opts = {
|
85
85
|
data: Base64.strict_encode64(content.strip),
|
86
86
|
filename: relative_p,
|
87
|
-
lang_iso: config.lang_iso_inferer.call(content)
|
87
|
+
lang_iso: config.lang_iso_inferer.call(content, full_p)
|
88
88
|
}
|
89
89
|
|
90
90
|
initial_opts.merge config.export_opts
|
data/lib/lokalise_manager.rb
CHANGED
data/lokalise_manager.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = 'https://github.com/bodrovis/lokalise_manager'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
spec.platform = Gem::Platform::RUBY
|
16
|
-
spec.required_ruby_version = '>=
|
16
|
+
spec.required_ruby_version = '>= 3.0'
|
17
17
|
|
18
18
|
spec.files = Dir['README.md', 'LICENSE',
|
19
19
|
'CHANGELOG.md', 'lib/**/*.rb',
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.extra_rdoc_files = ['README.md']
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
|
-
spec.add_dependency 'ruby-lokalise-api', '~>
|
26
|
+
spec.add_dependency 'ruby-lokalise-api', '~> 9.0'
|
27
27
|
spec.add_dependency 'rubyzip', '~> 2.3'
|
28
28
|
spec.add_dependency 'zeitwerk', '~> 2.4'
|
29
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lokalise_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Krukowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-lokalise-api
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '9.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '9.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubyzip
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -231,14 +231,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
231
231
|
requirements:
|
232
232
|
- - ">="
|
233
233
|
- !ruby/object:Gem::Version
|
234
|
-
version: '
|
234
|
+
version: '3.0'
|
235
235
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
236
236
|
requirements:
|
237
237
|
- - ">="
|
238
238
|
- !ruby/object:Gem::Version
|
239
239
|
version: '0'
|
240
240
|
requirements: []
|
241
|
-
rubygems_version: 3.
|
241
|
+
rubygems_version: 3.5.6
|
242
242
|
signing_key:
|
243
243
|
specification_version: 4
|
244
244
|
summary: Lokalise integration for Ruby
|