-
Notifications
You must be signed in to change notification settings - Fork 988
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
Automate lang links #6618
base: master
Are you sure you want to change the base?
Automate lang links #6618
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# build a link list of alternative languages (may be character(0)) | ||
rikivillalba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.write.translation.links <- function(fmt) { | ||
url = "https://rdatatable.gitlab.io/data.table/articles" | ||
path = dirname(knitr::current_input(TRUE)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a litedown equivalent (#6583)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only alternative I found (other than searching up the call stack) was |
||
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 = if (length(which(transl_lang != lang))) { | ||
rikivillalba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sprintf( | ||
fmt, paste(collapse = " | ", sprintf( | ||
"[%s](%s)", | ||
transl_lang[transl_lang != lang], | ||
file.path(url, sub("(?i)\\.Rmd$", ".html", translation[transl_lang != lang])) | ||
))) | ||
} else "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
knitr::asis_output(block) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,9 @@ 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'} | ||
``` | ||
`r .write.translation.links("Translations of this document are available in: %s")` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC the idea is the translation team will just translate this string themselves directly in the .Rmd file, is that right? (seems fine, just want to confirm my understanding) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly. |
||
|
||
This document is meant to guide on measuring performance of `data.table`. Single place to document best practices and traps to avoid. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also have this helper script, let's keep a consistent naming style (personally, I like your snake case style here):
https://github.com/Rdatatable/data.table/blob/master/vignettes/.check.translations.R
Also note that this should probably be added to
.Rbuildignore
? Maybe just ignore allvignettes/_.*
files?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, adding it to .Rbuildignore causes R check to fail. It checks the vignettes to be able to be built from the tarball bundle alone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh got it. I guess that's why it must be prefixed with
_
to not be "hidden", which in turn is why there's no R CMD check failure.I am only concerned about R CMD check passing, it is fine to include it.