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

[docs] Don't redirect on deploy preview #32399

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ if (reactStrictMode) {
}
const l10nPRInNetlify = /^l10n_/.test(process.env.HEAD) && process.env.NETLIFY === 'true';
const vercelDeploy = Boolean(process.env.VERCEL);
const isDeployPreview = process.env.PULL_REQUEST === 'true';
// For crowdin PRs we want to build all locales for testing.
const buildOnlyEnglishLocale = isDeployPreview && !l10nPRInNetlify && !vercelDeploy;

const staging =
process.env.REPOSITORY_URL === undefined || /mui\/material-ui$/.test(process.env.REPOSITORY_URL);
Expand Down Expand Up @@ -172,6 +175,7 @@ module.exports = {
SOURCE_CODE_ROOT_URL: 'https://github.com/mui/material-ui/blob/master',
SOURCE_CODE_REPO: 'https://github.com/mui/material-ui',
STAGING: staging,
BUILD_ONLY_ENGLISH_LOCALE: buildOnlyEnglishLocale,
},
// Next.js provides a `defaultPathMap` argument, we could simplify the logic.
// However, we don't in order to prevent any regression in the `findPages()` method.
Expand Down Expand Up @@ -218,8 +222,8 @@ module.exports = {
}

// We want to speed-up the build of pull requests.
// For crowdin PRs we want to build all locales for testing.
if (process.env.PULL_REQUEST === 'true' && !l10nPRInNetlify && !vercelDeploy) {
// For this, consider only English language on deploy previews, except for crowdin PRs.
if (buildOnlyEnglishLocale) {
// eslint-disable-next-line no-console
console.log('Considering only English for SSR');
traverse(pages, 'en');
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function LanguageNegotiation() {
acceptLanguage.get(navigator.language) ||
userLanguage;
Copy link
Member

Choose a reason for hiding this comment

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

Should we redirect to translated page if navigator language is not English though?
Given that content is not translated, I would argue that we should only redirect if user explicitly selected different language

const preferedLanguage =
  LANGUAGES.find((lang) => lang === getCookie('userLanguage')) ||
- acceptLanguage.get(navigator.language) ||
  userLanguage;

Copy link
Member Author

Choose a reason for hiding this comment

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

The pages for the data grid are not translated, but the pages for the core components are. Speaking about Portuguese, the core docs is around 35% translated. I think as soon as one single string is translated we'll need to redirect the docs. BTW, the button to send contributions doesn't work on X. I'll open an issue for that.

image

Copy link
Member

Choose a reason for hiding this comment

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

I think as soon as one single string is translated we'll need to redirect the docs.

Interesting, what is the motivation behind this?
I would argue that partially translated (even >50%) page is more disappointing than helpful. Especially for technical documentation (landing pages and pricing page are English-only)


if (userLanguage !== preferedLanguage) {
if (userLanguage !== preferedLanguage && !process.env.BUILD_ONLY_ENGLISH_LOCALE) {
window.location =
preferedLanguage === 'en' ? canonicalAs : `/${preferedLanguage}${canonicalAs}`;
}
Expand Down