1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #8078 from sylvestre/l10n-yes

l10n: port yes to translation + add french
This commit is contained in:
Daniel Hofstetter 2025-06-06 11:09:11 +02:00 committed by GitHub
commit 1f24aa2c62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 3 deletions

View file

@ -1,2 +1,6 @@
yes-about = Repeatedly display a line with STRING (or 'y') yes-about = Repeatedly display a line with STRING (or 'y')
yes-usage = yes [STRING]... yes-usage = yes [STRING]...
# Error messages
yes-error-standard-output = standard output: { $error }
yes-error-invalid-utf8 = arguments contain invalid UTF-8

View file

@ -0,0 +1,6 @@
yes-about = Affiche de façon répétée une ligne avec CHAÎNE (ou 'y')
yes-usage = yes [CHAÎNE]...
# Messages d'erreur
yes-error-standard-output = sortie standard : { $error }
yes-error-invalid-utf8 = les arguments contiennent de l'UTF-8 invalide

View file

@ -6,6 +6,7 @@
// cSpell:ignore strs // cSpell:ignore strs
use clap::{Arg, ArgAction, Command, builder::ValueParser}; use clap::{Arg, ArgAction, Command, builder::ValueParser};
use std::collections::HashMap;
use std::error::Error; use std::error::Error;
use std::ffi::OsString; use std::ffi::OsString;
use std::io::{self, Write}; use std::io::{self, Write};
@ -14,7 +15,7 @@ use uucore::format_usage;
#[cfg(unix)] #[cfg(unix)]
use uucore::signals::enable_pipe_errors; use uucore::signals::enable_pipe_errors;
use uucore::locale::get_message; use uucore::locale::{get_message, get_message_with_args};
// it's possible that using a smaller or larger buffer might provide better performance on some // it's possible that using a smaller or larger buffer might provide better performance on some
// systems, but honestly this is good enough // systems, but honestly this is good enough
@ -31,7 +32,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
match exec(&buffer) { match exec(&buffer) {
Ok(()) => Ok(()), Ok(()) => Ok(()),
Err(err) if err.kind() == io::ErrorKind::BrokenPipe => Ok(()), Err(err) if err.kind() == io::ErrorKind::BrokenPipe => Ok(()),
Err(err) => Err(USimpleError::new(1, format!("standard output: {err}"))), Err(err) => Err(USimpleError::new(
1,
get_message_with_args(
"yes-error-standard-output",
HashMap::from([("error".to_string(), err.to_string())]),
),
)),
} }
} }
@ -77,7 +84,7 @@ fn args_into_buffer<'a>(
for part in itertools::intersperse(i.map(|a| a.to_str()), Some(" ")) { for part in itertools::intersperse(i.map(|a| a.to_str()), Some(" ")) {
let bytes = match part { let bytes = match part {
Some(part) => part.as_bytes(), Some(part) => part.as_bytes(),
None => return Err("arguments contain invalid UTF-8".into()), None => return Err(get_message("yes-error-invalid-utf8").into()),
}; };
buf.extend_from_slice(bytes); buf.extend_from_slice(bytes);
} }