Skip to content
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

[RFC] Hide slug for default locale (in routes/links) #40

Closed
madc opened this issue Jul 21, 2016 · 8 comments
Closed

[RFC] Hide slug for default locale (in routes/links) #40

madc opened this issue Jul 21, 2016 · 8 comments
Assignees

Comments

@madc
Copy link
Contributor

madc commented Jul 21, 2016

Personally, I'm a huge fan of simple URLs. Thats why i propose, that we introduce an option to hide the slug of the default locale. That means, that instead of mysite.com/de and mysite.com/en, we would have mysite.comand mysite.com/en, if german is the default language.

After giving this just a quick thought, I can come up with two ways to solve this (from user perspective):

  • Add an option to the config (i.e. hide_default_slug: [true/false])
  • Allow to set an empty slug for one language in the locales config

What do you thinkt, @SahAssar?

@madc
Copy link
Contributor Author

madc commented Jul 21, 2016

If we think about implementing more URL styles in the future, we could also use one setting to define the URL type, like routing_style: [default/hide_default/domain/...]

@SvanteRichter
Copy link
Contributor

SvanteRichter commented Jul 21, 2016

@madc: My original idea was that the default "automatic" routing would be for users who just wanted to get started without all the configuring, so I made it disableable so that one could do hostname based or other types of routing in the routing.yml file, but if we can implement a routing_style option that works well that'd be great!

The hide_default_slug style is easy to automatically make the actual routing for, but the issue will be to make bolt "get" that the same record should get different link styles based on a parameter bolt basically does not "care about" IIRC.

So, I'm all for this if we can get it to work well :) One thing to take into consideration is that everything we do in many parts basically has to be implemented in both legacy and proper storage since legacy is used on the frontend and proper is used on the backend.

@madc
Copy link
Contributor Author

madc commented Jul 21, 2016

I'm totally with you on that. The default configuration should reflect the usual use case and work right out of the box. Thing is, I'll have to take some time soon to implement this and I'm sure, its interesting for other users too.

I'd suggest to implement the routing_style option, even if it just toggles the default language slug for now. Do you agree?

@SvanteRichter
Copy link
Contributor

SvanteRichter commented Jul 21, 2016

Yeah, routing_style gives us the freedom to add different styles in the future, so that sounds good!

If you have any questions/notes/criticism about/of my code please just throw them out there and I'll answer ASAP :)

@madc
Copy link
Contributor Author

madc commented Jul 21, 2016

Believe me, I'm not the guy holding back on criticism.. .. as for questions, they will come for sure.
I'll touch this thing the week after next one. Meanwhile, if you have any thought on the topic, just throw them in here..

@madc madc self-assigned this Jul 21, 2016
@SvanteRichter SvanteRichter changed the title [RFC] Hide slug for default locale [RFC] Hide slug for default locale (in routes/links) Jul 27, 2016
@madc
Copy link
Contributor Author

madc commented Dec 21, 2016

Just a quick heads up: I'm currently working on this feature here: madc/bolt-translate

@benwallis
Copy link

I think I have this working just by setting my own route. But it's only a very simple single-page site with only one contenttype.

/app/config/routing.yml

# first route
templatebinding:
    path: /{_locale}
    defaults:
        _controller: controller.frontend:template
        template: index
    requirements:
        _locale: '(en|fr|ru)'

# also need the default homepage route
homepage:
    path: / 
    defaults:
        _controller: controller.frontend:homepage

All options in translate.animal.yml are set to false.

@SvanteRichter
Copy link
Contributor

While this is possible with some routing hacks like @benwallis mentioned, I don't think we can do it on a larger scale as long as we do prefix routing. Basically we can't check for the locale when building the routing, so we can't exclude the locale then (sorta a catch-22 problem) and we can't have optional parameters before required ones so we can't make the locale optional since the rest of the route params need to be required. If we did suffix routing like /page/about-us/en instead we could do it, but that looks really ugly and can be done in ones own routing if one prefers.

Closing for now, if we find a way to do it we can reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants