diff --git a/crates/notedeck/src/app.rs b/crates/notedeck/src/app.rs index 6566bf23..12636c16 100644 --- a/crates/notedeck/src/app.rs +++ b/crates/notedeck/src/app.rs @@ -230,7 +230,12 @@ impl Notedeck { let job_pool = JobPool::default(); // Initialize localization - let i18n = Localization::new(); + let mut i18n = Localization::new(); + if let Some(locale) = &parsed_args.locale { + if let Err(err) = i18n.set_locale(locale.to_owned()) { + error!("{err}"); + } + } // Initialize global i18n context //crate::i18n::init_global_i18n(i18n.clone()); diff --git a/crates/notedeck/src/args.rs b/crates/notedeck/src/args.rs index 5c615dd1..c053a6e0 100644 --- a/crates/notedeck/src/args.rs +++ b/crates/notedeck/src/args.rs @@ -2,10 +2,12 @@ use std::collections::BTreeSet; use enostr::{Keypair, Pubkey, SecretKey}; use tracing::error; +use unic_langid::{LanguageIdentifier, LanguageIdentifierError}; pub struct Args { pub relays: Vec, pub is_mobile: Option, + pub locale: Option, pub show_note_client: bool, pub keys: Vec, pub light: bool, @@ -36,6 +38,7 @@ impl Args { use_keystore: true, dbpath: None, datapath: None, + locale: None, }; let mut i = 0; @@ -47,6 +50,23 @@ impl Args { res.is_mobile = Some(true); } else if arg == "--light" { res.light = true; + } else if arg == "--locale" { + i += 1; + let Some(locale) = args.get(i) else { + panic!("locale argument missing?"); + }; + let parsed: Result = locale.parse(); + match parsed { + Err(err) => { + panic!("locale failed to parse: {err}"); + } + Ok(locale) => { + tracing::info!( + "parsed locale '{locale}' from args, not sure if we have it yet though." + ); + res.locale = Some(locale); + } + } } else if arg == "--dark" { res.light = false; } else if arg == "--debug" {