Package 'babelquarto'

Title: Renders a Multilingual Quarto Book
Description: Automate rendering and cross-linking of Quarto books following a prescribed structure.
Authors: Maëlle Salmon [cre, aut] (ORCID: <https://orcid.org/0000-0002-2815-0399>), Johannes Ranke [ctb], Joel H. Nitta [ctb] (ORCID: <https://orcid.org/0000-0003-4719-7472>), Pascal Burkhard [aut] (ORCID: <https://orcid.org/0009-0001-5504-5084>), rOpenSci [fnd] (ROR: <https://ror.org/019jywm96>)
Maintainer: Maëlle Salmon <[email protected]>
License: MIT + file LICENSE
Version: 0.0.1
Built: 2025-08-22 14:42:36 UTC
Source: https://github.com/ropensci-review-tools/babelquarto

Help Index


Create a starter/example quarto multilingual book or website

Description

Create a starter/example quarto multilingual book or website

Usage

quarto_multilingual_book(
  parent_dir,
  project_dir,
  main_language = "en",
  further_languages = c("es", "fr"),
  register_languages = TRUE,
  site_url = "https://example.com",
  placement = c("sidebar", "navbar")
)

quarto_multilingual_website(
  parent_dir,
  project_dir,
  main_language = "en",
  further_languages = c("es", "fr"),
  register_languages = TRUE,
  site_url = "https://example.com",
  placement = c("navbar", "sidebar")
)

Arguments

parent_dir

Folder where to create the project folder.

project_dir

Project (book, website) folder name.

main_language

Code for main languages.

further_languages

Codes for not main languages.

register_languages

Whether to register languages (logical).

site_url

Site URL for the book/site-url or website/site-url part of the Quarto configuration.

placement

Where to place the language links (sidebar, navbar).

Value

The path to the created project.

Examples

parent_dir <- withr::local_tempdir()
  quarto_multilingual_book(
    parent_dir = parent_dir,
    project_dir = "blop",
    further_languages = c("es", "fr"),
    main_language = "en"
  )

Register further languages in Quarto config

Description

Register further languages in Quarto config

Usage

register_further_languages(further_languages, project_path = ".")

Arguments

further_languages

Languages to be registered (character vector)

project_path

Path where the book/website source is located

Value

Nothing

Examples

parent_dir <- withr::local_tempdir()
  quarto_multilingual_book(
    parent_dir = parent_dir,
    project_dir = "blop",
    further_languages = c("es", "fr"),
    main_language = "en"
  )
register_further_languages(
  "pt",
  project_path = file.path(parent_dir, "blop")
)
# have a look at the configuration
file.edit(file.path(parent_dir, "blop", "_quarto.yml"))

Register main language in Quarto config

Description

Register main language in Quarto config

Usage

register_main_language(main_language = "en", project_path = ".")

Arguments

main_language

Main language code (character, like "en")

project_path

Path where the book/website source is located

Value

Nothing

Examples

parent_dir <- withr::local_tempdir()
quarto_multilingual_book(
    parent_dir = parent_dir,
    project_dir = "blop",
    further_languages = c("es", "fr"),
    main_language = "en",
    register_languages = FALSE
  )
book_path <- file.path(parent_dir, "blop")
register_main_language("en", book_path)
# have a look at the config
file.edit(file.path(parent_dir, "blop", "_quarto.yml"))

Render a Quarto multilingual project

Description

Render a Quarto multilingual project

Usage

render_book(project_path = ".", site_url = NULL, profile = NULL)

render_website(project_path = ".", site_url = NULL, profile = NULL)

Arguments

project_path

Path where the book/website source is located

site_url

Base URL of the book/website.

profile

Quarto profile(s) to use.

Details

babelquarto expects a book/website folder with each qmd/Rmd present in as many languages as needed, with the same basename but,

  • once with only .qmd as extension for the main language,

  • once with .es.qmd (using the language code) for each other language.

You also need to register the language in the configuration file, see register_main_language() and register_further_languages():

babelquarto:
  mainlanguage: 'en'
  languages: ['es', 'fr']

Value

Nothing, called for its side-effect of rendering a project.

Examples

directory <- withr::local_tempdir()
quarto_multilingual_book(parent_dir = directory, project_dir = "blop")
render_book(file.path(directory, "blop"))
## Not run: 
if (require("servr") && rlang::is_interactive()) {
  servr::httw(file.path(directory, "blop", "_book"))
}

## End(Not run)