Skip to content

Commit

Permalink
Update MDX Crowdin doc
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Feb 24, 2021
1 parent bb66f56 commit f7e2d34
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function plugin() {
if (node.lang === 'mdx-code-block') {
const newChildrens = this.parse(node.value).children;

// Replace mdx code block the parsed childrens
// Replace the mdx code block by its content, parsed
parent.children.splice(
parent.children.indexOf(node),
1,
Expand Down
60 changes: 57 additions & 3 deletions website/docs/i18n/i18n-crowdin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,67 @@ Crowdin does not support well multiple concurrent uploads/downloads: it is prefe

### MDX

:::warning
:::caution

Crowdin does not support the `.mdx` extension, and interpret these files as plain text instead of Markdown, producing a bad translation experience.
Pay special attention to the JSX fragments in MDX documents!

:::

We temporarily recommend using the `.md` extension (even if the document contains React code), and are in touch with Crowdin to get this solved.
Crowdin **does not support officially MDX**, but they added **support for the `.mdx` extension**, and interpret such files as Markdown (instead of plain text).

#### MDX problems

Crowdin thinks the JSX syntax is embedded HTML, and can mess-up with the JSX markup when you download the translations, leading to a site that fails to build due to invalid JSX.

Simple JSX fragments using simple string props like `<Username name="Sebastien"/>` will work fine.

More complex JSX fragments using object/array props like `<User person={{name: "Sebastien"}}/>` are more likely to fail due to a syntax that does not look like HTML.

#### MDX solutions

We recommend moving the complex embedded JSX code as separate standalone components.

We also added a `mdx-code-block` escape hatch syntax:

`````text
# How to deploy Docusaurus
To deploy Docusaurus, run the following command:
````mdx-code-block
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
<Tabs
defaultValue="bash"
values={[
{ label: 'Bash', value: 'bash' },
{ label: 'Windows', value: 'windows' }
]}>
<TabItem value="bash">
```bash
GIT_USER=<GITHUB_USERNAME> yarn deploy
```
</TabItem>
<TabItem value="windows">
```batch
cmd /C "set "GIT_USER=<GITHUB_USERNAME>" && yarn deploy"
```
</TabItem>
</Tabs>
````
`````

This will:

- be interpreted by Crowdin as code blocks (and not mess-up with the markup on download)
- be interpreted by Docusaurus as regular JSX (as if it was not wrapped by any code block)
- unfortunately opt-out of MDX tooling (IDE syntax highlighting, Prettier...)

### Docs versioning

Expand Down

0 comments on commit f7e2d34

Please sign in to comment.