Skip to content

Commit dc8063d

Browse files
committed
l10n(uucore::checksum): Implement l10n for English + French
1 parent a24dc47 commit dc8063d

File tree

6 files changed

+73
-37
lines changed

6 files changed

+73
-37
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,3 @@ cksum-help-quiet = don't print OK for each successfully verified file
2828
cksum-help-ignore-missing = don't fail or report status for missing files
2929
cksum-help-zero = end each output line with NUL, not newline, and disable file name escaping
3030
cksum-help-debug = print CPU hardware capability detection info used by cksum
31-
32-
# Error messages
33-
cksum-error-is-directory = { $file }: Is a directory
34-
cksum-error-failed-to-read-input = failed to read input

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,3 @@ cksum-help-quiet = ne pas afficher OK pour chaque fichier vérifié avec succès
2828
cksum-help-ignore-missing = ne pas échouer ou signaler le statut pour les fichiers manquants
2929
cksum-help-zero = terminer chaque ligne de sortie avec NUL, pas un saut de ligne, et désactiver l'échappement des noms de fichiers
3030
cksum-help-debug = afficher les informations de débogage sur la détection de la prise en charge matérielle du processeur
31-
32-
# Messages d'erreur
33-
cksum-error-is-directory = { $file } : Est un répertoire
34-
cksum-error-failed-to-read-input = échec de la lecture de l'entrée

src/uucore/locales/en-US.ftl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ error-io = I/O error
2929
error-permission-denied = Permission denied
3030
error-file-not-found = No such file or directory
3131
error-invalid-argument = Invalid argument
32+
error-is-a-directory = { $file }: Is a directory
3233
3334
# Common actions
3435
action-copying = copying
@@ -54,3 +55,21 @@ safe-traversal-error-unlink-failed = failed to unlink '{ $path }': { $source }
5455
safe-traversal-error-invalid-fd = invalid file descriptor
5556
safe-traversal-current-directory = <current directory>
5657
safe-traversal-directory = <directory>
58+
59+
# checksum-related messages
60+
checksum-no-properly-formatted = { $checksum_file }: no properly formatted checksum lines found
61+
checksum-no-file-verified = { $checksum_file }: no file was verified
62+
checksum-error-failed-to-read-input = failed to read input
63+
checksum-bad-format = { $count ->
64+
[1] { $count } line is improperly formatted
65+
*[other] { $count } lines are improperly formatted
66+
}
67+
checksum-failed-cksum = { $count ->
68+
[1] { $count } computed checksum did NOT match
69+
*[other] { $count } computed checksums did NOT match
70+
}
71+
checksum-failed-open-file = { $count ->
72+
[1] { $count } listed file could not be read
73+
*[other] { $count } listed files could not be read
74+
}
75+
checksum-error-algo-bad-format = { $file }: { $line }: improperly formatted { $algo } checksum line

src/uucore/locales/fr-FR.ftl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ error-io = Erreur E/S
2929
error-permission-denied = Permission refusée
3030
error-file-not-found = Aucun fichier ou répertoire de ce type
3131
error-invalid-argument = Argument invalide
32+
error-is-a-directory = { $file }: Est un répertoire
3233
3334
# Actions communes
3435
action-copying = copie
@@ -54,3 +55,21 @@ safe-traversal-error-unlink-failed = échec de la suppression de '{ $path }' : {
5455
safe-traversal-error-invalid-fd = descripteur de fichier invalide
5556
safe-traversal-current-directory = <répertoire courant>
5657
safe-traversal-directory = <répertoire>
58+
59+
# Messages relatifs au module checksum
60+
checksum-no-properly-formatted = { $checksum_file }: aucune ligne correctement formattée n'a été trouvée
61+
checksum-no-file-verified = { $checksum_file }: aucun fichier n'a été vérifié
62+
checksum-error-failed-to-read-input = échec de la lecture de l'entrée
63+
checksum-bad-format = { $count ->
64+
[1] { $count } ligne invalide
65+
*[other] { $count } lignes invalides
66+
}
67+
checksum-failed-cksum = { $count ->
68+
[1] { $count } somme de hachage ne correspond PAS
69+
*[other] { $count } sommes de hachage ne correspondent PAS
70+
}
71+
checksum-failed-open-file = { $count ->
72+
[1] { $count } fichier passé n'a pas pu être lu
73+
*[other] { $count } fichiers passés n'ont pas pu être lu
74+
}
75+
checksum-error-algo-bad-format = { $file }: { $line }: ligne invalide pour { $algo }

src/uucore/src/lib/features/checksum/compute.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,7 @@ where
257257
if filepath.is_dir() {
258258
show!(USimpleError::new(
259259
1,
260-
// TODO: Rework translation, which is broken since this code moved to uucore
261-
// translate!("cksum-error-is-directory", "file" => filepath.display())
262-
format!("{}: Is a directory", filepath.display())
260+
translate!("error-is-a-directory", "file" => filepath.display())
263261
));
264262
continue;
265263
}
@@ -285,7 +283,7 @@ where
285283
let mut digest = options.algo_kind.create_digest();
286284

287285
let (digest_output, sz) = digest_reader(&mut digest, &mut file, options.binary)
288-
.map_err_context(|| translate!("cksum-error-failed-to-read-input"))?;
286+
.map_err_context(|| translate!("checksum-error-failed-to-read-input"))?;
289287

290288
// Encodes the sum if df is Base64, leaves as-is otherwise.
291289
let encode_sum = |sum: DigestOutput, df: DigestFormat| {

src/uucore/src/lib/features/checksum/validate.rs

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::quoting_style::{QuotingStyle, locale_aware_escape_name};
1818
use crate::sum::DigestOutput;
1919
use crate::{
2020
os_str_as_bytes, os_str_from_bytes, read_os_string_lines, show, show_error, show_warning_caps,
21-
util_name,
21+
translate,
2222
};
2323

2424
/// To what level should checksum validation print logging info.
@@ -149,35 +149,44 @@ impl From<ChecksumError> for FileCheckError {
149149

150150
#[allow(clippy::comparison_chain)]
151151
fn print_cksum_report(res: &ChecksumResult) {
152-
if res.bad_format == 1 {
153-
show_warning_caps!("{} line is improperly formatted", res.bad_format);
154-
} else if res.bad_format > 1 {
155-
show_warning_caps!("{} lines are improperly formatted", res.bad_format);
152+
if res.bad_format > 0 {
153+
show_warning_caps!(
154+
"{}",
155+
translate!("checksum-bad-format", "count" => res.bad_format)
156+
);
156157
}
157158

158-
if res.failed_cksum == 1 {
159-
show_warning_caps!("{} computed checksum did NOT match", res.failed_cksum);
160-
} else if res.failed_cksum > 1 {
161-
show_warning_caps!("{} computed checksums did NOT match", res.failed_cksum);
159+
if res.failed_cksum > 0 {
160+
show_warning_caps!(
161+
"{}",
162+
translate!("checksum-failed-cksum", "count" => res.failed_cksum)
163+
);
162164
}
163165

164-
if res.failed_open_file == 1 {
165-
show_warning_caps!("{} listed file could not be read", res.failed_open_file);
166-
} else if res.failed_open_file > 1 {
167-
show_warning_caps!("{} listed files could not be read", res.failed_open_file);
166+
if res.failed_open_file > 0 {
167+
show_warning_caps!(
168+
"{}",
169+
translate!("checksum-failed-open-file", "count" => res.failed_open_file)
170+
);
168171
}
169172
}
170173

171174
/// Print a "no properly formatted lines" message in stderr
172175
#[inline]
173176
fn log_no_properly_formatted(filename: impl Display) {
174-
show_error!("{filename}: no properly formatted checksum lines found");
177+
show_error!(
178+
"{}",
179+
translate!("checksum-no-properly-formatted", "checksum_file" => filename)
180+
);
175181
}
176182

177183
/// Print a "no file was verified" message in stderr
178184
#[inline]
179185
fn log_no_file_verified(filename: impl Display) {
180-
show_error!("{filename}: no file was verified");
186+
show_error!(
187+
"{}",
188+
translate!("checksum-no-file-verified", "checksum_file" => filename)
189+
);
181190
}
182191

183192
/// Represents the different outcomes that can happen to a file
@@ -582,17 +591,18 @@ fn get_input_file(filename: &OsStr) -> UResult<Box<dyn Read>> {
582591
match File::open(filename) {
583592
Ok(f) => {
584593
if f.metadata()?.is_dir() {
585-
Err(
586-
io::Error::other(format!("{}: Is a directory", filename.to_string_lossy()))
587-
.into(),
594+
Err(io::Error::other(
595+
translate!("error-is-a-directory", "file" => filename.to_string_lossy()),
588596
)
597+
.into())
589598
} else {
590599
Ok(Box::new(f))
591600
}
592601
}
593602
Err(_) => Err(io::Error::other(format!(
594-
"{}: No such file or directory",
595-
filename.to_string_lossy()
603+
"{}: {}",
604+
filename.to_string_lossy(),
605+
translate!("error-file-not-found")
596606
))
597607
.into()),
598608
}
@@ -875,11 +885,9 @@ fn process_checksum_file(
875885
} else {
876886
"Unknown algorithm"
877887
};
878-
eprintln!(
879-
"{}: {}: {}: improperly formatted {algo} checksum line",
880-
util_name(),
881-
filename_input.maybe_quote(),
882-
i + 1,
888+
show_error!(
889+
"{}",
890+
translate!("checksum-error-algo-bad-format", "file" => filename_input.maybe_quote(), "line" => i + 1, "algo" => algo)
883891
);
884892
}
885893
}

0 commit comments

Comments
 (0)