/
working-in-other-languages.Rmd
70 lines (62 loc) · 1.78 KB
/
working-in-other-languages.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
title: "Working in other languages"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Working in other languages}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
library(plume)
```
If you work in a language other than English, you can extend plume classes with default names in your desired language. plume provides `set_default_names()` to help you set new default names.
E.g. to extend `Plume` with default names in French:
```{r}
PlumeFr <- R6::R6Class(
classname = "PlumeFr",
inherit = Plume,
private = list(
plume_names = set_default_names(
initials = "initiales",
literal_name = "nom_complet",
corresponding = "correspondant",
given_name = "prénom",
family_name = "nom",
email = "courriel",
phone = "téléphone"
)
)
)
```
```{r}
PlumeFr$new(encyclopedists_fr)
```
You can also overwrite the default arguments of some methods to match your language. I recommend doing it in the `public` argument of the class definition. For the purpose of this example, I'll use the `set()` method instead. For example, to change `divider` and `sep_last` to ` : ` and ` et ` in `get_contributions()`:
```{r}
PlumeFr$set("public", "get_contributions", function(
roles_first = TRUE,
by_author = FALSE,
alphabetical_order = FALSE,
dotted_initials = TRUE,
literal_names = FALSE,
divider = " : ",
sep = ", ",
sep_last = " et "
) {
super$get_contributions(
roles_first, by_author, alphabetical_order, dotted_initials,
literal_names, divider, sep, sep_last
)
})
```
```{r}
aut <- PlumeFr$new(
encyclopedists_fr,
roles = c(supervision = "Supervision", rédaction = "Rédaction")
)
aut$get_contributions()
```