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

[Fix] Make the redirectToEnglishUrl behaves properly for local debugging #1715

Merged
merged 1 commit into from Jul 6, 2018
Merged

[Fix] Make the redirectToEnglishUrl behaves properly for local debugging #1715

merged 1 commit into from Jul 6, 2018

Conversation

ghost
Copy link

@ghost ghost commented Jul 1, 2018

@fhemberger

According to the normal webside, we have 4 kinds of url forms:

  1. https://localhost:8080/: Access the route, the default lang is en.
  2. https://localhost:8080/zh-cn/docs/: If we don't have the proper
    translations, just direct you to en.
  3. https://localhost:8080/zh-nc/docs/: If we have a wrong language spelling, 404 will
    be returned.
  4. https://localhost:8080/blog: When directly accessing a folder, just add en
    as the default lang (converted to https://localhost:8080/en/blog).

For other page routes, 404 will be redirected to you.

So the original codes don't meet all these cases. (e.g: https://localhost:8080/zh-cn/docs/, if you don't have doc translated files or folders, this will return you 404 instead of returning you a default en page).

But according to the comment, it SHOULD return you a default en doc files:)

Here's the fix for that.

Copy link
Contributor

@marswong marswong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

server.js Outdated
@@ -35,27 +35,32 @@ const locales = chokidar.watch(path.join(__dirname, 'locale'), opts)
const layouts = chokidar.watch(path.join(__dirname, 'layouts'), opts)
const statics = chokidar.watch(path.join(__dirname, 'static'), opts)

const OTHER_SUPPORTED_LANGS = new Set(['ar', 'ca', 'de', 'es', 'fr', 'gl', 'it', 'ja', 'ko', 'uk', 'zh-cn', 'zh-tw'])

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to use fs to get the directories under locale instead of fixed values.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, many thanks!

…gging

According to the normal webside, we have 4 kinds of url forms:

1) https://localhost:8080/: Access the route, the default lang is `en`.
2) https://localhost:8080/zh-cn/docs/: If we don't have the proper
translations, just direct you to `en`.
3) https://localhost:8080/zh-nc/docs/: If we have a wrong language, 404 will
be returned.
4) https://localhost:8080/blog: When directly accessing a folder, just add `en`
as the default lang.

For other page routes, `404` will be redirected to you.

So the original codes don't meet all these cases. Here's the fix for
that.
@ghost
Copy link
Author

ghost commented Jul 6, 2018

@marswong : Fixed, thanks!

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

Successfully merging this pull request may close these issues.

1 participant