Use a helper with yield Globalize.with_locale
A helper has been created to encapsule the logic of Globalize.with_locale. Now, to call that function, globalize(locale) do is called.
This commit is contained in:
@@ -42,4 +42,10 @@ module GlobalizeHelper
|
|||||||
locale.to_s.downcase.underscore.to_sym
|
locale.to_s.downcase.underscore.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def globalize(locale, &block)
|
||||||
|
Globalize.with_locale(locale) do
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<%= f.label :description, t("admin.milestones.new.description") %>
|
<%= f.label :description, t("admin.milestones.new.description") %>
|
||||||
<% @milestone.globalize_locales.each do |locale| %>
|
<% @milestone.globalize_locales.each do |locale| %>
|
||||||
<%= hidden_field_tag "delete_translations[#{locale}]", 0 %>
|
<%= hidden_field_tag "delete_translations[#{locale}]", 0 %>
|
||||||
<% Globalize.with_locale(locale) do %>
|
<% globalize(locale) do %>
|
||||||
<%= f.text_area "description_#{locale}", rows: 5,
|
<%= f.text_area "description_#{locale}", rows: 5,
|
||||||
class: "js-globalize-attribute",
|
class: "js-globalize-attribute",
|
||||||
data: { locale: locale },
|
data: { locale: locale },
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
class: "margin",
|
class: "margin",
|
||||||
id: "image_#{milestone.id}" }) if milestone.image.present? %>
|
id: "image_#{milestone.id}" }) if milestone.image.present? %>
|
||||||
<p>
|
<p>
|
||||||
<% Globalize.with_locale(neutral_locale(locale)) do %>
|
<% globalize(neutral_locale(locale)) do %>
|
||||||
<%= text_with_links milestone.description %>
|
<%= text_with_links milestone.description %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<% Globalize.with_locale(neutral_locale(locale)) do %>
|
<% globalize(neutral_locale(locale)) do %>
|
||||||
<%= text_with_links milestone.description %>
|
<%= text_with_links milestone.description %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user