locale-route
locale-route copied to clipboard
Translate url parameters process: direct and back, readme paragraph
Description
This feature provides translation of url parameters – direct and back – for retrieving URLs with translated parameters and passing them back to controllers.
In direct way, url constructor checks if there are some parameters to translate and makes necessary replacements. So when we call locale-route helper and pass origin_param_value
for route /path/{param}
, user gets translated url like /path/translated_param_value
.
In back way, middleware processes translated parameters and passes origin values to the corresponding controller, so it receives origin_param_value
for param
parameter.
Motivation and context
We pass numeric parameters in URLs (ids of objects for instance), but sometimes we have strings here, for e.g. sign up and sign in pages with different user types (/register/user
, /register/admin
, etc ), so it should be nice to keep the whole url in the same language instead of mixing languages like /regístrate/user
.
How has this been tested?
I add functional test for helper function locale_route
to check how it returns translated parameters
Types of changes
What types of changes does your code introduce? Put an x
in all the boxes that apply:
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
Go over all the following points, and put an x
in all the boxes that apply.
Please, please, please, don't send your pull request until all of the boxes are ticked.
- [x] I have read the CONTRIBUTING document.
- [x] My pull request addresses exactly one patch/feature.
- [x] I have created a branch for this patch/feature.
- [x] Each individual commit in the pull request is meaningful.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] If my change requires a change to the documentation, I have updated it accordingly.
- [x] My code follows the code style of this project.
If you're unsure about any of these, don't hesitate to ask. We're here to help!
Thanks! Let me check this in a few days. Sorry for the long wait, I just moved to a new apartment and there were holidays...
So, congratulations with relocation, new year and first release of this package)