-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
367 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
[ | ||
{ | ||
"language": "BG", | ||
"name": "Bulgarian", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "CS", | ||
"name": "Czech", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "DA", | ||
"name": "Danish", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "DE", | ||
"name": "German", | ||
"supports_formality": true | ||
}, | ||
{ | ||
"language": "EL", | ||
"name": "Greek", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "EN-GB", | ||
"name": "English (British)", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "EN-US", | ||
"name": "English (American)", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "ES", | ||
"name": "Spanish", | ||
"supports_formality": true | ||
}, | ||
{ | ||
"language": "ET", | ||
"name": "Estonian", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "FI", | ||
"name": "Finnish", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "FR", | ||
"name": "French", | ||
"supports_formality": true | ||
}, | ||
{ | ||
"language": "HU", | ||
"name": "Hungarian", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "ID", | ||
"name": "Indonesian", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "IT", | ||
"name": "Italian", | ||
"supports_formality": true | ||
}, | ||
{ | ||
"language": "JA", | ||
"name": "Japanese", | ||
"supports_formality": true | ||
}, | ||
{ | ||
"language": "KO", | ||
"name": "Korean", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "LT", | ||
"name": "Lithuanian", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "LV", | ||
"name": "Latvian", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "NB", | ||
"name": "Norwegian", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "NL", | ||
"name": "Dutch", | ||
"supports_formality": true | ||
}, | ||
{ | ||
"language": "PL", | ||
"name": "Polish", | ||
"supports_formality": true | ||
}, | ||
{ | ||
"language": "PT-BR", | ||
"name": "Portuguese (Brazilian)", | ||
"supports_formality": true | ||
}, | ||
{ | ||
"language": "PT-PT", | ||
"name": "Portuguese (European)", | ||
"supports_formality": true | ||
}, | ||
{ | ||
"language": "RO", | ||
"name": "Romanian", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "RU", | ||
"name": "Russian", | ||
"supports_formality": true | ||
}, | ||
{ | ||
"language": "SK", | ||
"name": "Slovak", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "SL", | ||
"name": "Slovenian", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "SV", | ||
"name": "Swedish", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "TR", | ||
"name": "Turkish", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "UK", | ||
"name": "Ukrainian", | ||
"supports_formality": false | ||
}, | ||
{ | ||
"language": "ZH", | ||
"name": "Chinese (simplified)", | ||
"supports_formality": false | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
[ | ||
{ | ||
"language": "BG", | ||
"name": "Bulgarian" | ||
}, | ||
{ | ||
"language": "CS", | ||
"name": "Czech" | ||
}, | ||
{ | ||
"language": "DA", | ||
"name": "Danish" | ||
}, | ||
{ | ||
"language": "DE", | ||
"name": "German" | ||
}, | ||
{ | ||
"language": "EL", | ||
"name": "Greek" | ||
}, | ||
{ | ||
"language": "EN", | ||
"name": "English" | ||
}, | ||
{ | ||
"language": "ES", | ||
"name": "Spanish" | ||
}, | ||
{ | ||
"language": "ET", | ||
"name": "Estonian" | ||
}, | ||
{ | ||
"language": "FI", | ||
"name": "Finnish" | ||
}, | ||
{ | ||
"language": "FR", | ||
"name": "French" | ||
}, | ||
{ | ||
"language": "HU", | ||
"name": "Hungarian" | ||
}, | ||
{ | ||
"language": "ID", | ||
"name": "Indonesian" | ||
}, | ||
{ | ||
"language": "IT", | ||
"name": "Italian" | ||
}, | ||
{ | ||
"language": "JA", | ||
"name": "Japanese" | ||
}, | ||
{ | ||
"language": "KO", | ||
"name": "Korean" | ||
}, | ||
{ | ||
"language": "LT", | ||
"name": "Lithuanian" | ||
}, | ||
{ | ||
"language": "LV", | ||
"name": "Latvian" | ||
}, | ||
{ | ||
"language": "NB", | ||
"name": "Norwegian" | ||
}, | ||
{ | ||
"language": "NL", | ||
"name": "Dutch" | ||
}, | ||
{ | ||
"language": "PL", | ||
"name": "Polish" | ||
}, | ||
{ | ||
"language": "PT", | ||
"name": "Portuguese" | ||
}, | ||
{ | ||
"language": "RO", | ||
"name": "Romanian" | ||
}, | ||
{ | ||
"language": "RU", | ||
"name": "Russian" | ||
}, | ||
{ | ||
"language": "SK", | ||
"name": "Slovak" | ||
}, | ||
{ | ||
"language": "SL", | ||
"name": "Slovenian" | ||
}, | ||
{ | ||
"language": "SV", | ||
"name": "Swedish" | ||
}, | ||
{ | ||
"language": "TR", | ||
"name": "Turkish" | ||
}, | ||
{ | ||
"language": "UK", | ||
"name": "Ukrainian" | ||
}, | ||
{ | ||
"language": "ZH", | ||
"name": "Chinese" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"translations": [ | ||
{ | ||
"detected_source_language": "EN", | ||
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n<document xmlns=\"http://commonmark.org/xml/1.0\">\n <heading level=\"1\">\n <text xml:space=\"preserve\">cabecera<\/text>\n <\/heading>\n <paragraph>\n <text xml:space=\"preserve\">esto es un texto<\/text>\n <\/paragraph>\n <heading level=\"2\">\n <text xml:space=\"preserve\">subtítulo<\/text>\n <\/heading>\n <paragraph>\n <text xml:space=\"preserve\">¡bonito!<\/text>\n <\/paragraph>\n<\/document>\n" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"translations": [ | ||
{ | ||
"detected_source_language": "EN", | ||
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n<document xmlns=\"http://commonmark.org/xml/1.0\">\n <heading level=\"1\">\n <text xml:space=\"preserve\">un título<\/text>\n <\/heading>\n<\/document>\n" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"translations": [ | ||
{ | ||
"detected_source_language": "EN", | ||
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n<document xmlns=\"http://commonmark.org/xml/1.0\">\n <paragraph>\n <text xml:space=\"preserve\">impresionante<\/text>\n <\/paragraph>\n<\/document>\n" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
structure(list(method = "GET", url = "api/languages?type=source", | ||
status_code = 403L, headers = structure(list(date = "Tue, 05 Dec 2023 12:44:02 GMT", | ||
`access-control-allow-origin` = "*", `strict-transport-security` = "max-age=63072000; includeSubDomains; preload", | ||
`server-timing` = "l7_lb_tls;dur=117, l7_lb_idle;dur=0, l7_lb_receive;dur=0, l7_lb_total;dur=130", | ||
`access-control-expose-headers` = "Server-Timing"), class = "httr2_headers"), | ||
body = raw(0), request = structure(list(url = "https://api.deepl.com/v2/languages?type=source", | ||
method = "GET", headers = structure(list(Authorization = "DeepL-Auth-Key lalala"), redact = character(0)), | ||
body = NULL, fields = list(), options = list(), policies = list( | ||
retry_max_tries = 3)), class = "httr2_request"), | ||
cache = new.env(parent = emptyenv())), class = "httr2_response") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
test_that("deepl_update() works", { | ||
|
||
dir <- withr::local_tempdir() | ||
file <- file.path(dir, "bla.md") | ||
fs::file_create(file) | ||
out_file <- file.path(dir, "bla.es.md") | ||
|
||
brio::write_lines( | ||
c("# header", "", "this is some text", "## subtitle", "", "nice!"), | ||
file | ||
) | ||
|
||
with_mock_dir("git1", { | ||
deepl_translate( | ||
path = file, | ||
out_path = out_file, | ||
source_lang = "EN", | ||
target_lang = "ES", | ||
formality = "less", | ||
yaml_fields = NULL | ||
) | ||
}) | ||
|
||
gert::git_init(dir) | ||
gert::git_config_set("user.name", "Jane Doe", repo = dir) | ||
gert::git_config_set("user.email", "[email protected]", repo = dir) | ||
gert::git_add(c(fs::path_file(file), fs::path_file(out_file)), repo = dir) | ||
gert::git_commit_all("First commit", repo = dir) | ||
|
||
brio::write_lines( | ||
c("# a title", "", "this is some text", "", "awesome", "", "## subtitle", ""), | ||
file | ||
) | ||
gert::git_add(fs::path_file(file), repo = dir) | ||
gert::git_commit("Second commit", repo = dir) | ||
|
||
original_translation <- brio::read_lines(out_file) | ||
|
||
with_mock_dir("git2", { | ||
deepl_update( | ||
path = file, | ||
out_path = out_file, | ||
source_lang = "EN", | ||
target_lang = "ES", | ||
formality = "less", | ||
yaml_fields = NULL | ||
) | ||
}) | ||
|
||
new_translation <- brio::read_lines(out_file) | ||
expect_true( | ||
!all(new_translation %in% original_translation) | ||
) | ||
expect_true( | ||
any(new_translation %in% original_translation) | ||
) | ||
|
||
}) |