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

How to add language to URL? #2

Open
smlbiobot opened this issue Apr 24, 2018 · 2 comments
Open

How to add language to URL? #2

smlbiobot opened this issue Apr 24, 2018 · 2 comments

Comments

@smlbiobot
Copy link

Right now I can switch language using the same URL but if I want to say use /zh/path to serve /path in Chinese, I don't quite know how I would achieve that.

Any help would be greatly appreciated!

@lixxu
Copy link
Owner

lixxu commented Apr 25, 2018

try to save language code in session when accessing /zh/path then /path can get language from session?

@smlbiobot
Copy link
Author

I am already saving language code in session — what I want to achieve is allowing /zh/path to always points to /path under the hood — I can’t figure out how I might do that without writing every single route out — and on my website that is a lot of paths.

Flasks have something like this: http://flask.pocoo.org/docs/0.12/patterns/urlprocessors/

So right now with the session, I am able to switch session but they all point to /path (because the language is in the session). And what I need is be able to depending on session point to /zh/path but have the language stay on that path. So for example, say in the HTML I point to /pathA if I am in Spanish mode, that it auto point to /es/pathA and fetch what is normally in /pathA.

If it helps, this is my current site: http://royaleapi.com — and the language is switched from the top right language selector. You will see that the same path serves all the different languages but it confuses the search engines.

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

No branches or pull requests

2 participants