Skip to content

Commit 935f0a9

Browse files
committed
l10n(uucore::checksum): Implement l10n for English + French
1 parent b823ac2 commit 935f0a9

File tree

6 files changed

+73
-38
lines changed

6 files changed

+73
-38
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
@@ -255,9 +255,7 @@ where
255255
if filepath.is_dir() {
256256
show!(USimpleError::new(
257257
1,
258-
// TODO: Rework translation, which is broken since this code moved to uucore
259-
// translate!("cksum-error-is-directory", "file" => filepath.display())
260-
format!("{}: Is a directory", filepath.display())
258+
translate!("error-is-a-directory", "file" => filepath.display())
261259
));
262260
continue;
263261
}
@@ -283,7 +281,7 @@ where
283281
let mut digest = options.algo_kind.create_digest();
284282

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

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

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

Lines changed: 33 additions & 26 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.
@@ -147,37 +147,45 @@ impl From<ChecksumError> for FileCheckError {
147147
}
148148
}
149149

150-
#[allow(clippy::comparison_chain)]
151150
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);
151+
if res.bad_format > 0 {
152+
show_warning_caps!(
153+
"{}",
154+
translate!("checksum-bad-format", "count" => res.bad_format)
155+
);
156156
}
157157

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);
158+
if res.failed_cksum > 0 {
159+
show_warning_caps!(
160+
"{}",
161+
translate!("checksum-failed-cksum", "count" => res.failed_cksum)
162+
);
162163
}
163164

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);
165+
if res.failed_open_file > 0 {
166+
show_warning_caps!(
167+
"{}",
168+
translate!("checksum-failed-open-file", "count" => res.failed_open_file)
169+
);
168170
}
169171
}
170172

171173
/// Print a "no properly formatted lines" message in stderr
172174
#[inline]
173175
fn log_no_properly_formatted(filename: impl Display) {
174-
show_error!("{filename}: no properly formatted checksum lines found");
176+
show_error!(
177+
"{}",
178+
translate!("checksum-no-properly-formatted", "checksum_file" => filename)
179+
);
175180
}
176181

177182
/// Print a "no file was verified" message in stderr
178183
#[inline]
179184
fn log_no_file_verified(filename: impl Display) {
180-
show_error!("{filename}: no file was verified");
185+
show_error!(
186+
"{}",
187+
translate!("checksum-no-file-verified", "checksum_file" => filename)
188+
);
181189
}
182190

183191
/// Represents the different outcomes that can happen to a file
@@ -582,17 +590,18 @@ fn get_input_file(filename: &OsStr) -> UResult<Box<dyn Read>> {
582590
match File::open(filename) {
583591
Ok(f) => {
584592
if f.metadata()?.is_dir() {
585-
Err(
586-
io::Error::other(format!("{}: Is a directory", filename.to_string_lossy()))
587-
.into(),
593+
Err(io::Error::other(
594+
translate!("error-is-a-directory", "file" => filename.to_string_lossy()),
588595
)
596+
.into())
589597
} else {
590598
Ok(Box::new(f))
591599
}
592600
}
593601
Err(_) => Err(io::Error::other(format!(
594-
"{}: No such file or directory",
595-
filename.to_string_lossy()
602+
"{}: {}",
603+
filename.to_string_lossy(),
604+
translate!("error-file-not-found")
596605
))
597606
.into()),
598607
}
@@ -875,11 +884,9 @@ fn process_checksum_file(
875884
} else {
876885
"Unknown algorithm"
877886
};
878-
eprintln!(
879-
"{}: {}: {}: improperly formatted {algo} checksum line",
880-
util_name(),
881-
filename_input.maybe_quote(),
882-
i + 1,
887+
show_error!(
888+
"{}",
889+
translate!("checksum-error-algo-bad-format", "file" => filename_input.maybe_quote(), "line" => i + 1, "algo" => algo)
883890
);
884891
}
885892
}

0 commit comments

Comments
 (0)