From 8c348d4535e72b715733e72aa9dd1ef0ba452ae4 Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 26 Jan 2013 11:11:42 -0600 Subject: [PATCH] localize outfits#edit search helpers --- app/helpers/outfits_helper.rb | 19 +++++++++++++------ app/views/outfits/edit.html.haml | 8 ++------ config/locales/pt.yml | 4 ++-- public/javascripts/outfits/edit.js | 19 +++++++++++++++---- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/app/helpers/outfits_helper.rb b/app/helpers/outfits_helper.rb index 5dd74503..06220510 100644 --- a/app/helpers/outfits_helper.rb +++ b/app/helpers/outfits_helper.rb @@ -25,22 +25,29 @@ module OutfitsHelper link_to content, wardrobe_path(:anchor => query), options end - def search_helper(filter) + def search_helper(filter, standard_key) key = translate("#{filter}.key") default_value = translate("#{filter}.default_value") content_tag :span, default_value, :class => 'search-helper', - 'data-search-filter' => key + 'data-search-filter-key' => standard_key, + 'data-search-filter-name' => key end - def search_query_description(base) + def search_query_description(base, standard_key) translate "#{base}.description_html", - :default_value => search_helper("#{base}.filter") + :default_value => search_helper("#{base}.filter", standard_key) end - def search_query_with_helper(base) + def search_query_with_helper(base, standard_key) translate "#{base}.query_html", :filter_key => content_tag(:span, translate("#{base}.filter.key")), - :filter_value => search_helper("#{base}.filter") + :filter_value => search_helper("#{base}.filter", standard_key) + end + + def search_query(translation_key, filter_key) + base = "outfits.edit.search.examples.#{translation_key}" + content_tag(:dt, search_query_with_helper(base, filter_key)) + + content_tag(:dd, search_query_description(base, filter_key)) end def outfit_creation_summary(outfit) diff --git a/app/views/outfits/edit.html.haml b/app/views/outfits/edit.html.haml index 56d882cf..f0e36d0f 100644 --- a/app/views/outfits/edit.html.haml +++ b/app/views/outfits/edit.html.haml @@ -109,12 +109,8 @@ %div %dt= t '.search.examples.flags.query' %dd= t '.search.examples.flags.description' - %div - %dt= search_query_with_helper '.search.examples.species' - %dd= search_query_description '.search.examples.species' - %div - %dt= search_query_with_helper '.search.examples.type' - %dd= search_query_description '.search.examples.type' + %div= search_query 'species', 'species' + %div= search_query 'type', 'occupies' #preview-search-form-loading= t '.search.loading' #preview-search-form-error.possible-error #preview-search-form-no-results diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 6e032d42..b3c32857 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -202,7 +202,7 @@ pt: query: espécies:shoyru description: mostra qualquer item que um Shoyru pode vestir type: - query: ocupa:chapéu -restringe:cabelo + query: ocupa:chapéus -restringe:cabelo description: 'mostra qualquer item que ocupa a zona do "chapéu", mas não se restringe a zona do "cabelo" ' newest_items: header: Novos itens @@ -462,7 +462,7 @@ pt: type: filter: key: ocupa - default_value: fundo + default_value: fundosdeimagem query_html: "%{filter_key}:%{filter_value}" description_html: 'mostra como resultado qualquer item que ocupe a zona de %{default_value} ' userbar: diff --git a/public/javascripts/outfits/edit.js b/public/javascripts/outfits/edit.js index 39049a5c..281a1cc4 100644 --- a/public/javascripts/outfits/edit.js +++ b/public/javascripts/outfits/edit.js @@ -1260,9 +1260,13 @@ View.Search = function (wardrobe) { function prepBuildHelper(type, getSet) { return function (objs) { - var select = $('', { + 'class': 'search-helper', + 'data-search-filter': filterName + }); + var defaultValue = span.get(0).innerText; objs = getSet(objs); for(var i = 0, l = objs.length; i < l; i++) { $('