範圍可用的區域設定

如果你的應用程式以不同語言提供,則通常會在 URL 中顯示當前區域設定。

scope '/(:locale)', locale: /#{I18n.available_locales.join('|')}/ do
    root 'example#root'
    # other routes
end

你的 root 可以通過 I18n.available_locales 中定義的語言環境訪問。