rails_i18n_manager 1.1.0 → 1.1.1

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: f728ba9cda5d596101c9da0d9e5336ca468d9db8b9c7c15d1bd621db9e065fc9
4
- data.tar.gz: 800e36c720bf9a2a2c18b9f2e286507b463cda8dbecdb3a7b67237c2faea20a7
3
+ metadata.gz: 42c0b085e7edbb9d009e8bccba78e937350e914d44b6d571fbfa9dab4949f23f
4
+ data.tar.gz: cf189df04c6de14d7796a34a9da4328d290066a81e7992048703df65d2c71c8a
5
5
  SHA512:
6
- metadata.gz: 9c5fa427b474d3e313adc680decffb40f9b403e6a1cd9fa362d6c698b17170842b57d44650d0a0c19fd6f41d179f232880a16911d01f56c0e98f61ad7543daf2
7
- data.tar.gz: 3cd51e42ac3cec4465cf10b3a7de4c52cca60268bccc70485a8b9ae7a1087f764e3dfe13abfdade0cbe758a12a5b7ea0cad6edcc90a48348e37e11cd512afda9
6
+ metadata.gz: 7318df372d6f81bfd1a53592a5ebf5e3d390233c9834fcb6aa72529922c79052c9f64ecd623dfc2ee437a1e4ee45d20d60d43410a8594574f153848ecbbd5ea4
7
+ data.tar.gz: eb177a2ceddceb4f928d33e4119490ce8a8a61f8112e1453f80263ddf8395ce925d990e56998e513da5e78b32b90e22d11e430132d9f0a4a6b2a960288da8b23
@@ -102,10 +102,16 @@ module RailsI18nManager
102
102
  render
103
103
  else
104
104
  if @form.valid?
105
+ if @form.file.path.end_with?(".json")
106
+ parsed_file_contents = JSON.parse(@form.file.read)
107
+ else
108
+ parsed_file_contents = YAML.safe_load(@form.file.read)
109
+ end
110
+
105
111
  begin
106
112
  TranslationsImportJob.new.perform(
107
113
  translation_app_id: @form.translation_app_id,
108
- import_file: @form.file.path,
114
+ parsed_file_contents: parsed_file_contents,
109
115
  overwrite_existing: @form.overwrite_existing,
110
116
  mark_inactive_translations: @form.mark_inactive_translations,
111
117
  )
@@ -1,24 +1,18 @@
1
1
  module RailsI18nManager
2
- class TranslationsImportJob < ApplicationJob
2
+ class TranslationsImportJob
3
3
 
4
4
  class ImportAbortedError < StandardError; end
5
5
 
6
- def perform(translation_app_id:, import_file:, overwrite_existing: false, mark_inactive_translations: false)
6
+ def perform(translation_app_id:, parsed_file_contents:, overwrite_existing: false, mark_inactive_translations: false)
7
7
  app_record = TranslationApp.find(translation_app_id)
8
8
 
9
- if import_file.end_with?(".json")
10
- translations_hash = JSON.parse(File.read(import_file))
11
- else
12
- translations_hash = YAML.safe_load(File.read(import_file))
13
- end
14
-
15
- new_locales = translations_hash.keys - app_record.all_locales
9
+ new_locales = parsed_file_contents.keys - app_record.all_locales
16
10
 
17
11
  if new_locales.any?
18
12
  raise ImportAbortedError.new("Import aborted. Locale not listed in translation app: #{new_locales.join(', ')}")
19
13
  end
20
14
 
21
- all_keys = RailsI18nManager.fetch_flattened_dot_notation_keys(translations_hash)
15
+ all_keys = RailsI18nManager.fetch_flattened_dot_notation_keys(parsed_file_contents)
22
16
 
23
17
  key_records_by_key = app_record.translation_keys.includes(:translation_values).index_by(&:key)
24
18
 
@@ -35,7 +29,7 @@ module RailsI18nManager
35
29
  app_record.all_locales.each do |locale|
36
30
  split_keys = [locale] + key.split(".").map{|x| x}
37
31
 
38
- val = translations_hash.dig(*split_keys)
32
+ val = parsed_file_contents.dig(*split_keys)
39
33
 
40
34
  if val.present?
41
35
  val_record = key_record.translation_values.detect{|x| x.locale == locale.to_s }
data/config/routes.rb CHANGED
@@ -14,8 +14,6 @@ RailsI18nManager::Engine.routes.draw do
14
14
 
15
15
  get "/robots", to: "application#robots", constraints: ->(req){ req.format == :text }
16
16
 
17
- match "*a", to: "application#render_404", via: :get
18
-
19
17
  get "/", to: "translations#index"
20
18
 
21
19
  root "translations#index"
@@ -1,3 +1,3 @@
1
1
  module RailsI18nManager
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "1.1.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_i18n_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weston Ganger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-18 00:00:00.000000000 Z
11
+ date: 2025-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -225,7 +225,6 @@ files:
225
225
  - app/controllers/rails_i18n_manager/translations_controller.rb
226
226
  - app/helpers/rails_i18n_manager/application_helper.rb
227
227
  - app/helpers/rails_i18n_manager/custom_form_builder.rb
228
- - app/jobs/rails_i18n_manager/application_job.rb
229
228
  - app/jobs/rails_i18n_manager/translations_import_job.rb
230
229
  - app/lib/rails_i18n_manager/forms/base.rb
231
230
  - app/lib/rails_i18n_manager/forms/translation_file_form.rb
@@ -1,5 +0,0 @@
1
- module RailsI18nManager
2
- class ApplicationJob < ActiveJob::Base
3
- self.queue_adapter = :async
4
- end
5
- end