diff options
| author | metamuffin <metamuffin@disroot.org> | 2025-10-24 20:53:08 +0200 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2025-10-24 20:53:08 +0200 |
| commit | e67d2d03f9e2d66a24a6b7561146af589e019891 (patch) | |
| tree | d776ae10122b569f6d8faf36cd01088ce1231afc /server/book-export/src/main.rs | |
| parent | 1e5dc0dee2fed17d6cc5c0e98edbb9b72daa6345 (diff) | |
| download | hurrycurry-e67d2d03f9e2d66a24a6b7561146af589e019891.tar hurrycurry-e67d2d03f9e2d66a24a6b7561146af589e019891.tar.bz2 hurrycurry-e67d2d03f9e2d66a24a6b7561146af589e019891.tar.zst | |
Localize book html export
Diffstat (limited to 'server/book-export/src/main.rs')
| -rw-r--r-- | server/book-export/src/main.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/server/book-export/src/main.rs b/server/book-export/src/main.rs index 9d3cb5dc..b2731308 100644 --- a/server/book-export/src/main.rs +++ b/server/book-export/src/main.rs @@ -22,10 +22,15 @@ use crate::book_html::render_html_book; use anyhow::Result; use clap::{Parser, ValueEnum}; use hurrycurry_data::{book::book, index::DataIndex}; -use hurrycurry_locale::FALLBACK_LOCALE; +use hurrycurry_locale::Locale; +use std::path::PathBuf; #[derive(Parser)] struct Args { + #[arg(long, default_value = "locale")] + locale_dir: PathBuf, + #[arg(short, long, default_value = "en")] + locale: String, #[arg(short, long)] format: ExportFormat, #[arg(short, long, default_value = "5star")] @@ -52,7 +57,9 @@ fn main() -> Result<()> { println!("{}", serde_json::to_string(&book).unwrap()) } ExportFormat::Html => { - println!("{}", render_html_book(&data, &book, &FALLBACK_LOCALE)); + let mut locale = Locale::load(&args.locale_dir.join(format!("{}.ini", args.locale)))?; + locale.merge(Locale::load(&args.locale_dir.join("en.ini"))?); + println!("{}", render_html_book(&data, &book, &locale)); } } Ok(()) |