mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
l10n: the manpage creation should use the locale files
This commit is contained in:
parent
d9f0868a45
commit
c437ac830e
1 changed files with 15 additions and 15 deletions
|
@ -80,6 +80,19 @@ fn find_prefixed_util<'a>(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn setup_localization_or_exit(util_name: &str) {
|
||||||
|
locale::setup_localization(get_canonical_util_name(util_name)).unwrap_or_else(|err| {
|
||||||
|
match err {
|
||||||
|
uucore::locale::LocalizationError::ParseResource {
|
||||||
|
error: err_msg,
|
||||||
|
snippet,
|
||||||
|
} => eprintln!("Localization parse error at {snippet}: {err_msg}"),
|
||||||
|
other => eprintln!("Could not init the localization system: {other}"),
|
||||||
|
}
|
||||||
|
process::exit(99)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(clippy::cognitive_complexity)]
|
#[allow(clippy::cognitive_complexity)]
|
||||||
fn main() {
|
fn main() {
|
||||||
uucore::panic::mute_sigpipe_panic();
|
uucore::panic::mute_sigpipe_panic();
|
||||||
|
@ -143,21 +156,7 @@ fn main() {
|
||||||
// binary to avoid the load of the flt
|
// binary to avoid the load of the flt
|
||||||
// Could be something like:
|
// Could be something like:
|
||||||
// #[cfg(not(feature = "only_english"))]
|
// #[cfg(not(feature = "only_english"))]
|
||||||
match locale::setup_localization(get_canonical_util_name(util)) {
|
setup_localization_or_exit(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)));
|
process::exit(uumain(vec![util_os].into_iter().chain(args)));
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
@ -261,6 +260,7 @@ fn gen_manpage<T: uucore::Args>(
|
||||||
let command = if utility == "coreutils" {
|
let command = if utility == "coreutils" {
|
||||||
gen_coreutils_app(util_map)
|
gen_coreutils_app(util_map)
|
||||||
} else {
|
} else {
|
||||||
|
setup_localization_or_exit(utility);
|
||||||
util_map.get(utility).unwrap().1()
|
util_map.get(utility).unwrap().1()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue