lokalise_manager 6.3.0 → 6.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08b1f69944b78b0bd4e7d0af79d13577856ed3c1a1dd63c72ee518621bf04d2d'
4
- data.tar.gz: 111eee6b8ac91ab7e0ae0427fb4d67f5f484269bf5814b1dcf34c6891dd35c74
3
+ metadata.gz: e3d449c0a476650e30e126c7b468b8265e8afc17819ea4223a7a1a2a2228e70c
4
+ data.tar.gz: d5a4eb4621151d3003c6df65b4c404929cff3512964bff3a0628594b568fc68a
5
5
  SHA512:
6
- metadata.gz: c925831cc2c72996ade697c7a4e273cb21859e2198f87515cabe9285b659336621ff3013b082db7fdda6a8bddf47bb1cb49b30c159f474c7565b8c4aa467ea5d
7
- data.tar.gz: 8bbe2658653393a54c70a27c0bf371950eb0555507e6392316a59b343ee28ce11424a78729c601176a6dee2c0cfb4d3f5b327216eb267ffc0cd754b8b508dab2
6
+ metadata.gz: 88fa1d12483670f848b83e3391304ec4f0186ca6fd75b67cd6c9a52de6182cd579701fa69434ae60bb5587e6cfd80c39507346468a5ee4b66c2efb9064804098
7
+ data.tar.gz: 860a18bfc113b64899d5f4acc1ca94435093cd66a07a0dffa40073009085d176f6a196c0e2267d3bda0dd9e3dc5b3085115f0bbf66506dcf1994a8c040b7394a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.4.0 (04-Jul-2025)
4
+
5
+ * Added a new export option `export_filename_generator` (`lambda` or `proc`) that allows to control the `filename` sent to Lokalise for each uploaded file. The lambda takes two arguments: full file path and relative path (both `Pathname` instances). The relative path is calculated based on your `locales_path` setting — it shows the file's location inside your locales folder. The lambda must return a string or `Pathname` (or anything convertible to string) with the desired filename. By default, the relative path is used as the filename.
6
+
7
+ ```ruby
8
+ c.export_filename_generator = ->(_full_path, relative_path) { relative_path.to_s.upcase }
9
+ ```
10
+
3
11
  ## 6.3.0 (19-Jun-2025)
4
12
 
5
13
  * Added a new export option `export_preprocessor` (`lambda` or `proc`) that enables you to specify additional processing logic for your translation files' content before uploading to Lokalise. This option defaults to `->(raw_data, _path) { raw_data }` (no processing).
data/README.md CHANGED
@@ -184,6 +184,12 @@ c.skip_file_export = ->(file) { f.split[1].to_s.include?('fr') }
184
184
  c.export_preprocessor = ->(raw_data, _path) { raw_data.upcase }
185
185
  ```
186
186
 
187
+ * `export_filename_generator` (`lambda` or `proc`) — allows you to control the `filename` sent to Lokalise for each uploaded file. The lambda takes two arguments: full file path and relative path (both `Pathname` instances). The relative path is calculated based on your `locales_path` setting — it shows the file's location inside your locales folder. The lambda must return a string or `Pathname` (or anything convertible to string) with the desired filename. By default, the relative path is used as the filename.
188
+
189
+ ```ruby
190
+ c.export_filename_generator = ->(_full_path, relative_path) { relative_path.to_s.upcase }
191
+ ```
192
+
187
193
  * `max_retries_export` (`integer`) — this option is introduced to properly handle Lokalise API rate limiting. If the HTTP status code 429 (too many requests) has been received, LokaliseManager will apply an exponential backoff mechanism with a very simple formula: `2 ** retries` (initially `retries` is `0`). If the maximum number of retries has been reached, a `RubyLokaliseApi::Error::TooManyRequests` exception will be raised and the export operation will be halted. By default, LokaliseManager will make up to `5` retries which potentially means `1 + 2 + 4 + 8 + 16 + 32 = 63` seconds of waiting time. If the `max_retries_export` is less than `1`, LokaliseManager will not perform any retries and give up immediately after receiving error 429.
188
194
  * `raise_on_export_fail` (`boolean`) — default is `true`. When this option is enabled, LokaliseManager will re-raise any exceptions that happened during the file uploading. In other words, if any uploading thread raised an exception, your exporting process will exit with an exception. Suppose, you are uploading 12 translation files; these files will be split in 2 groups with 6 files each, and each group will be uploaded in parallel (using threads). However, suppose some exception happens when uploading the first group. By default this exception will be re-raised for the whole process and the script will never try to upload the second group. If you would like to continue uploading even if an exception happened, set the `raise_on_export_fail` to `false`. In this case the `export!` method will return an array with scheduled processes and with information about processes that were not successfully scheduled. This information is represented as an object with three methods: `path` (contains an instance of the `Pathname` class which says which file could not be uploaded), `error` (the actual exception), and `success` (returns `false`). So, you can use the following snippet to check your processes:
189
195
 
@@ -10,7 +10,7 @@ module LokaliseManager
10
10
  :file_ext_regexp, :skip_file_export, :branch, :additional_client_opts,
11
11
  :translations_loader, :translations_converter, :lang_iso_inferer,
12
12
  :max_retries_export, :max_retries_import, :use_oauth2_token, :silent_mode,
13
- :raise_on_export_fail, :import_async, :export_preprocessor
13
+ :raise_on_export_fail, :import_async, :export_preprocessor, :export_filename_generator
14
14
 
15
15
  # Yield self to block for configuration
16
16
  def config
@@ -115,6 +115,10 @@ module LokaliseManager
115
115
  def export_preprocessor
116
116
  @export_preprocessor || ->(raw_data, _path) { raw_data }
117
117
  end
118
+
119
+ def export_filename_generator
120
+ @export_filename_generator || ->(_full_path, relative_path) { relative_path }
121
+ end
118
122
  end
119
123
  end
120
124
  end
@@ -95,16 +95,16 @@ module LokaliseManager
95
95
  #
96
96
  # Reads and encodes the file content in Base64 before sending it to Lokalise.
97
97
  #
98
- # @param full_p [Pathname] Full file path.
99
- # @param relative_p [Pathname] Relative path within the project.
98
+ # @param full_path [Pathname] Full file path.
99
+ # @param relative_path [Pathname] Relative path within the project.
100
100
  # @return [Hash] Upload options including encoded content, filename, and language.
101
- def opts(full_p, relative_p)
102
- content = File.read(full_p).strip
101
+ def opts(full_path, relative_path)
102
+ content = File.read(full_path).strip
103
103
 
104
104
  {
105
- data: Base64.strict_encode64(config.export_preprocessor.call(content, full_p)),
106
- filename: relative_p.to_s,
107
- lang_iso: config.lang_iso_inferer.call(content, full_p)
105
+ data: Base64.strict_encode64(config.export_preprocessor.call(content, full_path)),
106
+ filename: config.export_filename_generator.call(full_path, relative_path).to_s,
107
+ lang_iso: config.lang_iso_inferer.call(content, full_path)
108
108
  }.merge(config.export_opts)
109
109
  end
110
110
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseManager
4
- VERSION = '6.3.0'
4
+ VERSION = '6.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lokalise_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.0
4
+ version: 6.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Krukowski