Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

I18N_SCOPES => I18n::SCOPES

  • Loading branch information...
commit f22b7a120b0ef33bf39215ded78fa4f66e94fd7c 1 parent 616c42a
@grimen grimen authored committed
Showing with 11 additions and 6 deletions.
  1. +1 −5 lib/formtastic.rb
  2. +6 −1 lib/formtastic/i18n.rb
  3. +4 −0 spec/i18n_spec.rb
View
6 lib/formtastic.rb
@@ -27,10 +27,6 @@ class SemanticFormBuilder < ActionView::Helpers::FormBuilder
INLINE_ERROR_TYPES = [:sentence, :list, :first]
- I18N_SCOPES = [ '{{model}}.{{action}}.{{attribute}}',
- '{{model}}.{{attribute}}',
- '{{attribute}}']
-
attr_accessor :template
# Returns a suitable form input for the given +method+, using the database column information
@@ -1383,7 +1379,7 @@ def localized_string(key, value, type, options = {})
action_name = template.params[:action].to_s rescue ''
attribute_name = key.to_s
- defaults = I18N_SCOPES.collect do |i18n_scope|
+ defaults = ::Formtastic::I18n::SCOPES.collect do |i18n_scope|
i18n_path = i18n_scope.dup
i18n_path.gsub!('{{action}}', action_name)
i18n_path.gsub!('{{model}}', model_name)
View
7 lib/formtastic/i18n.rb
@@ -9,7 +9,12 @@ module I18n
:create => 'Create {{model}}',
:update => 'Update {{model}}'
}.freeze
-
+ SCOPES = [
+ '{{model}}.{{action}}.{{attribute}}',
+ '{{model}}.{{attribute}}',
+ '{{attribute}}'
+ ]
+
class << self
def translate(*args)
View
4 spec/i18n_spec.rb
@@ -106,6 +106,10 @@
::Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false
end
+ it "lookup scopes should be defined" do
+ lambda { ::Formtastic::I18n::SCOPES }.should_not raise_error(::NameError)
+ end
+
it "should be able to translate with namespaced object" do
semantic_form_for(@new_post) do |builder|
concat(builder.input(:title))
Please sign in to comment.
Something went wrong with that request. Please try again.