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 in-context translation #19056

Merged
merged 1 commit into from
Jan 2, 2020
Merged
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
22 changes: 10 additions & 12 deletions docs/src/modules/components/EditPage.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { Router, useRouter } from 'next/router';
import Button from '@material-ui/core/Button';
import { pathnameToLanguage } from 'docs/src/modules/utils/helpers';

const SOURCE_CODE_ROOT_URL = 'https://github.com/mui-org/material-ui/edit/master';

export default function EditPage(props) {
const { markdownLocation } = props;
const t = useSelector(state => state.options.t);
const userLanguage = useSelector(state => state.options.userLanguage);
const router = useRouter();
const { canonical } = pathnameToLanguage(Router._rewriteUrlForNextExport(router.asPath));
const LOCALES = { zh: 'zh-CN', pt: 'pt-BR', es: 'es-ES' };
const CROWDIN_ROOT_URL = 'https://translate.material-ui.com/project/material-ui-docs/';
const crowdInLocale = LOCALES[userLanguage] || userLanguage;
const crowdInPath = markdownLocation.substring(0, markdownLocation.lastIndexOf('/'));

return (
<Button
component={userLanguage === 'en' ? 'a' : 'button'}
onClick={() => {
if (userLanguage === 'en') {
return;
}
window.location = `/aa${canonical}`;
}}
href={userLanguage === 'en' ? `${SOURCE_CODE_ROOT_URL}${markdownLocation}` : null}
component="a"
href={
userLanguage === 'en'
? `${SOURCE_CODE_ROOT_URL}${markdownLocation}`
: `${CROWDIN_ROOT_URL}${crowdInLocale}#/staging${crowdInPath}`
}
target="_blank"
rel="noopener nofollow"
size="small"
Expand Down