Comments (4)
It looks like it's translating city to ville... Will take a look later. Thanks for the info
from route_translator.
hi,
after few hours of research, I found difference between 2.0.1 and 3.0.1
on 2.0.1
translations_for method return [route.app, conditions, requirements, defaults, new_name] where
requirements = { :city_id => /\d+/, :category_id => /\d+/, :user_id => /\d+/, :subcategory_id => /\d+/, :prefixid => /[A-Z]{3}/, :controller=>"annonces", :action=>"index"}
and
conditions = {:path_info=>"/fr/(:userslug(-:user_id)/)...', :request_method=>/^GET$/}
but on 3.0.1
translations_for method call add_route on [app, new_conditions, new_requirements, new_defaults, new_route_name, anchor] where
new_requirements = { :city_id => /\d+/, :category_id => /\d+/, :user_id => /\d+/, :subcategory_id => /\d+/, :prefixid => /[A-Z]{3}/, :controller=>"annonces", :action=>"index"}
and
new_conditions = { :city_id => /\d+/, :category_id => /\d+/, :user_id => /\d+/, :subcategory_id => /\d+/, :prefixid => /[A-Z]{3}/, :controller=>"annonces", :action=>"index", :path_info=>"/fr/(:userslug(-:user_id)/)...', :request_method=>/^GET$/}
so if I just change condition and remove all what is already in new_requirements (ie I just keep conditions = {:path_info=>"/fr/(:userslug(-:user_id)/)...', :request_method=>/^GET$/}) then it is working fine.
it seems it is
mapping = Mapping.new(@set, @scope, path, options)
app, conditions, requirements, defaults, as, anchor = mapping.to_route
which is giving this values to conditions. So is that me who is doing something bad ? is it normal to have this contraints in conditions ?
because when such, It is bugging on journey
routes.sort_by(&:precedence).find_all { |r|
133 r.constraints.all? { |k,v| v === req.send(k) } &&
134 r.verb === req.request_method
135 }
saying that req.send(k) is incorrect as "undefined method `city_id' for #ActionDispatch::Request:0x00000006041ec8"
any idea ?
thanks
from route_translator.
I'm sorry but I didn't quite get your question. I suggest that next time you report and issue like this you wrap your code with ```
Although what happened with city and ville was partly my fault because I think I made a mistake when adding unscoped fallbacs in translations. I've deleted that in version 3.1.0 of the gem
I did a quick test with this in config/routes.rb
:
RouteTranslator32TestApp::Application.routes.draw do
localized do
get 'products_path', {
controller: 'products',
action: 'index',
constraints: {
city_id: /\d+/,
category_id: /\d+/,
user_id: /\d+/,
subcategory_id: /\d+/,
prefixid: /[A-Z]{3}/
},
as: :products
}
end
end
config/locales/all.yml
fr:
routes:
products_path: "(:userslug(-:user_id)/)articles(/:categoryslug-:rubrique_id(/:subcategoryslug-:subcategory_id))(/:cityslug-_:city_id)(/:productslug-:prefixid:id)(/:action)"
Then I tried running rake routes
and the output it showed me was:
products_en GET /products_path(.:format) products#index {:city_id=>/\d+/, :category_id=>/\d+/, :user_id=>/\d+/, :subcategory_id=>/\d+/, :prefixid=>/[A-Z]{3}/, :locale=>"en"}
products_fr GET /fr/(:userslug(-:user_id)/)articles(/:categoryslug-:rubrique_id(/:subcategoryslug-:subcategory_id))(/:cityslug-_:city_id)(/:productslug-:prefixid:id)(/:action)(.:format) products#index {:city_id=>/\d+/, :category_id=>/\d+/, :user_id=>/\d+/, :subcategory_id=>/\d+/, :prefixid=>/[A-Z]{3}/, :locale=>"fr"}
So I guess it works
Although I will give you one bit of advice regarding the route structure that you chose and adding it to the translation value: Don't do that.
It's hard to read, hard to spot mistakes in it, and adds no value. You're way better of defining your route with namespaces or scopes like its shown in the guides
from route_translator.
Hi,
I know it is not best solution, but it was just the most easy for me and actually the only one that fullfill all my requirements.
I put new version of route translator, but I still have the same easy and need to easy my little patch to make it work.
And I have another kind of issue. Im using nginx, and I have to make their a rewrite and I dont know why but for utf8 characters, it rewrite it lowercased
here is a route : /ka/განცხადებები
/ka/%E1%83%92%E1%83%90%E1%83%9C%E1%83%AA%E1%83%AE%E1%83%90%E1%83%93%E1%83%94%E1%83%91%E1%83%94%E1%83%91%E1%83%98/
become
/ka/%e1%83%92%e1%83%90%e1%83%9c%e1%83%aa%e1%83%ae%e1%83%90%e1%83%93%e1%83%94%e1%83%91%e1%83%94%e1%83%91%e1%83%98
ie all uppercase letter become lowercase, that cause à pb with my rails app.
and because of this, my route are not recognized. if I changed just this and have other uft8 letters (lowercased also) in params, rails can convert and handle them normally.
Just routes are not recognized, ie %E1%83%92%E1%83%90%E1%83%9C%E1%83%AA%E1%83%AE%E1%83%90%E1%83%93%E1%83%94%E1%83%91%E1%83%94%E1%83%91%E1%83%98
is different than
%e1%83%92%e1%83%90%e1%83%9c%e1%83%aa%e1%83%ae%e1%83%90%e1%83%93%e1%83%94%e1%83%91%e1%83%94%e1%83%91%e1%83%98
whereas it should be equal as it is
განცხადებები
do u know what could be the reason ?
thanks
from route_translator.
Related Issues (20)
- 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 5
- 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
- Bug: en named route always generated ignoring config.available_locales HOT 2
- Translating scopes HOT 1
- Bug: unlocalized path name doesn't include locale HOT 3
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.