From 16afa021ce64407f567cf998856c31e8d74a28c8 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 31 May 2025 18:10:58 +0200 Subject: [PATCH] l10n: add a comment to detail the need of having the capability to disable translations --- src/bin/coreutils.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/bin/coreutils.rs b/src/bin/coreutils.rs index 0332d29a0..384ac9876 100644 --- a/src/bin/coreutils.rs +++ b/src/bin/coreutils.rs @@ -112,8 +112,25 @@ fn main() { match utils.get(util) { Some(&(uumain, _)) => { - if let Err(e) = locale::setup_localization(uucore::util_name()) { - println!("Could not init the localization system {}", e); + // TODO: plug the deactivation of the translation + // and load the English strings directly at compilation time in the + // binary to avoid the load of the flt + // Could be something like: + // #[cfg(not(feature = "only_english"))] + match locale::setup_localization(get_canonical_util_name(util)) { + Ok(()) => {} + Err(uucore::locale::LocalizationError::ParseResource { + error: err_msg, + snippet, + }) => { + // Now you have both `err_msg: ParserError` and `snippet: String` + eprintln!("Localization parse error at “{}”: {:?}", snippet, err_msg); + process::exit(1); + } + Err(other) => { + eprintln!("Could not init the localization system: {}", other); + process::exit(1); + } } process::exit(uumain(vec![util_os].into_iter().chain(args))); }