lokalise_rails 9.1.0 → 10.0.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: 10aca9c56566ddf94f027c08089f95fb779b1a939858d7b70d4824bd41559c1c
4
- data.tar.gz: 69f38ae41196a487926e269b4d8f48a409c0ff282055fecb95ddb53736941890
3
+ metadata.gz: 42a36a8f1a48885107ab483355a20b5165bf5560bda87469718d4f868e419b9b
4
+ data.tar.gz: ea273319e86b45f3dd8d00e72695e55724f6ec3864915f8b031c928b02fc2b48
5
5
  SHA512:
6
- metadata.gz: 39cc268525d31a84a0fa8b9b924964a2913bf0dd320cb63f26eec80265f6a645139352e5bd3bf9a2e159cd8c0a4cad2beb61306b22817eade5158489e0587f25
7
- data.tar.gz: cb3c6a2323b358ae5e6c887caf686e4b8adcfd028fdedc38aa5dfdfe27540a996691aee36c7a52a96c659c536f6045aacf6dcd920b337a86c49fd190ff6f1956
6
+ metadata.gz: f75b0fe35c4721f6a5dacc2e7cdb2c18f49058b741369933629a60875b9ee374c49a16bdb57dd01fe3798ddc47eedca7de6d2a4fea4a4be1dc42f8021a4b2e92
7
+ data.tar.gz: 79cfffd769d35dec7e53b96eec3ceffad46fc93cedca58ff348705477901e7a7d50fb816af75cbca4bd575229bb623b754672290c1332fefe05d3e764b981c86
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 10.0.0 (31-Aug-2026)
4
+
5
+ * **Require Ruby 3.2+**
6
+ * Various code updates and enhancements
7
+
3
8
  ## 9.1.0 (22-Feb-2026)
4
9
 
5
10
  - Added `LokaliseRails::GlobalConfig.for_default_project` to define per-run overrides for the default project (without changing global settings), and updated rake tasks to use `project_opts(:default)`.
data/README.md CHANGED
@@ -14,7 +14,7 @@ This gem provides [Lokalise](http://lokalise.com) integration for Ruby on Rails
14
14
 
15
15
  ### Requirements
16
16
 
17
- This gem requires Ruby 3.0+ and Rails 5.1+. It might work with older versions of Rails though. You will also need to [set up 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 (or a read-only token if you plan to perform only imports).
17
+ This gem requires Ruby 3.2+ and Rails 5.1+. It might work with older versions of Rails though. You will also need to [set up 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 (or a read-only token if you plan to perform only imports).
18
18
 
19
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` (please check [options docs](https://github.com/bodrovis/lokalise_manager#common-config) to learn more).
20
20
 
@@ -69,6 +69,76 @@ To export translations from your Rails app to the specified Lokalise project, ru
69
69
  rails lokalise_rails:export
70
70
  ```
71
71
 
72
+ ## Configuration
73
+
74
+ Options are specified in the `config/lokalise_rails.rb` file.
75
+
76
+ Here's an example:
77
+
78
+ ```ruby
79
+ LokaliseRails::GlobalConfig.config do |c|
80
+ # These are mandatory options that you must set before running rake tasks:
81
+ c.api_token = ENV['LOKALISE_API_TOKEN']
82
+ c.project_id = ENV['LOKALISE_PROJECT_ID']
83
+
84
+ # Provide a custom path to the directory with your translation files:
85
+ # c.locales_path = "#{Rails.root}/config/locales"
86
+
87
+ # Provide a Lokalise project branch to use:
88
+ c.branch = 'develop'
89
+
90
+ # Provide request timeouts for the Lokalise API client:
91
+ c.additional_client_opts = {open_timeout: 5, timeout: 5}
92
+
93
+ # Provide maximum number of retries for file exporting:
94
+ c.max_retries_export = 5
95
+
96
+ # Provide maximum number of retries for file importing:
97
+ c.max_retries_import = 5
98
+
99
+ # Import options have the following defaults:
100
+ # c.import_opts = {
101
+ # format: 'ruby_yaml',
102
+ # placeholder_format: :icu,
103
+ # yaml_include_root: true,
104
+ # original_filenames: true,
105
+ # directory_prefix: '',
106
+ # indentation: '2sp'
107
+ # }
108
+
109
+ # Safe mode for imports is disabled by default:
110
+ # c.import_safe_mode = false
111
+
112
+ # Additional export options (only filename, contents, and lang_iso params are provided by default)
113
+ # c.export_opts = {}
114
+
115
+ # Provide additional file exclusion criteria for exports (by default, any file with the proper extension will be exported)
116
+ # c.skip_file_export = ->(file) { file.split[1].to_s.include?('fr') }
117
+
118
+ # Set the options below if you would like to work with format other than YAML
119
+ ## Regular expression to use when choosing the files to extract from the downloaded archive and upload to Lokalise
120
+ ## c.file_ext_regexp = /\.ya?ml\z/i
121
+
122
+ ## Load translations data and make sure they are valid:
123
+ ## c.translations_loader = ->(raw_data) { YAML.safe_load raw_data }
124
+
125
+ ## Convert translations data to a proper format:
126
+ ## c.translations_converter = ->(raw_data) { YAML.dump(raw_data).gsub(/\\\\n/, '\n') }
127
+
128
+ ## Infer language ISO code for the translation file:
129
+ ## c.lang_iso_inferer = ->(data, _path) { YAML.safe_load(data)&.keys&.first }
130
+
131
+ ## Pre-process translations before exporting to Lokalise:
132
+ ## c.export_preprocessor = ->(raw_data, _path) { raw_data }
133
+
134
+ ## Disable the export rake task:
135
+ ## c.disable_export_task = false
136
+
137
+ ## Disable the import rake task:
138
+ ## c.disable_import_task = false
139
+ end
140
+ ```
141
+
72
142
  ## Running tasks programmatically
73
143
 
74
144
  You can also run the import and export tasks programmatically from your code. To achieve that, please check the [`lokalise_manager`](https://github.com/bodrovis/lokalise_manager) gem which `lokalise_rails` relies on.
@@ -217,76 +287,6 @@ end
217
287
 
218
288
  Named projects are configured with `for_project(:name)` and generate scoped tasks like `lokalise_rails:<name>:import` and `lokalise_rails:<name>:export`.
219
289
 
220
- ## Configuration
221
-
222
- Options are specified in the `config/lokalise_rails.rb` file.
223
-
224
- Here's an example:
225
-
226
- ```ruby
227
- LokaliseRails::GlobalConfig.config do |c|
228
- # These are mandatory options that you must set before running rake tasks:
229
- c.api_token = ENV['LOKALISE_API_TOKEN']
230
- c.project_id = ENV['LOKALISE_PROJECT_ID']
231
-
232
- # Provide a custom path to the directory with your translation files:
233
- # c.locales_path = "#{Rails.root}/config/locales"
234
-
235
- # Provide a Lokalise project branch to use:
236
- c.branch = 'develop'
237
-
238
- # Provide request timeouts for the Lokalise API client:
239
- c.additional_client_opts = {open_timeout: 5, timeout: 5}
240
-
241
- # Provide maximum number of retries for file exporting:
242
- c.max_retries_export = 5
243
-
244
- # Provide maximum number of retries for file importing:
245
- c.max_retries_import = 5
246
-
247
- # Import options have the following defaults:
248
- # c.import_opts = {
249
- # format: 'ruby_yaml',
250
- # placeholder_format: :icu,
251
- # yaml_include_root: true,
252
- # original_filenames: true,
253
- # directory_prefix: '',
254
- # indentation: '2sp'
255
- # }
256
-
257
- # Safe mode for imports is disabled by default:
258
- # c.import_safe_mode = false
259
-
260
- # Additional export options (only filename, contents, and lang_iso params are provided by default)
261
- # c.export_opts = {}
262
-
263
- # Provide additional file exclusion criteria for exports (by default, any file with the proper extension will be exported)
264
- # c.skip_file_export = ->(file) { file.split[1].to_s.include?('fr') }
265
-
266
- # Set the options below if you would like to work with format other than YAML
267
- ## Regular expression to use when choosing the files to extract from the downloaded archive and upload to Lokalise
268
- ## c.file_ext_regexp = /\.ya?ml\z/i
269
-
270
- ## Load translations data and make sure they are valid:
271
- ## c.translations_loader = ->(raw_data) { YAML.safe_load raw_data }
272
-
273
- ## Convert translations data to a proper format:
274
- ## c.translations_converter = ->(raw_data) { YAML.dump(raw_data).gsub(/\\\\n/, '\n') }
275
-
276
- ## Infer language ISO code for the translation file:
277
- ## c.lang_iso_inferer = ->(data, _path) { YAML.safe_load(data)&.keys&.first }
278
-
279
- ## Pre-process translations before exporting to Lokalise:
280
- ## c.export_preprocessor = ->(raw_data, _path) { raw_data }
281
-
282
- ## Disable the export rake task:
283
- ## c.disable_export_task = false
284
-
285
- ## Disable the import rake task:
286
- ## c.disable_import_task = false
287
- end
288
- ```
289
-
290
290
  ## Running tests
291
291
 
292
292
  1. Copy-paste `.env.example` file as `.env`. Put your Lokalise API token and project ID inside. The `.env` file is excluded from version control so your data is safe. All in all, we use stubbed requests, so the actual API requests won't be sent. However, providing at least some values is required.
@@ -37,7 +37,7 @@ if defined?(LokaliseRails::GlobalConfig)
37
37
  # Run imports asynchronously
38
38
  # c.import_async = false
39
39
 
40
- # Additional export options (only filename, contents, and lang_iso params are provided by default)
40
+ # Additional export options (only data, filename, and lang_iso params are provided by default)
41
41
  # c.export_opts = {}
42
42
 
43
43
  # Provide additional file exclusion criteria for exports:
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
-
5
3
  module LokaliseRails
6
4
  # Extends `LokaliseManager::GlobalConfig` to provide a global configuration
7
5
  # specific to the LokaliseRails gem in a Rails application.
@@ -19,16 +19,24 @@ module LokaliseRails
19
19
  # Returns the root directory of a Rails application, if present.
20
20
  #
21
21
  # - Uses `Rails.root` when Rails is loaded.
22
- # - Falls back to `RAILS_ROOT` for legacy Rails versions.
23
22
  # - Returns `nil` when Rails is not available.
24
23
  #
25
24
  # @return [Pathname, nil] Pathname pointing to the Rails root, or `nil`.
26
25
  def rails_root
27
- if defined?(::Rails) && ::Rails.respond_to?(:root) && (r = ::Rails.root)
28
- Pathname(r)
29
- elsif defined?(::RAILS_ROOT)
30
- Pathname(::RAILS_ROOT)
26
+ ::Rails.root if defined?(::Rails) && ::Rails.respond_to?(:root)
27
+ end
28
+
29
+ def require_config!
30
+ config_path = root.join('config', 'lokalise_rails.rb')
31
+
32
+ unless config_path.exist?
33
+ abort <<~MSG
34
+ LokaliseRails configuration file was not found at #{config_path}.
35
+ Run `rails generate lokalise_rails:install` first.
36
+ MSG
31
37
  end
38
+
39
+ require config_path.to_s
32
40
  end
33
41
  end
34
42
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseRails
4
- VERSION = '9.1.0'
4
+ VERSION = '10.0.0'
5
5
  end
@@ -7,7 +7,7 @@ require 'lokalise_manager'
7
7
  loader = Zeitwerk::Loader.for_gem
8
8
 
9
9
  # Ignore files that should not be autoloaded.
10
- loader.ignore "#{__dir__}/lokalise_rails/railtie.rb" # Exclude Railtie when not in a Rails app
10
+ loader.ignore "#{__dir__}/lokalise_rails/railtie.rb" # Load Railtie manually only in Rails applications.
11
11
  loader.ignore "#{__dir__}/generators" # Exclude generators
12
12
 
13
13
  loader.setup
@@ -3,7 +3,7 @@
3
3
  require 'rake'
4
4
  require 'lokalise_rails'
5
5
 
6
- require LokaliseRails::Utils.root.join('config', 'lokalise_rails.rb').to_s
6
+ LokaliseRails::Utils.require_config!
7
7
 
8
8
  # Rake tasks for syncing translation files between a Rails project and Lokalise.
9
9
  namespace :lokalise_rails do
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.homepage = 'https://github.com/bodrovis/lokalise_rails'
13
13
  spec.license = 'MIT'
14
14
  spec.platform = Gem::Platform::RUBY
15
- spec.required_ruby_version = '>= 3.0'
15
+ spec.required_ruby_version = '>= 3.2'
16
16
 
17
17
  spec.files = Dir['README.md', 'LICENSE.md',
18
18
  'CHANGELOG.md', 'lib/**/*.rb',
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.extra_rdoc_files = ['README.md']
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_dependency 'lokalise_manager', '~> 7.0'
24
+ spec.add_dependency 'lokalise_manager', '~> 8.0'
25
25
  spec.add_dependency 'zeitwerk', '~> 2.4'
26
26
 
27
27
  spec.add_development_dependency 'rake', '~> 13.0'
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'rubocop-performance', '~> 1.5'
31
31
  spec.add_development_dependency 'rubocop-rake', '~> 0.7'
32
32
  spec.add_development_dependency 'rubocop-rspec', '~> 3.0'
33
- spec.add_development_dependency 'simplecov', '~> 0.22'
33
+ spec.add_development_dependency 'simplecov', '~> 1.0'
34
34
 
35
35
  spec.metadata = {
36
36
  'rubygems_mfa_required' => 'true',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lokalise_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.1.0
4
+ version: 10.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Krukowski
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: '7.0'
18
+ version: '8.0'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: '7.0'
25
+ version: '8.0'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: zeitwerk
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -127,14 +127,14 @@ dependencies:
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: '0.22'
130
+ version: '1.0'
131
131
  type: :development
132
132
  prerelease: false
133
133
  version_requirements: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: '0.22'
137
+ version: '1.0'
138
138
  description: This gem allows to exchange translation files between your Rails app
139
139
  and Lokalise TMS.
140
140
  email:
@@ -172,14 +172,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
172
  requirements:
173
173
  - - ">="
174
174
  - !ruby/object:Gem::Version
175
- version: '3.0'
175
+ version: '3.2'
176
176
  required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  requirements: []
182
- rubygems_version: 4.0.6
182
+ rubygems_version: 4.0.19
183
183
  specification_version: 4
184
184
  summary: Lokalise integration for Ruby on Rails
185
185
  test_files: []