ropensci-review-tools / babelquarto

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

Add new functions #56

Open ntluong95 opened 4 months ago

ntluong95 commented 4 months ago

The two new functions deal with the situation when there is not yet available translation version of the main language. Take this book as an example:

project:
  type: book

format:
  html: 
    theme:
      light: cosmo
      dark: [darkly, theme-dark.scss]
    toc: true
    number-sections: false
    number-depth: 0
    css:
    - webex.css
    include-after-body:
    - webex.js
  # pdf:
  #   documentclass: scrreprt

bibliography: references.bib
babelquarto:
  languagecodes:

  - name: es
    text: "Español"
  - name: en
    text: "English"

  mainlanguage: 'en'
  languages: ['es']

title-es: "Estudios de casos de AppliedEpi"
lang: en

book:
  title: "AppliedEpi cases studies"
  search:
    type: textbox
  author: AppliedEpi
  date: today
  date-format: "MMM D, YYYY"
  chapters:
  # INTRO 
  - index.qmd                           

  # ABOUT BOOK
  - part: "Case studies"
    part-es: "Estudios de caso"
    chapters:
    - pages/fulton.qmd          
    - pages/r_practical_epiet.qmd
    - pages/tbe.qmd                
    - pages/oswego.es.qmd

The English version has 3 chapter fulton.qmd, r_practical_epiet.qmd, tbe.qmd, while the Spanish version only has oswego.es.qmd. Adding two new function babelquarto::render_dynamic_book() and babelquarto::render_dynamic_website() creates a flexibility, so when all language variants are there, we can use babelquarto::render_book() and babelquarto::render_website() as usual

ntluong95 commented 4 months ago

I forgot to mention that the index file for language versions is the must. For example, in this case we need index.es.qmd. @maelle It would be nice if I can be added as a contributor of the package 😊

maelle commented 3 months ago

Thank you @ntluong95! I need to think a bit about this. I feel it's adding some maintenance work (and duplication) on the side of the package, while it's not a lot of work for users to add the placeholders file. :thinking: