It seems to me that I missed something very simple, and I continue to spin my wheels on this issue.
Currently, my program is running internationalization. Translation work and routes work great. At least most of the site works, with the exception of the routes to my two static pages, my About and FAQ pages.
Every other link in the application points to the correct localized route. For example, if I choose "French" as my language, the links point to the corresponding "(/:locale)/controller(.:format)". However, despite the changes that I made in the application, my links for "O" and "FAQ" do not point to "../fr/static/about" and always point to "/ static / about."
To change the situation when I run rake routes, I see: "GET (/:locale)/static/:permalink(.:format) of the page # show {: locale => / en | fr /}"
and when I manually type "../fr/static/about", the page translates perfectly.
My routes file:
devise_for :users scope "(:locale)", :locale => /en|fr/ do get 'static/:permalink', :controller => 'pages', :action => 'show' resources :places, only: [:index, :show, :destroy] resources :homes, only: [:index, :show] match '/:locale' => 'places#index' get '/'=>'places#index',:as=>"root" end
My ApplicationController:
before_filter :set_locale def set_locale I18n.locale=params[:locale]||I18n.default_locale end def default_url_options(options={}) logger.debug "default_url_options is passed options: #{options.inspect}\n" { :locale => I18n.locale } end
and My Pages Controller:
class PagesController < ApplicationController before_filter :validate_page PAGES = ['about_us', 'faq'] def show render params[:permalink] end def validate_page redirect_to :status => 404 unless PAGES.include?(params[:permalink]) end end
I would be very grateful for any help ... it was only one of those days.
Edit: Thanks Terry for turning on the submissions.
<div class="container-fluid nav-collapse"> <ul class="nav"> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= t(:'navbar.about') %><b class="caret"></b></a> <ul class="dropdown-menu"> <li><%=link_to t(:'navbar.about_us'), "/static/about_us"%></li> <li><%=link_to t(:'navbar.faq'), "/static/faq"%></li> <li><%=link_to t(:'navbar.blog'), '#' %></li> </ul> </li>