Skip to content
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

Translate comments in code #73

Open
yabellini opened this issue Nov 14, 2024 · 1 comment
Open

Translate comments in code #73

yabellini opened this issue Nov 14, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@yabellini
Copy link

yabellini commented Nov 14, 2024

Sometimes, we have code examples with comments explaining the code. It would be nice to be able to translate those comments.

Example:

Original:

# Load packages
library(tidyverse) # for {dplyr} functions and the pipe %>%
library(rio) # for importing data
library(here) # for easy file referencing
library(cleanepi)

Translated to Spanish:

# Cargar paquetes
library(tidyverse) # para las funciones de {dplyr} y el pipe %>%
library(rio) # para importar los datos
library(here) # para referencia sencilla de archivos
library(cleanepi)
@maelle
Copy link
Contributor

maelle commented Nov 19, 2024

Some thoughts.

Currently we do not parse the code at all. To parse it and differentiate comments from code, we'd need to use a code parser (base R + xmlparsedata would allow us to use XPath; treesitter).

In code comments how would we escape code. For instance we don't want to translate variable names, package names, etc.

At the moment because we do not translate code comments, one would obtain better results by extracting/repeating the ideas of the code comments in text around the code chunks.

In the code below we use the packages tidyverse (for dplyr functions and the pipe), rio (for importing data), here (for easy file referencing) and cleanepi.

```r
# Load packages
library(tidyverse) # for {dplyr} functions and the pipe %>%
library(rio) # for importing data
library(here) # for easy file referencing
library(cleanepi)
```

@maelle maelle added the enhancement New feature or request label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants