Skip to content

Commit f378f08

Browse files
committed
l10n: port factor for translation + add french
1 parent bcb76ac commit f378f08

3 files changed

Lines changed: 35 additions & 7 deletions

File tree

src/uu/factor/locales/en-US.ftl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
factor-about = Print the prime factors of the given NUMBER(s).
22
If none are specified, read from standard input.
33
factor-usage = factor [OPTION]... [NUMBER]...
4+
5+
# Help messages
6+
factor-help-exponents = Print factors in the form p^e
7+
factor-help-help = Print help information.
8+
9+
# Error messages
10+
factor-error-factorization-incomplete = Factorization incomplete. Remainders exists.
11+
factor-error-write-error = write error
12+
factor-error-reading-input = error reading input: { $error }

src/uu/factor/locales/fr-FR.ftl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
factor-about = Afficher les facteurs premiers du/des NOMBRE(s) donné(s).
2+
Si aucun n'est spécifié, lire depuis l'entrée standard.
3+
factor-usage = factor [OPTION]... [NOMBRE]...
4+
5+
# Messages d'aide
6+
factor-help-exponents = Afficher les facteurs sous la forme p^e
7+
factor-help-help = Afficher les informations d'aide.
8+
9+
# Messages d'erreur
10+
factor-error-factorization-incomplete = Factorisation incomplète. Des restes existent.
11+
factor-error-write-error = erreur d'écriture
12+
factor-error-reading-input = erreur de lecture de l'entrée : { $error }

src/uu/factor/src/factor.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// spell-checker:ignore funcs
77

8-
use std::collections::BTreeMap;
8+
use std::collections::{BTreeMap, HashMap};
99
use std::io::BufRead;
1010
use std::io::{self, Write, stdin, stdout};
1111

@@ -16,7 +16,7 @@ use uucore::display::Quotable;
1616
use uucore::error::{FromIo, UResult, USimpleError, set_exit_code};
1717
use uucore::{format_usage, show_error, show_warning};
1818

19-
use uucore::locale::get_message;
19+
use uucore::locale::{get_message, get_message_with_args};
2020

2121
mod options {
2222
pub static EXPONENTS: &str = "exponents";
@@ -46,11 +46,12 @@ fn print_factors_str(
4646
if let Some(_remaining) = remaining {
4747
return Err(USimpleError::new(
4848
1,
49-
"Factorization incomplete. Remainders exists.",
49+
get_message("factor-error-factorization-incomplete"),
5050
));
5151
}
5252

53-
write_result(w, &x, factorization, print_exponents).map_err_context(|| "write error".into())?;
53+
write_result(w, &x, factorization, print_exponents)
54+
.map_err_context(|| get_message("factor-error-write-error"))?;
5455

5556
Ok(())
5657
}
@@ -104,7 +105,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
104105
}
105106
Err(e) => {
106107
set_exit_code(1);
107-
show_error!("error reading input: {e}");
108+
show_error!(
109+
"{}",
110+
get_message_with_args(
111+
"factor-error-reading-input",
112+
HashMap::from([("error".to_string(), e.to_string())])
113+
)
114+
);
108115
return Ok(());
109116
}
110117
}
@@ -131,13 +138,13 @@ pub fn uu_app() -> Command {
131138
Arg::new(options::EXPONENTS)
132139
.short('h')
133140
.long(options::EXPONENTS)
134-
.help("Print factors in the form p^e")
141+
.help(get_message("factor-help-exponents"))
135142
.action(ArgAction::SetTrue),
136143
)
137144
.arg(
138145
Arg::new(options::HELP)
139146
.long(options::HELP)
140-
.help("Print help information.")
147+
.help(get_message("factor-help-help"))
141148
.action(ArgAction::Help),
142149
)
143150
}

0 commit comments

Comments
 (0)