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 +4 -4
- data/app/controllers/rails_i18n_manager/translations_controller.rb +7 -1
- data/app/jobs/rails_i18n_manager/translations_import_job.rb +5 -11
- data/config/routes.rb +0 -2
- data/lib/rails_i18n_manager/version.rb +1 -1
- metadata +2 -3
- data/app/jobs/rails_i18n_manager/application_job.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42c0b085e7edbb9d009e8bccba78e937350e914d44b6d571fbfa9dab4949f23f
|
4
|
+
data.tar.gz: cf189df04c6de14d7796a34a9da4328d290066a81e7992048703df65d2c71c8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
2
|
+
class TranslationsImportJob
|
3
3
|
|
4
4
|
class ImportAbortedError < StandardError; end
|
5
5
|
|
6
|
-
def perform(translation_app_id:,
|
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
|
-
|
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(
|
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 =
|
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"
|
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.
|
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-
|
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
|