diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-25 03:51:44 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-25 03:51:44 +0200 |
| commit | baace1fa5df46694ddd515dc3bbca59b22df8692 (patch) | |
| tree | 6a8b587ca5d6d38377fe132b02c857f1c4149231 /app/controllers/page_translations_controller.rb | |
| parent | ed32bc6902ab634451539770bcd910662212e01a (diff) | |
Extract flashes to i18n and stop dispatching on submit labels
Diffstat (limited to 'app/controllers/page_translations_controller.rb')
| -rw-r--r-- | app/controllers/page_translations_controller.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/app/controllers/page_translations_controller.rb b/app/controllers/page_translations_controller.rb index 38a7c4f9..e5ca57e0 100644 --- a/app/controllers/page_translations_controller.rb +++ b/app/controllers/page_translations_controller.rb | |||
| @@ -16,14 +16,14 @@ class PageTranslationsController < ApplicationController | |||
| 16 | @page = @node.draft || @node.head | 16 | @page = @node.draft || @node.head |
| 17 | @translation = @page.translations.find_by(:locale => @locale) | 17 | @translation = @page.translations.find_by(:locale => @locale) |
| 18 | rescue LockedByAnotherUser => e | 18 | rescue LockedByAnotherUser => e |
| 19 | flash[:error] = e.message | 19 | flash[:error] = t("flash.common.locked_by_other") |
| 20 | redirect_to node_path(@node) | 20 | redirect_to node_path(@node) |
| 21 | end | 21 | end |
| 22 | 22 | ||
| 23 | def update | 23 | def update |
| 24 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } | 24 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } |
| 25 | @node.save_draft!(current_user) | 25 | @node.save_draft!(current_user) |
| 26 | flash[:notice] = "#{@locale.upcase} translation saved. Publish the draft to make it live." | 26 | flash[:notice] = t("flash.page_translations.saved", :lang => @locale.upcase) |
| 27 | 27 | ||
| 28 | if params[:commit] == "Save + Unlock + Exit" | 28 | if params[:commit] == "Save + Unlock + Exit" |
| 29 | @node.unlock! | 29 | @node.unlock! |
| @@ -32,7 +32,7 @@ class PageTranslationsController < ApplicationController | |||
| 32 | redirect_to edit_node_translation_path(@node, @locale) | 32 | redirect_to edit_node_translation_path(@node, @locale) |
| 33 | end | 33 | end |
| 34 | rescue LockedByAnotherUser => e | 34 | rescue LockedByAnotherUser => e |
| 35 | flash[:error] = e.message | 35 | flash[:error] = t("flash.common.locked_by_other") |
| 36 | redirect_to node_path(@node) | 36 | redirect_to node_path(@node) |
| 37 | end | 37 | end |
| 38 | 38 | ||
| @@ -40,7 +40,7 @@ class PageTranslationsController < ApplicationController | |||
| 40 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } | 40 | Globalize.with_locale(@locale) { @node.autosave!(translation_params, current_user) } |
| 41 | head :ok | 41 | head :ok |
| 42 | rescue LockedByAnotherUser => e | 42 | rescue LockedByAnotherUser => e |
| 43 | render plain: e.message, status: :locked | 43 | render plain: t("flash.common.locked_by_other"), status: :locked |
| 44 | rescue ActiveRecord::RecordInvalid => e | 44 | rescue ActiveRecord::RecordInvalid => e |
| 45 | render plain: e.message, status: :unprocessable_entity | 45 | render plain: e.message, status: :unprocessable_entity |
| 46 | rescue StandardError => e | 46 | rescue StandardError => e |
| @@ -50,12 +50,12 @@ class PageTranslationsController < ApplicationController | |||
| 50 | def destroy | 50 | def destroy |
| 51 | base = @node.draft || @node.head | 51 | base = @node.draft || @node.head |
| 52 | unless base && base.translated_locales.include?(@locale) | 52 | unless base && base.translated_locales.include?(@locale) |
| 53 | flash[:error] = "No #{@locale.to_s.upcase} translation exists to remove." | 53 | flash[:error] = t("flash.page_translations.none_to_remove", :lang => @locale.to_s.upcase) |
| 54 | return redirect_to node_path(@node) | 54 | return redirect_to node_path(@node) |
| 55 | end | 55 | end |
| 56 | 56 | ||
| 57 | if (base.translated_locales - [@locale]).empty? | 57 | if (base.translated_locales - [@locale]).empty? |
| 58 | flash[:error] = "Can't remove the only remaining translation." | 58 | flash[:error] = t("flash.page_translations.last_translation") |
| 59 | return redirect_to node_path(@node) | 59 | return redirect_to node_path(@node) |
| 60 | end | 60 | end |
| 61 | 61 | ||
| @@ -63,7 +63,7 @@ class PageTranslationsController < ApplicationController | |||
| 63 | draft.translations.where(:locale => @locale).delete_all | 63 | draft.translations.where(:locale => @locale).delete_all |
| 64 | draft.reload | 64 | draft.reload |
| 65 | 65 | ||
| 66 | flash[:notice] = "#{@locale.upcase} translation removed from the draft. Publish to make this permanent." | 66 | flash[:notice] = t("flash.page_translations.removed", :lang => @locale.upcase) |
| 67 | redirect_to node_path(@node) | 67 | redirect_to node_path(@node) |
| 68 | rescue LockedByAnotherUser => e | 68 | rescue LockedByAnotherUser => e |
| 69 | flash[:error] = e.message | 69 | flash[:error] = e.message |
