Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/jobs/rails_i18n_manager/translations_import_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def perform(translation_app_id:, import_file:, overwrite_existing: false, mark_i
if import_file.end_with?(".json")
translations_hash = JSON.parse(File.read(import_file))
else
translations_hash = YAML.safe_load(File.read(import_file))
translations_hash = YAML.safe_load(File.read(import_file), [Symbol])
end

new_locales = translations_hash.keys - app_record.all_locales
Expand Down
2 changes: 1 addition & 1 deletion app/lib/rails_i18n_manager/forms/translation_file_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def validate_file

case File.extname(file)
when ".yml"
if !YAML.safe_load(File.read(file)).is_a?(Hash)
if !YAML.safe_load(File.read(file), [Symbol]).is_a?(Hash)
errors.add(:file, "Invalid yml file.")
return
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/rails_i18n_manager/translation_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def default_translation
@default_translation = self.translation_values.detect{|x| x.locale == translation_app.default_locale.to_s }&.translation
end

def translation(language_code)
self.translation_values.detect{|x| x.locale == language_code }&.translation
end

def any_missing_translations?
self.translation_app.all_locales.any? do |locale|
val_record = translation_values.detect{|x| x.locale == locale.to_s}
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/rails_i18n_manager/application.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- @title = "Translations Manager"
- @title = "Translations Manager NB"

doctype html
html
Expand Down
2 changes: 1 addition & 1 deletion app/views/rails_i18n_manager/translations/import.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ h2.page-sub-title Import Translations from Source File

.row
.col-6
= custom_form_for @form, as: :import_form, url: import_translations_path, method: :post, multipart: true, html: {class: "form-horizontal"} do |f|
= custom_form_for @form, as: :import_form, url: import_translations_path, method: :post, multipart: true, html: {enctype: "multipart/form-data", class: "form-horizontal"} do |f|
= f.error_notification

= f.field :translation_app_id, label: "App Name", type: :select, collection: RailsI18nManager::TranslationApp.order(name: :asc).pluck(:name, :id)
Expand Down
2 changes: 2 additions & 0 deletions app/views/rails_i18n_manager/translations/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ table.table.table-striped.table-hover.space-above3.list-table
th Default Translation
- if params[:status] == "Inactive"
th Status
th Translation SV
th = sort_link(:updated_at)
th Actions
tbody
Expand All @@ -37,6 +38,7 @@ table.table.table-striped.table-hover.space-above3.list-table
td = x.default_translation
- if params[:status] == "Inactive"
td Inactive
td = x.translation("sv")
td = x.updated_at&.strftime("%Y-%m-%d %l:%M %p")
td
span = link_to "View", {action: :show, id: x.id}
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20221001001344_add_rails_i18n_manager_tables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def change
create_table :rails_i18n_manager_translation_values do |t|
t.references :translation_key, index: { name: 'index_translation_values_on_translation_key_id' }
t.string :locale, limit: 5
t.string :translation
t.string :translation, limit: 500
t.datetime :updated_at
end

Expand Down