-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: en named route always generated ignoring config.available_locales #305
Comments
Hi, this is caused by the following method: route_translator/lib/route_translator/translator.rb Lines 56 to 63 in 886e69d
This change was introduced in #28, but at the time it was not possible to configure I understand that the current route translator behavior is not expected, but I'm afraid of the consequences of excluding the default locale from the available locales I've tried to add locales = RouteTranslator.available_locales
+ return locales unless locales.include?(I18n.default_locale)
+ and there are two failing specs
The failure is due to the fact that if there isn't a default route, the system does not know how to build a route for something that should be legit. In rails, if I do not put the default locale among available locales I have a got a Since I'm not using this gem in a production environment, a PR with proper tests and a brief analysis of the consequences of removing the default locale from available locales is welcomed |
Ok, thank you for the explanation The simplest in my case is to set the default locale to en-US and config.force_locale = true This then generates the expected routes free_consultation_en_ca GET /en-CA/free-consultation(.:format) www/leads#consultation {:locale=>"en-CA"} However what it misses is the default route name free_consultation_path() which could take a locale as a parameter we're trying to migrate from routing-filter to this gem so we can have route translations as well |
Bug description
Hello, my route_translator.rb is setup as such:
config.available_locales = %i[en-US en-CA]
to handle routes from US or Canadian customers
The problem I have is that route translator is creating the fallback route for everything
e.g in routes.rb
But explicitly, I want it to only generate /en_us and /en_ca. Which I thought would be the case by specifying available_locales.
Note that I have not yet created the routes in locale file since in this case the translation is the same for both locale
Other configurations
Steps to reproduce
create a route inside a localized block in routes.rb
create a list of locales in config.available_locales
run rake routes
Expected behavior
Only generate the routes specified by available_locales regardless of fallbacks
Actual behavior
generates available_locales and fallback locales routes
Reproducible reduced test case
n/a
Ruby version
3.3
Ruby on Rails version
7.0
Route Translator version
14.1.1
I18n configuration
Route Translator configuration
Rails routes source
localized do
get '/free-consultation', to: 'www/leads#consultation'
end
Rails locales
n/a
Rails routes
Bug report checklist
The text was updated successfully, but these errors were encountered: