Creating multilingual documentation with Quarto
During a recent coffee chat with Wes McKinney and Hadley Wickham, a participant shared an interesting use case:
We want to use Quarto to share documentation with different contexts, same documentation, but quickly switching between R and Python for our users that need to see one language or the other.
Wes and Hadley shared different solutions available in Quarto, and we enjoyed the discussion so much that we turned it into a blog post!
Quarto is a scientific and technical authoring system built from the ground up to support multilingual projects. You can combine R, Python, Julia, and more in one document. It’s an excellent choice for developers, technical writers, and educators looking to create multilingual documentation for different programming languages. Below, we explore two approaches to implement this functionality: grouped tabsets on a page and the Tabby extension.
Group tabsets on a page
Quarto’s tabsets allow you to organize content, such as R and Python code, in separate tabs. Grouped tabsets enable you to synchronize these tabs so that when a user switches to one language, all related tabs on the page switch simultaneously.
Create grouped tabsets by assigning the same group attribute (e.g., language) to multiple tabset divs. Each heading within the tabset will output a separate tab. All the tabs with the same heading will synchronize across the page. For example, selecting the R tab will switch all related tabs on the page to the tabs containing R code.
:::{.panel-tabset group="language"}
## R
```{r}
R code here
```
## Python
```{python}
Python code here
```
:::
More stuff in between...
:::{.panel-tabset group="language"}
## R
```{r}
R code here
```
## Python
```{python}
Python code here
```
:::Tabby extension
The Tabby extension by James J. Balamuta provides another way to create multilingual documentation.
Similar to the example above, you assign a group attribute (e.g., language) a Tabby div. However, unlike grouped tabsets, where you need to define the same headings across all tabsets for synchronization, Tabby automatically creates tabsets for each code block in the Tabby div. It will then synchronize tab switches across the document.
---
filters:
- tabby
---
::: {.tabby group="language"}
```{r}
R code here
```
```{python}
Python code here
```
:::
More stuff in between...
::: {.tabby group="language"}
```{r}
R code here
```
```{python}
Python code here
```
:::Additionally, Tabby lets you set a default tab selection, which is handy if you would like to prioritize the most relevant language for your audience.
Learn more
We are excited for you to present R and Python (or other languages) side by side with Quarto!
- See grouped tabset examples in our Posit Docs.
- Search for more Quarto extensions in the Quarto extension gallery.