I am trying to configure a routing system for my rails application, which allows me to specify an additional route (/: locale) for the site base.
So more or less:
/ ru / home / will go to the same page as / home / / ru / people / -> / people /
The only problem I encountered is setting this option in route configurations.
Use scope '(:locale)' do ... end . Here you can see an example from Agile Web Development with Rails :
scope '(:locale)' do
end
http://intertwingly.net/projects/AWDwR4/checkdepot-30/section-15.1.html
What I usually do in config/routes.rb :
config/routes.rb
MyApp::Application.routes.draw do scope "(:locale)", :locale => /en|fr/ do #here only two languages are accepted: english and french end end
And in my ApplicationController :
ApplicationController
before_filter :set_locale def set_locale I18n.locale = params[:locale] || "en" end
Source: https://habr.com/ru/post/892401/More articles:Find degrees (0-360ΒΊ) of a point on a circle - svgThe variable before or after the value in the IF expression - operatorsHow to get the "last sync" time for an account? - androidHow to represent time intervals in a schedule - javaHow to catch the event of a return to activity after a strike - javaCXF Client Security - cxfUnderstanding the code: Hash, grep for duplicates (modified to check for multiple elements) - perlSleep flow boost for several nanoseconds - c ++What are the general rules for comparing different data types in C? - cC, design: deleting global objects - cAll Articles