ropensci-review-tools / babelquarto

Renders a Multilingual Quarto Project (Book or Website)
https://docs.ropensci.org/babelquarto/
Other
30 stars 6 forks source link

No language selector #44

Closed truecluster closed 2 weeks ago

truecluster commented 2 weeks ago

I have worked with bookdown, but am new to quarto. I try to setup a multilingual book (3 languages) that renders as a switchable html (and alternatively as 3 pdfs). I installed the latest version of RStudio, and babelquarto with install.packages('babelquarto', repos = c('https://ropensci.r-universe.dev', 'https://cloud.r-project.org')) I set up an example with

babelquarto::quarto_multilingual_book(
  parent_dir = 'myparentdir',
  project_dir = 'mybookdir',
  main_language = "en",
  further_languages = c("es", "fr"),
  register_languages = TRUE,
  site_url = "https://example.com"  ## What is the effect of site_url?
)

Then I create a new RStudio project in mybookdir and html render the project: it gives just an english website with no language selector!?? What am I doing wrong?

maelle commented 2 weeks ago

@truecluster books have to be rendered using babelquarto::render_book().

You're the second person to ask so the culprit is the documentation, I'll update the README :grin:

truecluster commented 2 weeks ago

Thank you Maelle, That is important to know. Once I babelquarto::render_book() I got the multilanguage setup, opening in a browser (local filesystem) gave me 404 on changing the language, because the site-url: "https://example.com" was of course wrong. I can fix this by putting the "file:///pathto/project/_book/" which creates conflicts with git synching with a production version. I tried the relative path "." instead, but that fails because the default language is not in a subdirectory like the other two languages. Furthermore the search function does not work because babelquarto::render_book() does not serve the content like the RenderBook Button in Rstudio. How can I preview my multilingual Book? Kind regards

maelle commented 2 weeks ago

right, that's not straightforward.

I opened #46

truecluster commented 2 weeks ago

Thank you Maelle, That works like a charm. Even more convenient when storing the return value of httw:

ret <- servr::httw("_book")                               # start http server with path to index.html
babelquarto::render_book(site_url = ret$url)   # render overwriting the url of the yaml file
servr::daemon_stop(1)                                     # finally stop server 

Kind regards