The i18n locale suddenly stopped working.

Asked 2 years ago, Updated 2 years ago, 75 views

The i18n locale setting suddenly no longer works except in English (en).

I don't know what the kick is, but
http://sampleurl.com/ja
When I open the site as , it doesn't display in Japanese, and all the links to en are only
It says it doesn't come out.

Language files are also
/config/locales
devise.en.yml devise.ja.yml en.yml ja.yml
It is prepared as shown in and currently only en.yml works.

Ruby is 2.3 and Rails is 4.2.3.Ruby has just recently been raised to 2.3.

I don't know where to check, but
The Route file and ApplicationController are as follows:
I haven't made any changes since it was working before.

What is the problem?Is there a place to check here?
Thank you for your cooperation

Rails.application.routes.drawdo

  # The priority is based upon order of creation: first created->highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  # root 'welcome #index'


device_for:users,skip:[:session,:password,:registration],controllers:{omniauth_callbacks:"users/omniauth_callbacks"}


 # Locale Information
scope"(:locale)" , locale: /en | ja /do
   get'/'=>'frontpage#index'
   get'restaurant /'=>'restaurant#index'
   get'restaurant /:id'=>'restaurant#show'
   get'menu/'=>'menu#index'
   get'menu /:id'=>'menu#show'
   get'area/'=>'area#index'
   get'area /:id'=>'area#show'

   resources —reviews

   device_for:users,skip:[:mniauth_callbacks]

end

The following is the Application Controller.

class ApplicationController<ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use: null_session installed.
  protect_from_forgery with: —Exception

  before_action:set_locale,:configure_permitted_parameters, if::device_controller?


  default_locale
    I18n.locale=params[:locale]||I18n.default_locale
  end

  default_url_options(options={})
    { locale —I18n.locale}.merge options
  end

  private
  def configure_permitted_parameters
  device_parameter_sanitizer.for(:sign_up)<<:name
  device_parameter_sanitizer.for(:account_update)<<:name
  end

ruby-on-rails ruby i18n

2022-09-30 19:09

1 Answers

I'm sorry.Selfless.
ApplicationController

before_action:set_locale,:configure_permitted_parameters, if::device_controller?

The problem was that it was written.The problem is that I wrote the i18n and device settings together.

before_action:set_locale

I fixed it only and it worked.


2022-09-30 19:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.