Skip to content

Commit

Permalink
[docs] Disable in-context translations (#19056)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt authored and oliviertassinari committed Jan 2, 2020
1 parent a07f180 commit 2a60cfc
Showing 1 changed file with 10 additions and 12 deletions.
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

0 comments on commit 2a60cfc

Please sign in to comment.