ropensci-review-tools / babeldown

Helpers for Automatic Translation of Markdown-based Content
https://docs.ropensci.org/babeldown/
Other
20 stars 2 forks source link

Fail to implement deepl_update() #57

Closed ntluong95 closed 8 months ago

ntluong95 commented 8 months ago

I have a Quarto book that is available in English. Then I was successfully create a German (DE) version of it by using deepl_translate_quarto() function

Next I want to try making changes in English version, and using deepl_update() function to implement on DE version and other languages (ideally there are currently 7 language versions available, but they were translated manually)

For example, I made changes on "basics.qmd", "factors.qmd" chapters, so I wrote this function to implement changes

chapter_changes = c("basics.qmd", "factors.qmd")
chapter_changes_update = c("basics.de.qmd", "factors.de.qmd")

for (i in 1:length(chapter_changes)) {
        babeldown::deepl_update(
                path = here::here("new_pages", chapter_changes[i]),
                out_path = here::here("new_pages", chapter_changes_update[i]),
                source_lang = "EN",
                target_lang = "DE",
                formality = "less",
                yaml_fields = NULL)
}

but I got this error: Error in log[["commit"]][[latest_source_commit_index]] : subscript out of bounds

The steps I did was first made changes on EN version, commit to Git, and run the above function In addition, I have also the following questions:

maelle commented 8 months ago

Is your repo public? In any case I'll look at your issue more precisely later this week.

Will the update be only in markdown text, or applied also to code chunk?

babeldown translates Markdown text, it does not translate code.

If we add or delete code chunks, will this be also updated in other languages? I guess no?

The idea is that it should be updated!

maelle commented 8 months ago

adding this link in case you didn't know it https://ropensci.org/blog/2024/01/16/deepl-update-babeldown/

maelle commented 8 months ago

(edited: no I don't need to look at the Git repo, I think I see the issue) I tried again deepl_update() in a babelquarto book and it went well:

Could maybe the paths created with here be problematic? That would explain why log[["commit"]][[latest_source_commit_index]] isn't found: the code is trying to find a commit with the source in it, but there is none, so it tries until it reaches the end of the log. If that's the case I definitely need to add more checks as the error message is not informative.

maelle commented 8 months ago

see #58

maelle commented 8 months ago

@ntluong95 could you please install babeldown (pak::pak("ropensci-review-tools/babeldown")) and try running your code again?

maelle commented 8 months ago

I opened the issue as I don't want to close it before you confirm it's fixed. :innocent:

ntluong95 commented 8 months ago

Hi it is fixed 🎉🎉 But I did not see changes in the code chunk, only markdown text has been updated

maelle commented 8 months ago

Ok, see #59