mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge pull request #8078 from sylvestre/l10n-yes
l10n: port yes to translation + add french
This commit is contained in:
commit
1f24aa2c62
3 changed files with 20 additions and 3 deletions
|
@ -1,2 +1,6 @@
|
|||
yes-about = Repeatedly display a line with STRING (or 'y')
|
||||
yes-usage = yes [STRING]...
|
||||
|
||||
# Error messages
|
||||
yes-error-standard-output = standard output: { $error }
|
||||
yes-error-invalid-utf8 = arguments contain invalid UTF-8
|
||||
|
|
6
src/uu/yes/locales/fr-FR.ftl
Normal file
6
src/uu/yes/locales/fr-FR.ftl
Normal 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
|
|
@ -6,6 +6,7 @@
|
|||
// cSpell:ignore strs
|
||||
|
||||
use clap::{Arg, ArgAction, Command, builder::ValueParser};
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
use std::ffi::OsString;
|
||||
use std::io::{self, Write};
|
||||
|
@ -14,7 +15,7 @@ use uucore::format_usage;
|
|||
#[cfg(unix)]
|
||||
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
|
||||
// systems, but honestly this is good enough
|
||||
|
@ -31,7 +32,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
match exec(&buffer) {
|
||||
Ok(()) => 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(" ")) {
|
||||
let bytes = match part {
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue