diff --git a/app/views/layouts/_javascript.rhtml b/app/views/layouts/_javascript.rhtml
index 65ee210..7c5578a 100644
--- a/app/views/layouts/_javascript.rhtml
+++ b/app/views/layouts/_javascript.rhtml
@@ -1,3 +1,8 @@
<%= javascript_include_tag :defaults, 'jquery-latest.js', 'jquery.noconflict.js', 'jquery.cycle.all.min.js', 'thickbox.js', 'lightbox', 'jquery-ui-1.8.2.custom.min', 'jquery.scrollTo', 'jquery.form.js', 'jquery.cookie', 'reflection', 'add-and-join', 'jquery.tokeninput', 'report-abuse','colorbox', 'jquery-validation/jquery.validate', 'catalog', 'manage-products', :cache => 'cache-general' %>
+
<% language = FastGettext.locale %>
-<%= javascript_include_tag 'jquery-validation/localization/messages_'+language, 'jquery-validation/localization/methods_'+language %>
+<% %w{messages methods}.each do |type| %>
+ <% require_path = File.join('jquery-validation', 'localization', type+'_'+language) %>
+ <% full_path = File.join(Rails.root, 'public', 'javascripts', require_path+'.js')%>
+ <%= javascript_include_tag require_path if File.exists?(full_path) %>
+<% end %>
diff --git a/test/functional/application_controller_test.rb b/test/functional/application_controller_test.rb
index 508ff8c..b1cc3c7 100644
--- a/test/functional/application_controller_test.rb
+++ b/test/functional/application_controller_test.rb
@@ -438,6 +438,13 @@ class ApplicationControllerTest < ActionController::TestCase
assert_tag :tag => 'style', :content => 'This is Plugin2 speaking!'
end
+ should 'not include jquery-validation language script if they do not exist' do
+ Noosfero.stubs(:available_locales).returns(['bli'])
+ get :index, :lang => 'bli'
+ assert_no_tag :tag => 'script', :attributes => {:src => /messages_bli/}
+ assert_no_tag :tag => 'script', :attributes => {:src => /methods_bli/}
+ end
+
if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
should 'change postgresql schema' do
--
libgit2 0.21.2