diff --git a/app/controllers/admin/cancerpredicts_controller.rb b/app/controllers/admin/cancerpredicts_controller.rb index ab697e9..c25cd21 100644 --- a/app/controllers/admin/cancerpredicts_controller.rb +++ b/app/controllers/admin/cancerpredicts_controller.rb @@ -333,7 +333,7 @@ class Admin::CancerpredictsController < OrbitAdminController Dir.chdir("public") do @site_locales = Site.last.in_use_locales.each do |locale| I18n.with_locale(locale) do - @file_tmp = File.new("#{Cancerpredictfields::ToolTablePrefix}#{I18n.locale}.txt", "w") + @file_tmp = File.new(Cancerpredictfields::ToolTableMap[I18n.locale], "w") tmp_table_texts = create_table(locale) @file_tmp.write(tmp_table_texts) @file_tmp.close @@ -661,7 +661,7 @@ class Admin::CancerpredictsController < OrbitAdminController Dir.chdir("public") do @site_locales = Site.last.in_use_locales.each do |locale| I18n.with_locale(locale) do - @file_tmp = File.new("#{Cancerpredictfields::ToolTablePrefix}#{I18n.locale}.txt", "w") + @file_tmp = File.new(Cancerpredictfields::ToolTableMap[I18n.locale], "w") tmp_table_texts = create_table(locale) @file_tmp.write(tmp_table_texts) @file_tmp.close diff --git a/app/controllers/cancerpredicts_controller.rb b/app/controllers/cancerpredicts_controller.rb index c443187..b4876ef 100644 --- a/app/controllers/cancerpredicts_controller.rb +++ b/app/controllers/cancerpredicts_controller.rb @@ -150,7 +150,7 @@ class CancerpredictsController < ApplicationController uid = OrbitHelper.params[:uid] rescue "" tags = OrbitHelper.widget_tags categories = OrbitHelper.widget_categories || [] - @table_str = File.read("#{Cancerpredictfields::ToolTablePrefix}#{I18n.locale}.txt") + @table_str = File.read(Cancerpredictfields::ToolTableMap[I18n.locale]) preidct_js_url = "/assets/cancer_predict.js" if File.exist?(Cancerpredictfields::JSFileName) js_filename = File.read(Cancerpredictfields::JSFileName) @@ -171,7 +171,7 @@ class CancerpredictsController < ApplicationController uid = OrbitHelper.params[:uid] rescue "" tags = OrbitHelper.widget_tags categories = OrbitHelper.widget_categories || [] - @table_str = File.read("#{Cancerpredictfields::ToolTablePrefix}#{I18n.locale}.txt") + @table_str = File.read(Cancerpredictfields::ToolTableMap[I18n.locale]) preidct_js_url = "/assets/cancer_predict.js" if File.exist?(Cancerpredictfields::JSFileName) js_filename = File.read(Cancerpredictfields::JSFileName) diff --git a/app/models/cancerpredictfields.rb b/app/models/cancerpredictfields.rb index 915962c..46bc878 100644 --- a/app/models/cancerpredictfields.rb +++ b/app/models/cancerpredictfields.rb @@ -10,7 +10,9 @@ class Cancerpredictfields TherapyFields = ["variable","name","hint","comment_text","choice_fields","lpv_impact","active_choice","disable_condition"] TherapyOnly = ["lpv_impact","active_choice","disable_condition"] JSFileName = "public/cancer_tool_js_filename.txt".freeze - ToolTablePrefix = "public/cancer_tool_table_tmp_".freeze + ToolTableMap = I18n.available_locales.map do |locale| + [locale, "public/cancer_tool_table_tmp_#{locale}.txt".freeze] + end.to_h field :title ,type:String ,default:"" field :advance_mode, type: Boolean, default: false field :form_show , :type=> Hash ,default:{