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] , Johannes Ranke [ctb], Joel H. Nitta [ctb] , Pascal Burkhard [aut]
Maintainer: Maëlle Salmon <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2024-12-19 06:30:34 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.


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


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


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']

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)