From 5713df685d6477429c2b90896a47e7a1707e2627 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 26 Jul 2012 05:58:09 +0800 Subject: [PATCH] Remove i18n_variable for views --- app/models/user/user.rb | 2 +- .../admin/ad_banners/_modal_preview.html.erb | 2 +- .../admin/ad_banners/_preview_block.html.erb | 2 +- app/views/admin/ad_images/_form.html.erb | 8 ++++---- .../asset_categories/_asset_category.html.erb | 2 +- app/views/admin/asset_categories/_form.html.erb | 4 ++-- app/views/admin/assets/_asset.html.erb | 4 ++-- app/views/admin/assets/_form.html.erb | 6 +++--- app/views/admin/assets/file_upload.html.erb | 8 ++++---- .../admin/attributes/_attribute_field.html.erb | 4 ++-- app/views/admin/attributes/index.html.erb | 2 +- app/views/admin/dashboards/index.html.erb | 4 ++-- app/views/admin/infos/_form.html.erb | 4 ++-- app/views/admin/links/_form.html.erb | 4 ++-- app/views/admin/links/_show.html.erb | 2 +- .../module_apps/reload_frontend_pages.js.erb | 2 +- .../admin/page_parts/_module_widget.html.erb | 4 ++-- app/views/admin/page_parts/_text.html.erb | 4 ++-- .../page_parts/_widget_categories.html.erb | 2 +- .../admin/page_parts/_widget_tags.html.erb | 2 +- app/views/admin/pages/_form.html.erb | 6 +++--- app/views/admin/roles/_form.html.erb | 4 ++-- app/views/admin/roles/_sub_role.html.erb | 4 ++-- app/views/admin/sites/site_info.html.erb | 17 +++++++++-------- app/views/admin/users/_form.html.erb | 4 ++-- app/views/admin/users/_info.html.erb | 4 ++-- app/views/admin/users/_show_attribute.html.erb | 2 +- app/views/admin/users/_show_sub_role.html.erb | 2 +- app/views/admin/users/_sub_role.html.erb | 4 ++-- .../admin/users/_sub_role_selector.html.erb | 2 +- app/views/admin/users/index.html.erb | 2 +- app/views/admin/users/show.html.erb | 4 ++-- 32 files changed, 64 insertions(+), 63 deletions(-) diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 46dc1040..1f7b11d7 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -35,7 +35,7 @@ class User # if(self.cache_dept.nil?) # self.build_cache_dept key: "dept_cache_user_#{self.id}" # end - dept_hash[locale] = sub_roles.collect{|sr| sr.i18n_variable[locale]}.join(',') + dept_hash[locale] = sub_roles.collect{|sr| sr.title}.join(',') # self.cache_dept[locale] = sub_roles.collect{|sr| sr.i18n_variable[locale]}.join(',') end self.cache_dept = dept_hash diff --git a/app/views/admin/ad_banners/_modal_preview.html.erb b/app/views/admin/ad_banners/_modal_preview.html.erb index ffc84107..3dc98521 100644 --- a/app/views/admin/ad_banners/_modal_preview.html.erb +++ b/app/views/admin/ad_banners/_modal_preview.html.erb @@ -8,7 +8,7 @@ diff --git a/app/views/admin/ad_banners/_preview_block.html.erb b/app/views/admin/ad_banners/_preview_block.html.erb index 47646f6f..afa9125d 100644 --- a/app/views/admin/ad_banners/_preview_block.html.erb +++ b/app/views/admin/ad_banners/_preview_block.html.erb @@ -9,7 +9,7 @@ diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index edbb2563..3ecda29b 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -142,14 +142,14 @@ <% @site_valid_locales.each do |locale|%> <%= content_tag :div,:class => "tab-pane #{active_when_current_locale_eq locale}",:id=>"#{locale}" do%>
- <%= f.fields_for :title,@ad_image.title do |f| %> - <%= f.text_field locale,:class=>"ad_image-title post-title",:placeholder => "輸入標題"%> + <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, :class=>"ad_image-title post-title", :placeholder => "輸入標題", :value => (@ad_image.title_translations[locale] rescue nil) %> <% end %>

- <%= f.fields_for :context, @ad_image.context do |f| %> - <%= f.text_area locale,:style => "width:100%", :class => "tinymce_textarea post-title" %> + <%= f.fields_for :context_translations, @ad_image.context do |f| %> + <%= f.text_area locale, :style => "width:100%", :class => "tinymce_textarea post-title", :value => (@ad_image.context_translations[locale] rescue nil) %> <% end %>
diff --git a/app/views/admin/asset_categories/_asset_category.html.erb b/app/views/admin/asset_categories/_asset_category.html.erb index d7047e36..64a931da 100644 --- a/app/views/admin/asset_categories/_asset_category.html.erb +++ b/app/views/admin/asset_categories/_asset_category.html.erb @@ -12,6 +12,6 @@ <% @site_valid_locales.each do |locale| %> - <%= asset_category.i18n_variable[locale] rescue nil %> + <%= asset_category.title_translations[locale] rescue nil %> <% end %> diff --git a/app/views/admin/asset_categories/_form.html.erb b/app/views/admin/asset_categories/_form.html.erb index 5c64146f..76df5c00 100644 --- a/app/views/admin/asset_categories/_form.html.erb +++ b/app/views/admin/asset_categories/_form.html.erb @@ -10,12 +10,12 @@
- <%= f.fields_for :i18n_variable, (@asset_category.new_record? ? @asset_category.build_i18n_variable : @asset_category.i18n_variable) do |f| %> + <%= f.fields_for :title_translations do |f| %> <% @site_valid_locales.each do |locale| %>
<%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
- <%= f.text_field locale, :class => 'input-xxlarge' %> + <%= f.text_field locale, :class => 'input-xxlarge', :value => (@asset_category.title_translations[locale] rescue nil) %>
<% end %> diff --git a/app/views/admin/assets/_asset.html.erb b/app/views/admin/assets/_asset.html.erb index 3a8dc439..a45e9a4b 100644 --- a/app/views/admin/assets/_asset.html.erb +++ b/app/views/admin/assets/_asset.html.erb @@ -1,6 +1,6 @@ <%= check_box_tag 'to_delete[]', asset.id, false, :class => "checkbox_in_list" %> - <%= asset.title.i18n_variable[I18n.locale] rescue nil %> + <%= asset.title rescue nil %>
@@ -12,7 +12,7 @@ <%= asset.data.file.content_type %> <%= number_to_human_size(asset.data.file.file_length) %> - <%= asset.description.i18n_variable[I18n.locale] rescue nil %> + <%= asset.description rescue nil %>
diff --git a/app/views/admin/assets/_form.html.erb b/app/views/admin/assets/_form.html.erb index 4e1589f4..dddfa9e6 100644 --- a/app/views/admin/assets/_form.html.erb +++ b/app/views/admin/assets/_form.html.erb @@ -1,12 +1,12 @@
- <%= f.fields_for :i18n_variable, (@asset.new_record? ? @asset.build_i18n_variable : @asset.i18n_variable) do |f| %> + <%= f.fields_for :title_translations do |f| %> <% @site_valid_locales.each do |locale| %> <%= content_tag :label do -%>
<%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale, :class => "input-large" %> + <%= f.text_field locale, :class => "input-large", :value => (@asset.title_translations[locale] rescue nil) %>
<% end %> <% end %> @@ -16,7 +16,7 @@
- <%= f.select :asset_category_id, @asset_categories.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-large" %> + <%= f.select :asset_category_id, @asset_categories.collect{|t| [ t.title, t.id ]}, {}, :class => "input-large" %>
diff --git a/app/views/admin/assets/file_upload.html.erb b/app/views/admin/assets/file_upload.html.erb index ff21935c..abdcfbc6 100644 --- a/app/views/admin/assets/file_upload.html.erb +++ b/app/views/admin/assets/file_upload.html.erb @@ -11,13 +11,13 @@
- <%= f.fields_for :title, (@asset.new_record? ? @asset.build_title : @asset.title) do |f| %> + <%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %> <%= content_tag :label do -%>
<%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale, :class => "input-large" %> + <%= f.text_field locale, :class => "input-large", :value => (@asset.title_translations[locale] rescue nil) %>
<% end %> <% end %> @@ -28,13 +28,13 @@
- <%= f.fields_for :description, (@asset.new_record? ? @asset.build_description : @asset.description) do |f| %> + <%= f.fields_for :description_translations do |f| %>
<% @site_valid_locales.each do |locale| %> <%= content_tag :label do -%>
<%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale, :class => "input-large" %> + <%= f.text_field locale, :class => "input-large", :value => (@asset.title_translations[locale] rescue nil) %>
<% end %> <% end %> diff --git a/app/views/admin/attributes/_attribute_field.html.erb b/app/views/admin/attributes/_attribute_field.html.erb index 63ee5953..b2e94344 100644 --- a/app/views/admin/attributes/_attribute_field.html.erb +++ b/app/views/admin/attributes/_attribute_field.html.erb @@ -3,9 +3,9 @@ <%= f.check_box :locale %> - <%= f.fields_for :i18n_variable, (attribute_field.new_record? ? attribute_field.build_i18n_variable : attribute_field.i18n_variable) do |f| %> + <%= f.fields_for :title_translations do |f| %> <% @site_valid_locales.each do |locale| %> - <%= f.text_field locale, :style => "width:130px" %> + <%= f.text_field locale, :style => "width:130px", :value => (attribute_field.title_translations[locale] rescue nil) %> <% end %> <% end %> diff --git a/app/views/admin/attributes/index.html.erb b/app/views/admin/attributes/index.html.erb index 71ec1699..83ded4eb 100644 --- a/app/views/admin/attributes/index.html.erb +++ b/app/views/admin/attributes/index.html.erb @@ -16,7 +16,7 @@ <% @attributes.each do |attribute| %> "> - <%= attribute.i18n_variable[I18n.locale] %> + <%= attribute.title %> <%= link_to t(:edit), eval("edit_admin_#{@attribute_type}_path(attribute)"), :class => 'edit' %> diff --git a/app/views/admin/dashboards/index.html.erb b/app/views/admin/dashboards/index.html.erb index dbca5aa6..180a0469 100644 --- a/app/views/admin/dashboards/index.html.erb +++ b/app/views/admin/dashboards/index.html.erb @@ -514,7 +514,7 @@ <% @recent_updated.each do |object| %> - <%= link_to ((object[0].title[I18n.locale] rescue nil) || (object[0].page.i18n_variable[I18n.locale] rescue nil)), get_link_to_object(object[0]) %> + <%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %> <%= link_to t("dashboard.#{object[0]._type.underscore}"), get_link(object[0]._type.underscore) %> <% end %> @@ -552,7 +552,7 @@ <% @most_visited.each do |object| %> - <%= link_to ((object[0].title[I18n.locale] rescue nil) || (object[0].page.i18n_variable[I18n.locale] rescue nil)), get_link_to_object(object[0]) %> + <%= link_to ((object[0].title rescue nil) || (object[0].page.title rescue nil)), get_link_to_object(object[0]) %> <%= link_to t("dashboard.#{object[0]._type.underscore}"), get_link(object[0]._type.underscore) %> <%= object[1] %> diff --git a/app/views/admin/infos/_form.html.erb b/app/views/admin/infos/_form.html.erb index 103c7af1..a499784a 100644 --- a/app/views/admin/infos/_form.html.erb +++ b/app/views/admin/infos/_form.html.erb @@ -13,9 +13,9 @@ <%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %> - <%= f.fields_for :i18n_variable, (@attribute.new_record? ? @attribute.build_i18n_variable : @attribute.i18n_variable) do |f| %> + <%= f.fields_for :title_translations do |f| %> <% @site_valid_locales.each do |locale| %> - <%= f.text_field locale, :style => "width:150px" %> + <%= f.text_field locale, :style => "width:150px", :value => (@attribute.title_translations[locale] rescue nil) %> <% end %> <% end %> diff --git a/app/views/admin/links/_form.html.erb b/app/views/admin/links/_form.html.erb index 2f03b968..f1415e98 100644 --- a/app/views/admin/links/_form.html.erb +++ b/app/views/admin/links/_form.html.erb @@ -6,11 +6,11 @@ <%= f.text_field :name, :class => 'text' %>

-<%= f.fields_for :i18n_variable, (@item.new_record? ? @item.build_i18n_variable : @item.i18n_variable) do |f| %> +<%= f.fields_for :title_translations do |f| %> <% @site_valid_locales.each do |locale| %>

<%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}" %> - <%= f.text_field locale %> + <%= f.text_field locale, :value => (@item.title_translations[locale] rescue nil) %>

<% end %> <% end %> diff --git a/app/views/admin/links/_show.html.erb b/app/views/admin/links/_show.html.erb index 33ca0c20..85927a85 100644 --- a/app/views/admin/links/_show.html.erb +++ b/app/views/admin/links/_show.html.erb @@ -7,7 +7,7 @@ <% @site_valid_locales.each do |locale| %>

<%= "#{t('admin.title')} #{locale}" %> - <%= @item.i18n_variable[locale] if @item.i18n_variable %> + <%= @item.title_translations[locale] if @item.title %>

<% end %> diff --git a/app/views/admin/module_apps/reload_frontend_pages.js.erb b/app/views/admin/module_apps/reload_frontend_pages.js.erb index 2fc90b8e..87d3476e 100644 --- a/app/views/admin/module_apps/reload_frontend_pages.js.erb +++ b/app/views/admin/module_apps/reload_frontend_pages.js.erb @@ -1,3 +1,3 @@ $('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', @module_app.app_pages) %>"); -$('#app_page_category').html("<%= j (select 'page', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, {:include_blank => true}) if @categories %>"); +$('#app_page_category').html("<%= j (select 'page', 'category', @categories.collect{|category| [category.title, category.id]}, {:include_blank => true}) if @categories %>"); $('#app_page_tag').html("<%= j (select 'page', 'tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, {:include_blank => true}) if @tags %>"); \ No newline at end of file diff --git a/app/views/admin/page_parts/_module_widget.html.erb b/app/views/admin/page_parts/_module_widget.html.erb index 1a1dd63c..9cf0be33 100644 --- a/app/views/admin/page_parts/_module_widget.html.erb +++ b/app/views/admin/page_parts/_module_widget.html.erb @@ -1,9 +1,9 @@
- <%= f.fields_for :title, @part.title do |f| %> + <%= f.fields_for :title_translations do |f| %> <% @site_valid_locales.each do |locale| %>

<%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}" %> - <%= f.text_field locale %> + <%= f.text_field locale, :value => (@part.title_translations[locale] rescue nil) %>

<% end %> <% end %> diff --git a/app/views/admin/page_parts/_text.html.erb b/app/views/admin/page_parts/_text.html.erb index c7386623..1eb57205 100644 --- a/app/views/admin/page_parts/_text.html.erb +++ b/app/views/admin/page_parts/_text.html.erb @@ -1,8 +1,8 @@ -<%= f.fields_for :i18n_variable, (@part.i18n_variable ? @part.i18n_variable : @part.build_i18n_variable) do |f| %> +<%= f.fields_for :content_translations do |f| %> <% @site_valid_locales.each do |locale| %>
<%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :class => 'tinymce_textarea' %> + <%= f.text_area locale, :class => 'tinymce_textarea', :value => (@part.content_translations[locale] rescue nil) %>
<% end %> <% end %> \ No newline at end of file diff --git a/app/views/admin/page_parts/_widget_categories.html.erb b/app/views/admin/page_parts/_widget_categories.html.erb index 60659036..7db04e3e 100644 --- a/app/views/admin/page_parts/_widget_categories.html.erb +++ b/app/views/admin/page_parts/_widget_categories.html.erb @@ -1 +1 @@ - <%= select 'page_part', 'category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => (@part ? @part[:category] : nil), :include_blank => true if @categories && @categories.size > 0 %> \ No newline at end of file + <%= select 'page_part', 'category', @categories.collect{|category| [category.title, category.id]}, :selected => (@part ? @part[:category] : nil), :include_blank => true if @categories && @categories.size > 0 %> \ No newline at end of file diff --git a/app/views/admin/page_parts/_widget_tags.html.erb b/app/views/admin/page_parts/_widget_tags.html.erb index bb78f118..688ac3cb 100644 --- a/app/views/admin/page_parts/_widget_tags.html.erb +++ b/app/views/admin/page_parts/_widget_tags.html.erb @@ -1 +1 @@ - <%= select 'page_part', 'tag', @tags.collect{|category| [category[I18n.locale], category.id]}, :selected => (@part ? @part[:tag] : nil), :include_blank => true if @tags && @tags.size > 0 %> \ No newline at end of file + <%= select 'page_part', 'tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, :selected => (@part ? @part[:tag] : nil), :include_blank => true if @tags && @tags.size > 0 %> \ No newline at end of file diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index eff3e4df..6822697d 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -9,12 +9,12 @@
-<%= f.fields_for :i18n_variable, (@item.new_record? ? @item.build_i18n_variable : @item.i18n_variable) do |f| %> +<%= f.fields_for :title_translations do |f| %> <% @site_valid_locales.each do |locale| %>
<%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
- <%= f.text_field locale, :class => 'text input-xlarge' %> + <%= f.text_field locale, :class => 'text input-xlarge', :value => (@item.title_translations[locale] rescue nil) %>
@@ -43,7 +43,7 @@ <%= select('page','app_frontend_url', @app_frontend_urls, :selected => @item.app_frontend_url ) rescue ''%> - <%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%> + <%= select('page','category', @categories.collect{|category| [category.title, category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%> <%= select('page','tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, :selected => @item[:tag], :include_blank => true ) rescue ''%> diff --git a/app/views/admin/roles/_form.html.erb b/app/views/admin/roles/_form.html.erb index b744f20c..1dd889cc 100644 --- a/app/views/admin/roles/_form.html.erb +++ b/app/views/admin/roles/_form.html.erb @@ -14,9 +14,9 @@ <%= is_new ? (f.text_field :key, {:style => "width:150px"}) : @attribute.key %> - <%= f.fields_for :i18n_variable, (@attribute.new_record? ? @attribute.build_i18n_variable : @attribute.i18n_variable) do |f| %> + <%= f.fields_for :title_translations do |f| %> <% @site_valid_locales.each do |locale| %> - <%= f.text_field locale, :style => "width:150px" %> + <%= f.text_field locale, :style => "width:150px", :value => (@attribute.title_translations[locale] rescue nil) %> <% end %> <% end %> diff --git a/app/views/admin/roles/_sub_role.html.erb b/app/views/admin/roles/_sub_role.html.erb index ca20890f..d4236dfc 100644 --- a/app/views/admin/roles/_sub_role.html.erb +++ b/app/views/admin/roles/_sub_role.html.erb @@ -11,9 +11,9 @@ <%= sub_role.new_record? ? (f.text_field :key, {:style => "width:150px"}) : sub_role.key %> - <%= f.fields_for :i18n_variable, (sub_role.new_record? ? sub_role.build_i18n_variable : sub_role.i18n_variable) do |f| %> + <%= f.fields_for :title_translations do |f| %> <% @site_valid_locales.each do |locale| %> - <%= f.text_field locale, :style => "width:150px" %> + <%= f.text_field locale, :style => "width:150px", :value => (sub_role.title_translations[locale] rescue nil) %> <% end %> <% end %> diff --git a/app/views/admin/sites/site_info.html.erb b/app/views/admin/sites/site_info.html.erb index e19307ca..4ce99df1 100644 --- a/app/views/admin/sites/site_info.html.erb +++ b/app/views/admin/sites/site_info.html.erb @@ -25,8 +25,8 @@
- <%= f.fields_for :title, @site.title do |f| %> - <%= f.text_field locale, :class => "input-xxlarge" %> + <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, :class => "input-xxlarge", :value => (@site.title_translations[locale] rescue nil) %> <% end %>

<%= (t 'admin.site_title_help').html_safe %>

@@ -38,6 +38,7 @@
+ <% #TODO: set keywords into meta %> <%= f.fields_for :keywords, @site.keywords do |f| %> <%= f.text_area locale, :class => "input-xxlarge textarea-height-s" %> <% end %> @@ -47,8 +48,8 @@
- <%= f.fields_for :description, @site.description do |f| %> - <%= f.text_area locale, :class => "input-xxlarge textarea-height-s" %> + <%= f.fields_for :description_translations do |f| %> + <%= f.text_area locale, :class => "input-xxlarge textarea-height-s", :value => (@site.description_translations[locale] %> <% end %>

<%= (t 'admin.site_description_help').html_safe %>

@@ -56,8 +57,8 @@
- <%= f.fields_for :footer, @site.footer do |f| %> - <%= f.text_area locale, :class => "tinymce_textarea input-xxlarge" %> + <%= f.fields_for :footer_translations do |f| %> + <%= f.text_area locale, :class => "tinymce_textarea input-xxlarge", :value => (@site.footer_translations[locale] %> <% end %>

<%= (t 'admin.site_footer_help').html_safe %>

@@ -65,8 +66,8 @@
- <%= f.fields_for :sub_menu, @site.sub_menu do |f| %> - <%= f.text_area locale, :class => "tinymce_textarea input-xxlarge" %> + <%= f.fields_for :sub_menu_translations do |f| %> + <%= f.text_area locale, :class => "tinymce_textarea input-xxlarge", :value => (@site.sub_menu_translations[locale] %> <% end %>
diff --git a/app/views/admin/users/_form.html.erb b/app/views/admin/users/_form.html.erb index 37ee9d28..c0cb194e 100644 --- a/app/views/admin/users/_form.html.erb +++ b/app/views/admin/users/_form.html.erb @@ -16,7 +16,7 @@
@@ -27,7 +27,7 @@
<% @roles.each do |role| %>