fizyk / pyramid_localize

Package to provide translation methods for pyramid, and means to reload translations without stopping the application
MIT License
4 stars 3 forks source link

Path-aware language negotiator #37

Open miohtama opened 7 years ago

miohtama commented 7 years ago

It is common pattern to carry the content language in URL as /en/foobar style path. This strategy is recommended by search engines. This might make sense to be included in pyramid_localize, so I am opening the discussion here.

Here is a preliminary gist if one wants to try out this: https://gist.github.com/miohtama/b93fd1ab11353f86e2da2b484d761358

fizyk commented 7 years ago

@miohtama http://pyramid-localize.readthedocs.io/en/latest/advanced.html#localized-urls would this help?

I'm aware though, it could be much better documented

k4ml commented 2 years ago

Can you give specific example of this:-

and your routes, you wish to localise should include a LOCALE parameter.

Is it something like this:-

config.add_route("frontend.dashboard", "/", _LOCALE_="en")

But this will give error Unknown predicate values: {'LOCALE': 'en'} (did you mean ). And what if the route need to support more than one locale? Call add_route() multiple times with different locale?

fizyk commented 1 year ago

no, not the add_route, the path has to be able to understand it, but you need to create the localized uri for your application.

So it's more like request.route_url("path", _LOCALE_="en")