-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Globalize OptionType, Taxonomy and Taxon model
Still need to hack around to make it display the localized taxon names on the backend tree. So far localized taxons look good on the frontend
- Loading branch information
Showing
18 changed files
with
338 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ pkg | |
spec/dummy | ||
.rvmrc | ||
.sass-cache | ||
public/spree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Spree | ||
OptionType.class_eval do | ||
translates :name, :presentation | ||
attr_accessible :translations_attributes | ||
accepts_nested_attributes_for :translations | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Spree | ||
Taxon.class_eval do | ||
translates :name, :description, :meta_title, :meta_description, :meta_keywords | ||
attr_accessible :translations_attributes | ||
accepts_nested_attributes_for :translations | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Spree | ||
Taxonomy.class_eval do | ||
translates :name | ||
attr_accessible :translations_attributes | ||
accepts_nested_attributes_for :translations | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
app/overrides/spree/admin/option_types/index/add_translation.html.erb.deface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!-- insert_bottom 'td.actions' --> | ||
<%= link_to '', admin_translations_path('option_types', option_type.id), | ||
class: 'icon_link with-tip icon-flag no-text' %> |
3 changes: 3 additions & 0 deletions
3
app/overrides/spree/admin/taxonomies/_list/add_translations.html.erb.deface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!-- insert_bottom 'td.actions' --> | ||
<%= link_to '', admin_translations_path('taxonomies', taxonomy.id), | ||
class: 'icon_link with-tip icon-flag no-text' %> |
4 changes: 4 additions & 0 deletions
4
app/overrides/spree/admin/taxons/edit/add_translations.html.erb.deface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!-- insert_top 'li' --> | ||
<li> | ||
<%= button_link_to t(:translations), spree.admin_translations_path('taxons', @taxon.id), :icon => 'icon-flag' %> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,83 @@ | ||
<%= form_for [:admin, @resource], :method => :put, :html => { :multipart => true } do |f| %> | ||
<fieldset class="omega eight columns no-border-bottom"> | ||
<legend>Translations</legend> | ||
<table id="attr_fields" class="no-borders"> | ||
<colgroup> | ||
<col style="width: 10%" /> | ||
<col style="width: 90%" /> | ||
</colgroup> | ||
<tbody> | ||
<% Spree::Config.all_locales.each do |locale| %> | ||
<%= f.globalize_fields_for locale.to_sym do |g| %> | ||
<% @resource.class.translates.each_with_index do |attr,i| %> | ||
<tr style="display:<%= i == 0 ? 'auto' : 'none' %>;" class="<%= attr %> <%= locale %> even"> | ||
<td style="padding:4px;" colspan="2"> | ||
<%= t(:this_file_language, :locale => locale) %> - | ||
<%= t(attr, :locale => locale ) %> | ||
</td> | ||
</tr> | ||
<tr style="display:<%= i == 0 ? 'auto' : 'none' %>;" class="<%= attr %> <%= locale %> odd"> | ||
<td class="flag table-column"> | ||
<% if locale.include?('-') %> | ||
<img src="http://www.localeapp.com/assets/flags/regions/<%= locale.split('-').last %>.png"> | ||
<% else %> | ||
<img src="http://www.localeapp.com/assets/flags/languages/<%= locale %>.png"> | ||
<% end %> | ||
</td> | ||
<td class="translation table-column"> | ||
<% if @resource.class.columns_hash[attr.to_s].type == :text %> | ||
<%= g.text_area attr, :class => "fullwidth", :rows => 4 %> | ||
<% else %> | ||
<%= g.text_field attr, :class => "fullwidth" %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
<div class="row"> | ||
<fieldset class="no-border-top"> | ||
<fieldset class="no-border-bottom"> | ||
<legend>Settings</legend> | ||
|
||
<div class="alpha six columns field"> | ||
<label for="show-only">Show only: </label> | ||
<ul> | ||
<li><input type="radio" name="show-only" value="all" checked> <label>All Translations</label></li> | ||
<li><input type="radio" name="show-only" value="incomplete"> <label>Only Incomplete</label></li> | ||
<li><input type="radio" name="show-only"value="complete"> <label>Only Complete</label></li> | ||
</ul> | ||
</div> | ||
|
||
<div class="omega six columns"> | ||
<label for="locale">Select locale: </label> | ||
<%= select_tag(:locale, options_for_select(admin_options_for_locale_select, Spree::Config.all_locales), :class => 'fullwidth' , :multiple => 'true') %> | ||
</div> | ||
</fieldset> | ||
|
||
<fieldset class="alpha four columns no-border-bottom"> | ||
<legend>Fields</legend> | ||
<nav class="menu"> | ||
<ul id="attr_list"> | ||
<% @resource.class.translates.each_with_index do |attr,i| %> | ||
<li class="<%= 'active' if i == 0 %>"> | ||
<a data-attr="<%= attr %>" href="#"><%= attr %></a> | ||
</li> | ||
<% end %> | ||
<% end %> | ||
</tbody> | ||
<tfoot> | ||
<tr style="display:none;"> | ||
<td colspan="2"></td> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
</fieldset> | ||
</ul> | ||
</nav> | ||
</fieldset> | ||
|
||
<%= form_for [:admin, @resource], :method => :put, :html => { :multipart => true } do |f| %> | ||
<fieldset class="omega eight columns no-border-bottom"> | ||
<legend>Translations</legend> | ||
<table id="attr_fields" class="no-borders"> | ||
<colgroup> | ||
<col style="width: 10%" /> | ||
<col style="width: 90%" /> | ||
</colgroup> | ||
<tbody> | ||
<% Spree::Config.all_locales.each do |locale| %> | ||
<%= f.globalize_fields_for locale.to_sym do |g| %> | ||
<% @resource.class.translates.each_with_index do |attr,i| %> | ||
<tr style="display:<%= i == 0 ? 'auto' : 'none' %>;" class="<%= attr %> <%= locale %> even"> | ||
<td style="padding:4px;" colspan="2"> | ||
<%= t(:this_file_language, :locale => locale) %> - | ||
<%= t(attr, :locale => locale ) %> | ||
</td> | ||
</tr> | ||
<tr style="display:<%= i == 0 ? 'auto' : 'none' %>;" class="<%= attr %> <%= locale %> odd"> | ||
<td class="flag table-column"> | ||
<% if locale.include?('-') %> | ||
<img src="http://www.localeapp.com/assets/flags/regions/<%= locale.split('-').last %>.png"> | ||
<% else %> | ||
<img src="http://www.localeapp.com/assets/flags/languages/<%= locale %>.png"> | ||
<% end %> | ||
</td> | ||
<td class="translation table-column"> | ||
<% if @resource.class.columns_hash[attr.to_s].type == :text %> | ||
<%= g.text_area attr, :class => "fullwidth", :rows => 4 %> | ||
<% else %> | ||
<%= g.text_field attr, :class => "fullwidth" %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</tbody> | ||
<tfoot> | ||
<tr style="display:none;"> | ||
<td colspan="2"></td> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
</fieldset> | ||
|
||
<%= render :partial => 'spree/admin/shared/edit_resource_links' %> | ||
<% end %> | ||
<%= render :partial => 'spree/admin/shared/edit_resource_links' %> | ||
<% end %> | ||
</fieldset> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<%= render :partial => 'spree/admin/shared/product_sub_menu' %> | ||
<% content_for :page_title do %> | ||
<%= t(:editing_option_type) %> <span class="green">"<%= @option_type.name %>"</span> | ||
<% end %> | ||
<% content_for :page_actions do %> | ||
<li> | ||
<%= button_link_to t(:back_to_option_types_list), spree.admin_option_types_path, :icon => 'icon-arrow-left' %> | ||
</li> | ||
<% end %> | ||
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @option_type } %> | ||
<%= render 'form' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<%= render :partial => 'spree/admin/shared/configuration_menu' %> | ||
<% content_for :page_title do %> | ||
<%= t(:taxon_edit) %> | ||
<% end %> | ||
<% content_for :page_actions do %> | ||
<li> | ||
<%= button_link_to t(:back_to_taxonomies_list), spree.admin_taxonomies_path, :icon => 'icon-arrow-left' %> | ||
</li> | ||
<% end %> | ||
|
||
<div class="row"> | ||
<fieldset class="no-border-top"> | ||
<fieldset class="no-border-bottom"> | ||
<legend>Settings</legend> | ||
|
||
<div class="alpha six columns field"> | ||
<label for="show-only">Show only: </label> | ||
<ul> | ||
<li><input type="radio" name="show-only" value="all" checked> <label>All Translations</label></li> | ||
<li><input type="radio" name="show-only" value="incomplete"> <label>Only Incomplete</label></li> | ||
<li><input type="radio" name="show-only"value="complete"> <label>Only Complete</label></li> | ||
</ul> | ||
</div> | ||
|
||
<div class="omega six columns"> | ||
<label for="locale">Select locale: </label> | ||
<%= select_tag(:locale, options_for_select(admin_options_for_locale_select, Spree::Config.all_locales), :class => 'fullwidth' , :multiple => 'true') %> | ||
</div> | ||
</fieldset> | ||
|
||
<fieldset class="alpha four columns no-border-bottom"> | ||
<legend>Fields</legend> | ||
<nav class="menu"> | ||
<ul id="attr_list"> | ||
<% @resource.class.translates.each_with_index do |attr,i| %> | ||
<li class="<%= 'active' if i == 0 %>"> | ||
<a data-attr="<%= attr %>" href="#"><%= attr %></a> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</nav> | ||
</fieldset> | ||
|
||
<%= form_for [:admin, @resource.taxonomy, @resource], | ||
:url => admin_taxonomy_taxon_path(@taxon.taxonomy, @taxon.id), | ||
:method => :put, :html => { :multipart => true } do |f| %> | ||
<fieldset class="omega eight columns no-border-bottom"> | ||
<legend>Translations</legend> | ||
<table id="attr_fields" class="no-borders"> | ||
<colgroup> | ||
<col style="width: 10%" /> | ||
<col style="width: 90%" /> | ||
</colgroup> | ||
<tbody> | ||
<% Spree::Config.all_locales.each do |locale| %> | ||
<%= f.globalize_fields_for locale.to_sym do |g| %> | ||
<% @resource.class.translates.each_with_index do |attr,i| %> | ||
<tr style="display:<%= i == 0 ? 'auto' : 'none' %>;" class="<%= attr %> <%= locale %> even"> | ||
<td style="padding:4px;" colspan="2"> | ||
<%= t(:this_file_language, :locale => locale) %> - | ||
<%= t(attr, :locale => locale ) %> | ||
</td> | ||
</tr> | ||
<tr style="display:<%= i == 0 ? 'auto' : 'none' %>;" class="<%= attr %> <%= locale %> odd"> | ||
<td class="flag table-column"> | ||
<% if locale.include?('-') %> | ||
<img src="http://www.localeapp.com/assets/flags/regions/<%= locale.split('-').last %>.png"> | ||
<% else %> | ||
<img src="http://www.localeapp.com/assets/flags/languages/<%= locale %>.png"> | ||
<% end %> | ||
</td> | ||
<td class="translation table-column"> | ||
<% if @resource.class.columns_hash[attr.to_s].type == :text %> | ||
<%= g.text_area attr, :class => "fullwidth", :rows => 4 %> | ||
<% else %> | ||
<%= g.text_field attr, :class => "fullwidth" %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</tbody> | ||
<tfoot> | ||
<tr style="display:none;"> | ||
<td colspan="2"></td> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
</fieldset> | ||
|
||
<div class="form-buttons" data-hook="buttons"> | ||
<%= button t(:update), 'icon-refresh' %> <%= t(:or) %> <%= button_link_to t(:cancel), edit_admin_taxonomy_url(@taxon.taxonomy), :icon => "icon-remove" %> | ||
</div> | ||
<% end %> | ||
</fieldset> | ||
</div> |
Oops, something went wrong.