Skip to content

Commit

Permalink
automated language links (#6613)
Browse files Browse the repository at this point in the history
  • Loading branch information
rikivillalba committed Nov 16, 2024
1 parent 03c647f commit 0d1ea0e
Show file tree
Hide file tree
Showing 23 changed files with 96 additions and 30 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.dir-locals.el
.check.translations.R
.translation_links.R
^\.Rprofile$
^data\.table_.*\.tar\.gz$
^config\.log$
Expand Down
32 changes: 32 additions & 0 deletions vignettes/.translation_links.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# build a link list of alternative languages
# currently inline IETF codes but can be expanded
url = "https://rdatatable.gitlab.io/data.table/articles"
path = dirname(knitr::current_input(TRUE))

if (basename(path) == "vignettes") {
lang = "en"
} else {
lang = basename(path)
path = dirname(path)
}

translation = dir(path,
recursive = TRUE,
pattern = glob2rx(knitr::current_input(FALSE))
)

transl_lang = ifelse(dirname(translation) == ".", "en", dirname(translation))

block = sprintf(
"%s: %s\n",
switch(lang,
fr = "Des traductions de ce document sont disponibles dans les langues suivantes",
"Translations of this document are available in the following languages"
),
paste(collapse = " | ", sprintf(
"[%s](%s)",
transl_lang[transl_lang != lang],
file.path(url, sub("(?i)\\.Rmd$", ".html", translation[transl_lang != lang]))
)))

knitr::asis_output(block)
5 changes: 2 additions & 3 deletions vignettes/datatable-benchmarking.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ h2 {
}
</style>

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-benchmarking.html)
```{r echo=FALSE, file='.translation_links.R'}
```

This document is meant to guide on measuring performance of `data.table`. Single place to document best practices and traps to avoid.

Expand Down
5 changes: 2 additions & 3 deletions vignettes/datatable-faq.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ h2 {
}
</style>

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-faq.html)
```{r echo=FALSE, file='.translation_links.R'}
```

```{r, echo = FALSE, message = FALSE}
library(data.table)
Expand Down
5 changes: 2 additions & 3 deletions vignettes/datatable-importing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ h2 {
}
</style>

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-importing.html)
```{r echo=FALSE, file='.translation_links.R'}
```

This document is focused on using `data.table` as a dependency in other R packages. If you are interested in using `data.table` C code from a non-R application, or in calling its C functions directly, jump to the [last section](#non-r-api) of this vignette.

Expand Down
5 changes: 2 additions & 3 deletions vignettes/datatable-intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-intro.html)
```{r echo=FALSE, file='.translation_links.R'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
3 changes: 3 additions & 0 deletions vignettes/datatable-joins.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ editor_options:
chunk_output_type: console
---

```{r echo=FALSE, file='.translation_links.R'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
5 changes: 2 additions & 3 deletions vignettes/datatable-keys-fast-subset.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-keys-fast-subset.html)
```{r echo=FALSE, file='.translation_links.R'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
5 changes: 2 additions & 3 deletions vignettes/datatable-programming.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-programming.html)
```{r echo=FALSE, file='.translation_links.R'}
```

```{r init, include = FALSE}
require(data.table)
Expand Down
5 changes: 2 additions & 3 deletions vignettes/datatable-reference-semantics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-reference-semantics.html)
```{r echo=FALSE, file='.translation_links.R'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
5 changes: 2 additions & 3 deletions vignettes/datatable-reshape.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-reshape.html)
```{r echo=FALSE, file='.translation_links.R'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
5 changes: 2 additions & 3 deletions vignettes/datatable-sd-usage.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ vignette: >
}
</style>

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-sd-usage.html)
```{r echo=FALSE, file='.translation_links.R'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
5 changes: 2 additions & 3 deletions vignettes/datatable-secondary-indices-and-auto-indexing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ vignette: >
\usepackage[utf8]{inputenc}
---

Translations of this document are available in

* [French](https://rdatatable.gitlab.io/data.table/articles/fr/datatable-secondary-indices-and-auto-indexing.html)
```{r echo=FALSE, file='.translation_links.R'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-benchmarking.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ h2 {
}
</style>

```{r echo=FALSE, file='../.translation_links.R'}
transl_message='Des traductions de ce document sont disponibles dans les langues suivantes'}
```

Ce document a pour but de guider la mesure de la performance de `data.table`. Il centralise la documentation des meilleures pratiques et des pièges à éviter.

# fread : effacer les caches
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-faq.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ h2 {
#TOC { width: 100%; }
</style>

```{r echo=FALSE, file='../.translation_links.R'}
transl_message='Des traductions de ce document sont disponibles dans les langues suivantes'}
```

```{r, echo = FALSE, message = FALSE}
library(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-importing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ h2 {
}
</style>

```{r echo=FALSE, file='../.translation_links.R'}
transl_message='Des traductions de ce document sont disponibles dans les langues suivantes'}
```

Ce document se concentre sur l'utilisation de `data.table` comme dépendance dans d'autres packages R. Si vous souhaitez utiliser le code C de `data.table` à partir d'une application non-R, ou appeler directement ses fonctions C, passez à la [dernière section](#non-r-API) de cette vignette.

Importer `data.table` n'est pas différent qu'importer d'autres packages R. Cette vignette a pour but de répondre aux questions les plus courantes à ce sujet; les indications présentées ici peuvent être appliquées à d'autres packages R.
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../.translation_links.R'}
transl_message='Des traductions de ce document sont disponibles dans les langues suivantes'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-keys-fast-subset.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../.translation_links.R'}
transl_message='Des traductions de ce document sont disponibles dans les langues suivantes'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-programming.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../.translation_links.R'}
transl_message='Des traductions de ce document sont disponibles dans les langues suivantes'}
```

```{r init, include = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-reference-semantics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../.translation_links.R'}
transl_message='Des traductions de ce document sont disponibles dans les langues suivantes'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-reshape.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../.translation_links.R'}
transl_message='Des traductions de ce document sont disponibles dans les langues suivantes'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
4 changes: 4 additions & 0 deletions vignettes/fr/datatable-sd-usage.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../.translation_links.R'}
transl_message='Des traductions de ce document sont disponibles dans les langues suivantes'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ vignette: >
\usepackage[utf8]{inputenc}
---

```{r echo=FALSE, file='../.translation_links.R'}
transl_message='Des traductions de ce document sont disponibles dans les langues suivantes'}
```

```{r, echo = FALSE, message = FALSE}
require(data.table)
knitr::opts_chunk$set(
Expand Down

0 comments on commit 0d1ea0e

Please sign in to comment.