Skip to content

Instantly share code, notes, and snippets.

@karmi
Created November 25, 2008 16:39
Show Gist options
  • Select an option

  • Save karmi/28974 to your computer and use it in GitHub Desktop.

Select an option

Save karmi/28974 to your computer and use it in GitHub Desktop.
locales = ["cz", "en"]
%w{name name_cz name_is_long name_is_long_cz name123_cz name_en name_ane name_es}.each do |attribute_name|
if includes_locale = locales.find { |locale| attribute_name =~ Regexp.new("_#{locale}$") }
puts includes_locale.inspect
puts attribute_name + ' : true'
puts "Attribute name without locale is " + attribute_name.sub( Regexp.new("(\w*)_#{includes_locale}$"), '\1' )
puts "---"
else
puts attribute_name + ' : false'
puts "---"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment