Skip to content

Commit

Permalink
don't allow to delete default locale translations
Browse files Browse the repository at this point in the history
  • Loading branch information
jiongye committed Jun 1, 2012
1 parent 886e86f commit eea654f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions app/controllers/dynamic_copy/locales_controller.rb
Expand Up @@ -42,9 +42,13 @@ def update

def destroy
locale = params[:id]
DynamicCopy.delete_locale(locale)
DynamicCopy.database.save
redirect_to locales_path, :notice => "All translations for locale #{locale} has been deleted."

# should not allow to delete default locale
unless locale == I18n.default_locale.to_s
DynamicCopy.delete_locale(locale)
DynamicCopy.database.save
redirect_to locales_path, :notice => "All translations for locale #{locale} has been deleted."
end
end

end
Expand Down
5 changes: 4 additions & 1 deletion app/views/dynamic_copy/locales/index.html.haml
Expand Up @@ -18,7 +18,10 @@
%td
= DynamicCopy.locale_names[locale]
%td
= link_to 'Delete', locale_path(:id => locale), :method => :delete, :confirm => "All translations for this locale will be deleted, Are you sure?"
- if locale != I18n.default_locale.to_s
= link_to 'Delete', locale_path(:id => locale), :method => :delete, :confirm => "All translations for this locale will be deleted, Are you sure?"
- else
default locale

%p
= link_to 'Create New Locale', new_locale_path

0 comments on commit eea654f

Please sign in to comment.