From c8b20e99fa9f53fc2ec9715bae3c5a540f2e64dd Mon Sep 17 00:00:00 2001 From: Trygve Date: Fri, 22 Apr 2022 03:12:32 +0200 Subject: [PATCH 1/4] oversatt story form --- .idea/Rorbua.iml | 206 +++++++++--------- app/controllers/application_controller.rb | 5 +- app/controllers/languages_controller.rb | 8 +- app/views/languages/_form.html.erb | 18 -- app/views/layouts/_language_selector.html.erb | 9 +- app/views/layouts/_navbar.html.erb | 2 +- app/views/stories/_form.html.erb | 4 +- config/initializers/i18.rb | 1 - config/locales/en.yml | 3 + config/locales/nb.yml | 4 + config/routes.rb | 30 ++- 11 files changed, 139 insertions(+), 151 deletions(-) delete mode 100644 app/views/languages/_form.html.erb delete mode 100644 config/initializers/i18.rb diff --git a/.idea/Rorbua.iml b/.idea/Rorbua.iml index 1a5d709..99e9ac2 100644 --- a/.idea/Rorbua.iml +++ b/.idea/Rorbua.iml @@ -26,113 +26,113 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9410e90..a659228 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,6 @@ class ApplicationController < ActionController::Base before_action :configure_permitted_parameters, if: :devise_controller? - #before_action :set_locale + before_action :set_locale protected @@ -11,8 +11,7 @@ class ApplicationController < ActionController::Base end def set_locale - I18n.locale = params[:locale] || session[:locale] || I18n.default_locale - session[:locale] = I18n.locale + I18n.locale = session[:locale] || I18n.default_locale end def after_sign_up_path_for(resource) diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb index e32e62c..5d40626 100644 --- a/app/controllers/languages_controller.rb +++ b/app/controllers/languages_controller.rb @@ -1,18 +1,12 @@ class LanguagesController < ApplicationController - before_action :set_language, only: %i[ show edit update destroy ] # POST /languages or /languages.json def change - puts "CCCCCCCCCCCCCCCCCCCCC #{params[:set_locale]}" - session[:locale] = I18n.locale = params[:set_locale] + session[:locale] = I18n.locale = params[:locale] redirect_back(fallback_location: root_path) end private - # Use callbacks to share common setup or constraints between actions. - def set_language - @language = Language.find(params[:id]) - end # Only allow a list of trusted parameters through. def language_params diff --git a/app/views/languages/_form.html.erb b/app/views/languages/_form.html.erb deleted file mode 100644 index bdb12d2..0000000 --- a/app/views/languages/_form.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<%= form_with(model: language) do |form| %> - <% if language.errors.any? %> -
-

<%= pluralize(language.errors.count, "error") %> prohibited this language from being saved:

- -
    - <% language.errors.each do |error| %> -
  • <%= error.full_message %>
  • - <% end %> -
-
- <% end %> - -
- <%= form.text_field :name, style: "width: 100px" %> - <%= form.submit "Set language "%> -
-<% end %> diff --git a/app/views/layouts/_language_selector.html.erb b/app/views/layouts/_language_selector.html.erb index c719a75..2463f6d 100644 --- a/app/views/layouts/_language_selector.html.erb +++ b/app/views/layouts/_language_selector.html.erb @@ -1,7 +1,6 @@ - - diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb index 737cdbb..e968420 100644 --- a/app/views/layouts/_navbar.html.erb +++ b/app/views/layouts/_navbar.html.erb @@ -8,7 +8,7 @@