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] Disable translations #34820

Merged
merged 11 commits into from
Dec 1, 2022
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
[![Follow on Twitter](https://img.shields.io/twitter/follow/MUI_hq.svg?label=follow+MUI)](https://twitter.com/MUI_hq)
[![Renovate status](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://github.com/mui/material-ui/issues/27062)
[![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/mui/material-ui.svg)](https://isitmaintained.com/project/mui/material-ui 'Average time to resolve an issue')
[![Crowdin](https://badges.crowdin.net/material-ui-docs/localized.svg)](https://translate.mui.com/project/material-ui-docs)
[![Open Collective backers and sponsors](https://img.shields.io/opencollective/all/mui)](https://opencollective.com/mui)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1320/badge)](https://bestpractices.coreinfrastructure.org/projects/1320)

Expand Down Expand Up @@ -233,14 +232,6 @@ These great services sponsor MUI's core infrastructure:

[Netlify](https://www.netlify.com/) lets us distribute the documentation.

<picture>
<source media="(prefers-color-scheme: dark)" srcset="/docs/public/static/readme/crowdin-darkmode.svg">
<source media="(prefers-color-scheme: light)" srcset="/docs/public/static/readme/crowdin-lightmode.svg">
<img alt="Crowdin logo" src="/docs/public/static/readme/crowdin-darkmode.svg">
</picture>

[Crowdin](https://crowdin.com/) lets us translate the documentation.

<picture>
<source media="(prefers-color-scheme: dark)" srcset="/docs/public/static/readme/browserstack-darkmode.svg">
<source media="(prefers-color-scheme: light)" srcset="/docs/public/static/readme/browserstack-lightmode.svg">
Expand Down
4 changes: 0 additions & 4 deletions docs/data/material/discover-more/backers/backers.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ GitHub allows us to host the Git repository.

Netlify allows us to distribute the documentation.

[<img loading="lazy" alt="Crowdin" src="https://support.crowdin.com/assets/logos/crowdin-logo-small-black.svg" height="30">](https://crowdin.com/)

Crowdin allows us to translate the documentation.

[<img loading="lazy" alt="BrowserStack" src="https://www.browserstack.com/images/mail/browserstack-logo-footer.png" height="30">](https://www.browserstack.com/)

BrowserStack allows us to test in real browsers.
Expand Down
1 change: 0 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"@types/react-virtualized": "^9.21.21",
"@types/react-window": "^1.8.5",
"@types/styled-components": "5.1.26",
"accept-language": "^3.0.18",
"ast-types": "^0.14.2",
"autoprefixer": "^10.4.13",
"autosuggest-highlight": "^3.3.4",
Expand Down
5 changes: 0 additions & 5 deletions docs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as React from 'react';
import { loadCSS } from 'fg-loadcss/src/loadCSS';
import NextHead from 'next/head';
import PropTypes from 'prop-types';
import acceptLanguage from 'accept-language';
import pages from 'docs/src/pages';
import basePages from 'docs/data/base/pages';
import materialPages from 'docs/data/material/pages';
Expand All @@ -14,7 +13,6 @@ import PageContext from 'docs/src/modules/components/PageContext';
import GoogleAnalytics from 'docs/src/modules/components/GoogleAnalytics';
import { CodeCopyProvider } from 'docs/src/modules/utils/CodeCopy';
import { ThemeProvider } from 'docs/src/modules/components/ThemeContext';
import { LANGUAGES } from 'docs/src/modules/constants';
import { CodeVariantProvider } from 'docs/src/modules/utils/codeVariant';
import { UserLanguageProvider } from 'docs/src/modules/utils/i18n';
import DocsStyledEngineProvider from 'docs/src/modules/utils/StyledEngineProvider';
Expand All @@ -29,9 +27,6 @@ LicenseInfo.setLicenseKey(process.env.NEXT_PUBLIC_MUI_LICENSE);
// Client-side cache, shared for the whole session of the user in the browser.
const clientSideEmotionCache = createEmotionCache();

// Set the locales that the documentation automatically redirects to.
acceptLanguage.languages(LANGUAGES);

let reloadInterval;

// Avoid infinite loop when "Upload on reload" is set in the Chrome sw dev tools.
Expand Down
9 changes: 9 additions & 0 deletions docs/public/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,15 @@ https://v4.material-ui.com/* https://v4.mui.com/:splat 301!
/:lang/experimental-api/classname-generator/ /:lang/material-ui/experimental-api/classname-generator/ 301
/experimental-api/css-variables/ /material-ui/experimental-api/css-theme-variables/overview/ 301
/:lang/experimental-api/css-variables/ /:lang/material-ui/experimental-api/css-theme-variables/overview/ 301
/pt/material-ui/* /material-ui/:splat 301
/zh/material-ui/* /material-ui/:splat 301
/pt/joy-ui/* /joy-ui/:splat 301
/zh/joy-ui/* /joy-ui/:splat 301
/pt/base/* /base/:splat 301
/zh/base/* /base/:splat 301
/pt/system/* /system/:splat 301
/zh/system/* /system/:splat 301

# 2023

# Proxies
Expand Down
55 changes: 1 addition & 54 deletions docs/src/modules/components/AppSettingsDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ import SettingsBrightnessIcon from '@mui/icons-material/SettingsBrightness';
import FormatTextdirectionLToRIcon from '@mui/icons-material/FormatTextdirectionLToR';
import FormatTextdirectionRToLIcon from '@mui/icons-material/FormatTextdirectionRToL';
import { useChangeTheme } from 'docs/src/modules/components/ThemeContext';
import { pathnameToLanguage } from 'docs/src/modules/utils/helpers';
import NoSsr from '@mui/material/NoSsr';
import { LANGUAGES_LABEL } from 'docs/src/modules/constants';
import { useUserLanguage, useTranslate } from 'docs/src/modules/utils/i18n';
import { useRouter } from 'next/router';
import List from '@mui/material/List';
import ListItemButton from '@mui/material/ListItemButton';

const LOCALES = { zh: 'zh-CN', pt: 'pt-BR', es: 'es-ES' };
const CROWDIN_ROOT_URL = 'https://translate.mui.com/project/material-ui-docs/';
import { useTranslate } from 'docs/src/modules/utils/i18n';

const Heading = styled(Typography)(({ theme }) => ({
margin: '20px 0 10px',
Expand Down Expand Up @@ -54,10 +45,6 @@ function AppSettingsDrawer(props) {
const [mode, setMode] = React.useState(null);
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
const preferredMode = prefersDarkMode ? 'dark' : 'light';
const userLanguage = useUserLanguage();
const crowdInLocale = LOCALES[userLanguage] || userLanguage;
const router = useRouter();
const { canonicalAs } = pathnameToLanguage(router.asPath);

React.useEffect(() => {
// syncing with homepage, can be removed once all pages are migrated to CSS variables
Expand Down Expand Up @@ -94,11 +81,6 @@ function AppSettingsDrawer(props) {
changeTheme({ direction });
};

const handleLanguageClick = (language) => () => {
document.cookie = `userLanguage=${language.code};path=/;max-age=31536000`;
onClose();
};

return (
<Drawer
anchor="right"
Expand Down Expand Up @@ -189,41 +171,6 @@ function AppSettingsDrawer(props) {
{t('settings.rtl')}
</IconToggleButton>
</ToggleButtonGroup>
<Heading gutterBottom>{t('settings.language')}</Heading>
<NoSsr defer>
<List>
{LANGUAGES_LABEL.map((language) => (
<ListItemButton
component="a"
divider
data-no-markdown-link="true"
href={language.code === 'en' ? canonicalAs : `/${language.code}${canonicalAs}`}
key={language.code}
onClick={handleLanguageClick(language)}
selected={userLanguage === language.code}
lang={language.code}
hrefLang={language.code}
>
{language.text}
</ListItemButton>
))}
<ListItemButton
component="a"
href={
userLanguage === 'en'
? `${CROWDIN_ROOT_URL}`
: `${CROWDIN_ROOT_URL}${crowdInLocale}#/staging`
}
rel="noopener nofollow"
target="_blank"
key={userLanguage}
lang={userLanguage}
hrefLang="en"
>
{t('appFrame.helpToTranslate')}
</ListItemButton>
</List>
</NoSsr>
<Heading gutterBottom>{t('settings.color')}</Heading>
<Button
component="a"
Expand Down
12 changes: 2 additions & 10 deletions docs/src/modules/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const CODE_VARIANTS = {
};

// Valid languages to server-side render in production
const LANGUAGES = ['en', 'zh', 'pt'];
const LANGUAGES = ['en'];
Copy link
Member

Choose a reason for hiding this comment

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

Do we need these constants? They're used in next.config.js, but maybe we should remove translation logic there as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

We discussed that we want to keep the infrastructure around the translations so that we can easily add it back if we decide in the future, this is why I decided to left these constants and not do any changes in the next.config.js, but I don't mind removing the logic there as well. cc @siriwatknp what do you think?

Copy link
Member

@siriwatknp siriwatknp Oct 20, 2022

Choose a reason for hiding this comment

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

Let's remove them too. There are many places that use LANGUAGES, so I think let's keep them there, otherwise it will be a lot more work. The changes are sufficient.


// Server side rendered languages
const LANGUAGES_SSR = ['en', 'zh', 'pt'];
const LANGUAGES_SSR = ['en'];

// Work in progress
const LANGUAGES_IN_PROGRESS = LANGUAGES.slice();
Expand All @@ -18,14 +18,6 @@ const LANGUAGES_LABEL = [
code: 'en',
text: 'English',
},
{
code: 'zh',
text: '中文',
},
{
code: 'pt',
text: 'Português',
},
];

const LANGUAGES_IGNORE_PAGES = (pathname) => {
Expand Down
15 changes: 1 addition & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4183,14 +4183,6 @@ abbrev@1:
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==

accept-language@^3.0.18:
version "3.0.18"
resolved "https://registry.yarnpkg.com/accept-language/-/accept-language-3.0.18.tgz#f5025f17bf65a466a845838ccf98cdb877d83384"
integrity sha512-sUofgqBPzgfcF20sPoBYGQ1IhQLt2LSkxTnlQSuLF3n5gPEqd5AimbvOvHEi0T1kLMiGVqPWzI5a9OteBRth3A==
dependencies:
bcp47 "^1.1.2"
stable "^0.1.6"

accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8:
version "1.3.8"
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e"
Expand Down Expand Up @@ -5006,11 +4998,6 @@ base@^0.11.1:
mixin-deep "^1.2.0"
pascalcase "^0.1.1"

bcp47@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/bcp47/-/bcp47-1.1.2.tgz#354be3307ffd08433a78f5e1e2095845f89fc7fe"
integrity sha512-JnkkL4GUpOvvanH9AZPX38CxhiLsXMBicBY2IAtqiVN8YulGDQybUydWA4W6yAMtw6iShtw+8HEF6cfrTHU+UQ==

bcrypt-pbkdf@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e"
Expand Down Expand Up @@ -14705,7 +14692,7 @@ ssri@^9.0.0, ssri@^9.0.1:
dependencies:
minipass "^3.1.1"

stable@^0.1.6, stable@^0.1.8:
stable@^0.1.8:
version "0.1.8"
resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf"
integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==
Expand Down