Fix translation bug.

This commit is contained in:
BoHung Chiu 2023-07-27 12:10:29 +08:00
parent d6a749995f
commit 6eee8738cc
10 changed files with 52 additions and 52 deletions

View File

@ -1,6 +1,6 @@
module Admin::PersonalPluginFieldsHelper
include OrbitBackendHelper
def thead_field(field)
def thead_field_for_ppg(field)
return I18n.t("personal_plugin_generator.#{field}")
end
end

View File

@ -84,23 +84,23 @@
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<div class="control-group">
<label class="control-label muted"><%=thead_field("module_name")%></label>
<label class="control-label muted"><%=thead_field_for_ppg("module_name")%></label>
<div class="controls">
<%= f.text_field :module_name, placeholder: thead_field("module_name") %>
<%= f.text_field :module_name, placeholder: thead_field_for_ppg("module_name") %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%=thead_field("primary_modal_name")%></label>
<label class="control-label muted"><%=thead_field_for_ppg("primary_modal_name")%></label>
<div class="controls">
<%= f.text_field :primary_modal_name, placeholder: thead_field("primary_modal_name"), class: "primary_modal_name" %>
<%= f.text_field :primary_modal_name, placeholder: thead_field_for_ppg("primary_modal_name"), class: "primary_modal_name" %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%=thead_field("related_modal_name")%></label>
<label class="control-label muted"><%=thead_field_for_ppg("related_modal_name")%></label>
<div class="controls">
<% f.object.related_modal_name.each_with_index do |related_modal_name,i| %>
<div>
<%= text_field_tag "#{f.object_name}[related_modal_name][]", related_modal_name,placeholder: thead_field("related_modal_name"), class: "related_modal_name", title: thead_field("related_modal_name") %>
<%= text_field_tag "#{f.object_name}[related_modal_name][]", related_modal_name,placeholder: thead_field_for_ppg("related_modal_name"), class: "related_modal_name", title: thead_field_for_ppg("related_modal_name") %>
<button type="button" class="remove_related_modal" index="<%=i%>"><%=t(:remove)%></button>
</div>
<% end %>
@ -108,9 +108,9 @@
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%=thead_field("one_line_title_format")%></label>
<label class="control-label muted"><%=thead_field_for_ppg("one_line_title_format")%></label>
<div class="controls">
<label for="enable_one_line_title"><%= f.check_box :enable_one_line_title, :checked => (f.object.enable_one_line_title), :class=>"toggle-check", :id=>"enable_one_line_title", :data=> { disabled: true } %><span style="float: left;"><%=thead_field("enable")%></span></label>
<label for="enable_one_line_title"><%= f.check_box :enable_one_line_title, :checked => (f.object.enable_one_line_title), :class=>"toggle-check", :id=>"enable_one_line_title", :data=> { disabled: true } %><span style="float: left;"><%=thead_field_for_ppg("enable")%></span></label>
<div style="clear: both;"></div>
<%= f.text_field :one_line_title_format, (f.object.enable_one_line_title ? {} : {:disabled=>'disabled',:id=>'one_line_title_format'}) %>
</div>
@ -129,25 +129,25 @@
</div>
</div>
</div>
<% field_types = ["text_field","text_editor","file","link","year","year_month","date","time","date_time","member"].map{|field| [thead_field(field),field]}
<% field_types = ["text_field","text_editor","file","link","year","year_month","date","time","date_time","member"].map{|field| [thead_field_for_ppg(field),field]}
field_types1 = field_types.select{|a| a[1] != "file" && a[1] != "member"}
%>
<div class="tab-content language-area">
<div id="primary_modal_plane">
<h4><%=thead_field("primary_modal_name")%> : <span class="primary_modal_name"><%= f.object.primary_modal_name%></span></h4>
<h4><%=thead_field_for_ppg("primary_modal_name")%> : <span class="primary_modal_name"><%= f.object.primary_modal_name%></span></h4>
<% if f.object.primary_modal_fields.present? %>
<%= render :partial => 'render_table',locals: {:f => f,:root_name => "primary_modal_fields",:field_values => f.object.primary_modal_fields,:field_types => field_types } %>
<% else %>
<%= render :partial => 'render_table',locals: {:f => f,:root_name => "primary_modal_fields",:field_values => [nil,nil],:field_types => field_types,:@include_blank => true} %>
<% end %>
<button type="button" onclick="add_primary_modal_field()" class="btn btn-primary"><%= thead_field('add_field') %></button>
<button type="button" onclick="add_primary_modal_field()" class="btn btn-primary"><%= thead_field_for_ppg('add_field') %></button>
</div>
<div id="related_modal_plane">
<% if f.object.related_modal_name.present? %>
<% f.object.related_modal_name.each_with_index do |related_modal_name,i| %>
<% field_values = f.object.related_modal_fields[i].to_a %>
<div index="<%= i %>">
<h4><%=thead_field("related_modal_name")%> : <span class="related_modal_name"><%= related_modal_name %></span></h4>
<h4><%=thead_field_for_ppg("related_modal_name")%> : <span class="related_modal_name"><%= related_modal_name %></span></h4>
<%= render :partial => 'render_table',locals: {:f => f,:root_name => "related_modal_fields][#{i}",:field_values => field_values,:field_types => field_types1 } %>
</div>
<% end %>
@ -182,23 +182,23 @@
$(this).parents('.start-line').hide();
}
});
var related_modal_name_html = '<%= text_field_tag "#{f.object_name}[related_modal_name][]", '',placeholder: thead_field("related_modal_name"), class: "related_modal_name", title: thead_field("related_modal_name") %>';
var related_modal_name_html = '<%= text_field_tag "#{f.object_name}[related_modal_name][]", '',placeholder: thead_field_for_ppg("related_modal_name"), class: "related_modal_name", title: thead_field_for_ppg("related_modal_name") %>';
related_modal_name_html = $("<div></div>").append(related_modal_name_html);
related_modal_name_html.append("<button type=\"button\" class=\"remove_related_modal\"><%=t(:remove) %></button>")
$(".remove_btn").off("click").on("click",function(){
if(window.confirm("<%=thead_field('remove_text')%>")){
if(window.confirm("<%=thead_field_for_ppg('remove_text')%>")){
$(this).parent().parent().remove();
}
})
<%
related_modal_fields_html = "<div index=\"new_index\"><h4>#{thead_field("related_modal_name")} : <span class=\"related_modal_name\"></span></h4>"
related_modal_fields_html = "<div index=\"new_index\"><h4>#{thead_field_for_ppg("related_modal_name")} : <span class=\"related_modal_name\"></span></h4>"
related_modal_fields_html += render(:partial => 'render_table',locals: {:f => f,:root_name => "related_modal_fields][new_index",:field_values => [nil],:field_types => field_types1,:@include_blank=>false})
related_modal_fields_html += "</div>"
primary_modal_field_html = render(:partial => 'render_table',locals: {:f => f,:root_name => "primary_modal_fields",:field_values => [nil],:field_types => field_types,:@include_blank=>false})
%>
var related_modal_fields_html = "<%= escape_javascript(related_modal_fields_html.html_safe) %>";
var primary_modal_field_html = $("<%= escape_javascript(primary_modal_field_html.html_safe) %>").find("tbody tr")[0].outerHTML;
var add_related_modal_field_btn = '<button type="button" onclick="add_related_modal_field(this)" class="btn btn-primary"><%=thead_field('add_field')%></button>';
var add_related_modal_field_btn = '<button type="button" onclick="add_related_modal_field(this)" class="btn btn-primary"><%=thead_field_for_ppg('add_field')%></button>';
$("#add_related_modal").click(function(){
var clone_modal = related_modal_name_html.clone();
var new_index = $("#related_modal_plane > div").length;
@ -215,7 +215,7 @@
remove_related_modal_func(this);
});
function remove_related_modal_func(item){
if(window.confirm("<%=thead_field('remove_text')%>")){
if(window.confirm("<%=thead_field_for_ppg('remove_text')%>")){
var index = $(item).attr("index");
$(item).parent().remove();
console.log(index);
@ -233,7 +233,7 @@
var related_modal = $(related_modal_fields_html.replaceAll("new_field_index",$(item).parent().find("tbody tr").length));
$(item).parent().find("tbody").append(related_modal.find("tbody tr")[0].outerHTML.replaceAll("new_index",current_index));
$(".remove_btn").off("click").on("click",function(){
if(window.confirm("<%=thead_field('remove_text')%>")){
if(window.confirm("<%=thead_field_for_ppg('remove_text')%>")){
$(this).parent().parent().remove();
}
})
@ -243,7 +243,7 @@
var primary_modal = $(primary_modal_field_html.replaceAll("new_field_index",$("#primary_modal_plane tbody tr").length));
$("#primary_modal_plane tbody").append(primary_modal);
$(".remove_btn").off("click").on("click",function(){
if(window.confirm("<%=thead_field('remove_text')%>")){
if(window.confirm("<%=thead_field_for_ppg('remove_text')%>")){
$(this).parent().parent().remove();
}
})
@ -251,9 +251,9 @@
$.ajaxSetup({async: false});
$(".main-forms").submit(function(){
if($("#primary_modal_plane .slug_title:checked").length == 0){
alert("<%=thead_field('please_choose_one_slug_title')%>");
alert("<%=thead_field_for_ppg('please_choose_one_slug_title')%>");
}else if($("#primary_modal_plane .slug_title:checked").length > 1){
alert("<%=thead_field('slug_title_can_only_choose_one')%>");
alert("<%=thead_field_for_ppg('slug_title_can_only_choose_one')%>");
}else{
var can_install;
$.post("<%=check_plugin_exist_admin_personal_plugin_field_path%>",{plugin_name: $("#personal_plugin_field_module_name").val(), id: "<%=f.object.id %>"}).done(function(data){
@ -281,7 +281,7 @@
}else{
$("#personal_plugin_field_module_name").css('border', '2px solid red');
alert("<%=thead_field("please_change_module_name")%>");
alert("<%=thead_field_for_ppg("please_change_module_name")%>");
window.location.href = "#" + $(".main-forms")[0].id;
can_install = false;
}

View File

@ -10,10 +10,10 @@
</td>
<td><%= personal_plugin_field.module_name %></td>
<td><%= link_to t(:edit) ,edit_admin_personal_plugin_field_path(personal_plugin_field.id),:class=> "btn btn-primary" %>
<%= link_to thead_field('fields_display_setting') ,admin_personal_plugin_field_fields_setting_path(personal_plugin_field.id),:class=> "btn btn-primary" %>
<%= link_to thead_field(:copy) ,admin_personal_plugin_field_copy_path(personal_plugin_field.id),:class=> "btn btn-primary" %>
<button class="generate_plugin btn btn-primary" type="button" data-url="<%= admin_personal_plugin_field_generate_plugin_path(personal_plugin_field.id) %>"><%= thead_field("generate_plugin") %></button>
<%= link_to thead_field(:download) ,admin_personal_plugin_field_download_path(personal_plugin_field.id),:class=> "btn btn-primary" %>
<%= link_to thead_field_for_ppg('fields_display_setting') ,admin_personal_plugin_field_fields_setting_path(personal_plugin_field.id),:class=> "btn btn-primary" %>
<%= link_to thead_field_for_ppg(:copy) ,admin_personal_plugin_field_copy_path(personal_plugin_field.id),:class=> "btn btn-primary" %>
<button class="generate_plugin btn btn-primary" type="button" data-url="<%= admin_personal_plugin_field_generate_plugin_path(personal_plugin_field.id) %>"><%= thead_field_for_ppg("generate_plugin") %></button>
<%= link_to thead_field_for_ppg(:download) ,admin_personal_plugin_field_download_path(personal_plugin_field.id),:class=> "btn btn-primary" %>
<a data-confirm="Are you sure?" data-method="delete" href="<%=admin_personal_plugin_field_path(personal_plugin_field.id) %>" rel="nofollow" class="delete btn btn-primary"><%= t(:delete_) %></a>
</td>
</tr>

View File

@ -1,7 +1,7 @@
<div id="<%= "#{root_name}_#{page_name}" %>">
<% object = f.object
%>
<h5><%=thead_field(page_name)%></h5>
<h5><%=thead_field_for_ppg(page_name)%></h5>
<button type="button" class="select_all btn"><%=t("select_all")%></button>
<button type="button" class="de_select_all btn"><%=t("de_select_all")%></button>
<table class="table table-bordered" id="<%="#{root_name}_#{page_name}"%>">

View File

@ -2,12 +2,12 @@
<thead>
<th></th>
<th><%= t(:remove) %></th>
<th><%= thead_field("field_name") %></th>
<th><%= thead_field("translation_name") %></th>
<th><%= thead_field("field_type") %></th>
<th><%= thead_field("localize") %></th>
<th><%= thead_field("slug_title") %></th>
<th><%= thead_field("periodic_time") %></th>
<th><%= thead_field_for_ppg("field_name") %></th>
<th><%= thead_field_for_ppg("translation_name") %></th>
<th><%= thead_field_for_ppg("field_type") %></th>
<th><%= thead_field_for_ppg("localize") %></th>
<th><%= thead_field_for_ppg("slug_title") %></th>
<th><%= thead_field_for_ppg("periodic_time") %></th>
</thead>
<tbody>
<%= f.fields_for root_name do |f| %>

View File

@ -23,7 +23,7 @@
<!-- Input Area -->
<div class="input-area">
<h4><%= thead_field('backend_page') %></h4>
<h4><%= thead_field_for_ppg('backend_page') %></h4>
<div id="backend_page">
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'backend_fields',:page_name=>'index'} %>
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'backend_fields',:page_name=>'profile'} %>
@ -31,7 +31,7 @@
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'backend_fields',:page_name=>'sort_asc',:access_field_types=>["date","date_time","year","year_month","time"]} %>
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'backend_fields',:page_name=>'sort_desc',:access_field_types=>["date","date_time","year","year_month","time"]} %>
</div>
<h4><%= thead_field('frontend_page') %></h4>
<h4><%= thead_field_for_ppg('frontend_page') %></h4>
<div id="frontend_page">
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'frontend_fields',:page_name=>'index'} %>
<%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'frontend_fields',:page_name=>'show'} %>
@ -73,9 +73,9 @@
if($("#backend_fields_analysis input").length > 0){
$(".main-forms").submit(function(){
if($("#backend_fields_analysis input:checked").length == 0){
alert("<%=thead_field('please_choose_one_analysis_field')%>");
alert("<%=thead_field_for_ppg('please_choose_one_analysis_field')%>");
}else if($("#backend_fields_analysis input:checked").length > 1){
alert("<%=thead_field('analysis_field_can_only_choose_one')%>");
alert("<%=thead_field_for_ppg('analysis_field_can_only_choose_one')%>");
}else{
return true;
}

View File

@ -1,20 +1,20 @@
<table class="table main-list">
<thead>
<tr>
<th><%= thead_field("personal_plugin_name") %></th>
<th><%= thead_field("module_name") %></th>
<th><%= thead_field("action") %></th>
<th><%= thead_field_for_ppg("personal_plugin_name") %></th>
<th><%= thead_field_for_ppg("module_name") %></th>
<th><%= thead_field_for_ppg("action") %></th>
</tr>
</thead>
<tbody id="tbody_writing_journals" class="sort-holder">
<%= render 'personal_plugin_fields' %>
</tbody>
</table>
<div id='dialog-confirm' title="<%= thead_field("generate_plugin") %>" style="display: none;">
<div id='dialog-confirm' title="<%= thead_field_for_ppg("generate_plugin") %>" style="display: none;">
<div style="clear:both;"></div>
<div id="info_texts">
<image src="/assets/preloader.gif" id="preloader"></image>
<div id="generating_plugin"><%=thead_field("generating_plugin")%></div>
<div id="generating_plugin"><%=thead_field_for_ppg("generating_plugin")%></div>
<div id="info_logs"></div>
</div>
</div>
@ -43,7 +43,7 @@
$("#preloader").css("display",'none');
$("#generating_plugin").css("display",'none');
if(data["success"]){
$( "#info_logs" ).html("<span><%=thead_field("goto")%><a target=\"_blank\" href=\""+data["url"]+"\" title=\"<%=thead_field("goto")%> "+data["name"]+"\">"+data["name"]+"</a></span>")
$( "#info_logs" ).html("<span><%=thead_field_for_ppg("goto")%><a target=\"_blank\" href=\""+data["url"]+"\" title=\"<%=thead_field_for_ppg("goto")%> "+data["name"]+"\">"+data["name"]+"</a></span>")
}else{
$( "#info_logs" ).html(data["error"]);
}

View File

@ -8,9 +8,9 @@ en:
one_line_title_format: "Paper Format Title"
download: Download
author_translation_name: Author translation name
personal_plugin_generator: Personal Plugin Generate
personal_plugin_generate: Personal Plugin Generate
personal_plugin_name: Personal Plugin Name Translation
module_name: Module Name
module_name: Module Key
action: Action
primary_modal_name: Primary Modal Name
related_modal_name: Related Modal Name

View File

@ -8,9 +8,9 @@ zh_tw:
one_line_title_format: "論文格式標題"
download: 下載
author_translation_name: 著作人翻譯名稱
personal_plugin_generator: 個人外掛生成
personal_plugin_generate: 個人外掛生成
personal_plugin_name: 個人外掛翻譯名稱
module_name: 模組名稱
module_name: 模組Key
action: 動作
primary_modal_name: 主要modal名稱(均英文小寫,可加底線)
related_modal_name: 關聯modal名稱(用來存論文類型、期刊等級...等)

View File

@ -8,11 +8,11 @@ module PersonalPluginGenerator
categorizable
authorizable
side_bar do
head_label_i18n 'personal_plugin_generator.personal_plugin_generator', icon_class: "icons-graduation"
head_label_i18n 'module_name.personal_plugin_generator', icon_class: "icons-graduation"
available_for "users"
active_for_controllers (['admin/personal_plugin_fields'])
head_link_path "admin_personal_plugin_fields_path"
context_link 'personal_plugin_generator.personal_plugin_generator',
context_link 'personal_plugin_generator.personal_plugin_generate',
:link_path=>"admin_personal_plugin_fields_path" ,
:priority=>1,
:active_for_action=>{'admin/personal_plugin_fields'=>'index'},
@ -25,11 +25,11 @@ module PersonalPluginGenerator
categorizable
authorizable
side_bar do
head_label_i18n 'personal_plugin_generator.personal_plugin_generator', icon_class: "icons-graduation"
head_label_i18n 'module_name.personal_plugin_generater', icon_class: "icons-graduation"
available_for "users"
active_for_controllers (['admin/personal_plugin_fields'])
head_link_path "admin_personal_plugin_fields_path"
context_link 'personal_plugin_generator.personal_plugin_generator',
context_link 'personal_plugin_generator.personal_plugin_generate',
:link_path=>"admin_personal_plugin_fields_path" ,
:priority=>1,
:active_for_action=>{'admin/personal_plugin_fields'=>'index'},