Comments (2)
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 available_locales
specific to route translator
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
Error:
TranslateRoutesTest#test_path_helper_arguments_fallback:
NoMethodError: undefined method `product_it_path' for module #<Module:0x0000000126c424e0>
bin/rails test /Users/geremia/dev/route_translator/test/routing_test.rb:543
Error:
TranslateRoutesTest#test_path_helper_arguments_fallback_with_hosts:
NoMethodError: undefined method `product_it_path' for module #<Module:0x00000001269efaa8>
bin/rails test /Users/geremia/dev/route_translator/test/routing_test.rb:559
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 I18n::InvalidLocale
error when using I18n.t
without arguments
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
from route_translator.
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"}
free_consultation_en_us GET /en-US/free-consultation(.:format) www/leads#consultation {:locale=>"en-US"}
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
from route_translator.
Related Issues (20)
- disable_fallback not working when I18n.fallbacks is configured HOT 7
- Routes not found error after upgrading to Rails 6.0 from Rails 5.1 HOT 4
- Transfer ownership HOT 1
- Two routes for same locale HOT 1
- Unable to translate routes with custom param HOT 7
- Advice Request: route_translator & Accept-Language request header HOT 4
- Missing translated routes in development after routes_reloader.reload! HOT 6
- Require MFA to publish gems HOT 1
- Bump version rubygems for Rails 7 support HOT 1
- Feature request: custom translation for nested resources HOT 5
- How to translate with dynamic root url HOT 1
- RSpec: cannot call non-localized routes name HOT 4
- Optional route params not included in translated URL HOT 2
- Idea pitch: Generate only unique routes and use I18n.fallbacks to generate as little routes as needed HOT 1
- Question: "/" path locale always English HOT 7
- Issue with partial implementation of route_translator HOT 3
- locale path segment not added to translated route (multiple languages on the same host with host locale translation enabled) HOT 3
- undefined method `eager_load!' for RouteTranslator:Module (NoMethodError) HOT 8
- [Question] Translating scopes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from route_translator.