lokalise_rails 8.0.1 → 8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0e0ceba2e43e8a631a04292440c1513064b43555007dfb021dab3e913b94998
4
- data.tar.gz: '091cc4d46c83da828e0b793975dd7c9dc03e10e0816b5505f4e66b6e0dac3b6f'
3
+ metadata.gz: a3ff7f8491d3b827f087d10075343078f5bb084b7fb648fac8270b65af1c26f2
4
+ data.tar.gz: d0176a00387aea9c8e4fd3063f214f8a1e3fc5b33b5a026cae685931214ce99b
5
5
  SHA512:
6
- metadata.gz: '095af676b0d83e33331bfaf988cc60f84210247a059ad764ca55d1bef7643cc2ad7f14c9f01b50317d6765701011098c47943aed75a7d693b151a388129b25a7'
7
- data.tar.gz: 0423e6defc5d17c908f7a566c0d10a1fc3137110aee6b5604e5ad732fc6cbf2611909fd65ada8bb97cbad895529543301b4e3fba89170f16feaacdd991852870
6
+ metadata.gz: 16ba4b740fb69c45c4de23fc629618fe93a18de23d55b8b7658590c36372d21fe685999f0576fe5055b3f58e331f0493c2f703eb8a0ca5f5bf7613956ddfdd12
7
+ data.tar.gz: 5db3aa39c333e88496a6a48efe13d0792da290cb46676058fd012e9ad3cca8a054c20f171436a3124739ce81ce6a0a566a45f12e57a774ee38c2475fe5415956
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 8.1.0 (17-Apr-2025)
4
+
5
+ * Added `disable_export_task` boolean option. When enabled, the export task is turned off in your project to prevent from accidentally exporting keys to Lokalise and overwriting existing data. Defaults to `false`. Thanks, @aarisr!
6
+
3
7
  ## 8.0.1 (19-Feb-2025)
4
8
 
5
9
  * Minor code tweaks, use latest `lokalise_manager` that now enables asynchronous imports
data/README.md CHANGED
@@ -185,6 +185,9 @@ LokaliseRails::GlobalConfig.config do |c|
185
185
 
186
186
  ## Infer language ISO code for the translation file:
187
187
  ## c.lang_iso_inferer = ->(data, _path) { YAML.safe_load(data)&.keys&.first }
188
+
189
+ ## Disable the export rake task:
190
+ ## c.disable_export_task = false
188
191
  end
189
192
  ```
190
193
 
@@ -55,5 +55,8 @@ if defined?(LokaliseRails::GlobalConfig)
55
55
 
56
56
  ## Infer language ISO code for the translation file:
57
57
  ## c.lang_iso_inferer = ->(data, _path) { YAML.safe_load(data)&.keys&.first }
58
+
59
+ ## Disable the export rake task:
60
+ ## c.disable_export_task = false
58
61
  end
59
62
  end
@@ -5,6 +5,17 @@ module LokaliseRails
5
5
  # specific to the LokaliseRails gem in a Rails application.
6
6
  class GlobalConfig < LokaliseManager::GlobalConfig
7
7
  class << self
8
+ attr_writer :disable_export_task
9
+
10
+ # Returns whether the export task should be disabled.
11
+ #
12
+ # Defaults to `false` if not explicitly set.
13
+ #
14
+ # @return [Boolean] `true` if the export task is disabled, otherwise `false`.
15
+ def disable_export_task
16
+ @disable_export_task.nil? ? false : @disable_export_task
17
+ end
18
+
8
19
  # Returns the path to the directory where translation files are stored.
9
20
  #
10
21
  # Defaults to `config/locales` under the Rails application root if not explicitly set.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseRails
4
- VERSION = '8.0.1'
4
+ VERSION = '8.1.0'
5
5
  end
@@ -2,16 +2,13 @@
2
2
 
3
3
  require 'rake'
4
4
  require 'lokalise_rails'
5
- require "#{LokaliseRails::Utils.root}/config/lokalise_rails" # Loads configuration settings for LokaliseRails
5
+ require File.join(LokaliseRails::Utils.root, 'config', 'lokalise_rails')
6
6
 
7
7
  # Rake tasks for syncing translation files between a Rails project and Lokalise.
8
8
  namespace :lokalise_rails do
9
- # Imports translations from Lokalise into the current Rails project.
10
- #
11
- # Uses LokaliseManager to fetch translations based on the configuration
12
- # defined in `LokaliseRails::GlobalConfig`.
13
- #
14
- # @raise [StandardError] Prints an error message and aborts if the import fails.
9
+ ##########################################################################
10
+ # IMPORT
11
+ ##########################################################################
15
12
  desc 'Import translations from Lokalise into the Rails project'
16
13
  task :import do
17
14
  importer = LokaliseManager.importer({}, LokaliseRails::GlobalConfig)
@@ -20,14 +17,16 @@ namespace :lokalise_rails do
20
17
  abort "Import failed: #{e.message}"
21
18
  end
22
19
 
23
- # Exports translations from the Rails project to Lokalise.
24
- #
25
- # Uses LokaliseManager to push localization files based on the configuration
26
- # in `LokaliseRails::GlobalConfig`.
27
- #
28
- # @raise [StandardError] Prints an error message and aborts if the export fails.
20
+ ##########################################################################
21
+ # EXPORT
22
+ ##########################################################################
29
23
  desc 'Export translations from the Rails project to Lokalise'
30
24
  task :export do
25
+ if LokaliseRails::GlobalConfig.disable_export_task
26
+ $stdout.puts 'Export task is disabled.'
27
+ exit 0
28
+ end
29
+
31
30
  exporter = LokaliseManager.exporter({}, LokaliseRails::GlobalConfig)
32
31
  exporter.export!
33
32
  rescue StandardError => e
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lokalise_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.1
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Krukowski
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-19 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: lokalise_manager
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubygems_version: 3.6.3
85
+ rubygems_version: 3.6.8
86
86
  specification_version: 4
87
87
  summary: Lokalise integration for Ruby on Rails
88
88
  test_files: []