lokalise_manager 4.0.0 → 5.1.0

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: e050488025db0f9c199092084e0b7925ffe56de86ea958f5647c073d396a1bc4
4
- data.tar.gz: a172734358df197f42c6c1f54c12de213bd5cb76537bb75167d69fca9ea81e90
3
+ metadata.gz: e651c10cfc08624f8bbfe88970210ed7a9e012e8637cc8cbb61aa4328942016b
4
+ data.tar.gz: f0dea631f1afba287ff49ff7336a1d74030347feafbafb848e8e5f445d466df9
5
5
  SHA512:
6
- metadata.gz: 73721527aed2b9fcfcdcf54c2475b6f9cc51307f82ab5c32a2736b6c909c48187d04c72ebfab1cd616293562a5c0bbbbc47dd41cd8e37d7eef83527c3452f86f
7
- data.tar.gz: f42762cc96263e83c84be880678914265eb43dcd595050fa63d17f7e72bdb566af27185874ff1b135964cb8ce33e6ba61be2d2e2d321137c99777ab2e33b5374
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
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Ilya Krukowski
3
+ Copyright (c) 2024 Ilya Krukowski
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  ![Gem](https://img.shields.io/gem/v/lokalise_manager)
4
4
  ![CI](https://github.com/bodrovis/lokalise_manager/actions/workflows/ci.yml/badge.svg)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/bodrovis/lokalise_manager/badge.svg?branch=master)](https://coveralls.io/github/bodrovis/lokalise_manager?branch=master)
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/9b682367a274ee3dcdee/maintainability)](https://codeclimate.com/github/bodrovis/lokalise_manager/maintainability)
6
7
  ![Downloads total](https://img.shields.io/gem/dt/lokalise_manager)
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 2.5+. 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
+ 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 RubyLokaliseApi::Error::TooManyRequests => e
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
@@ -19,7 +19,7 @@ module LokaliseManager
19
19
  return false
20
20
  end
21
21
 
22
- open_and_process_zip download_files['bundle_url']
22
+ open_and_process_zip download_files.bundle_url
23
23
 
24
24
  $stdout.print('Task complete!') unless config.silent_mode
25
25
  true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseManager
4
- VERSION = '4.0.0'
4
+ VERSION = '5.1.0'
5
5
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'zeitwerk'
4
4
  require 'yaml'
5
- require 'psych'
6
5
 
7
6
  loader = Zeitwerk::Loader.for_gem
8
7
  loader.setup
@@ -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 = '>= 2.7'
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', '~> 8.0'
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.0.0
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: 2023-07-21 00:00:00.000000000 Z
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: '8.0'
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: '8.0'
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: '2.7'
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.4.17
241
+ rubygems_version: 3.5.6
242
242
  signing_key:
243
243
  specification_version: 4
244
244
  summary: Lokalise integration for Ruby