mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #8184 from sylvestre/l10n-mktemp
l10n: port mktemp for translation + add french
This commit is contained in:
commit
a5a84a9524
3 changed files with 75 additions and 38 deletions
|
@ -1,2 +1,26 @@
|
||||||
mktemp-about = Create a temporary file or directory.
|
mktemp-about = Create a temporary file or directory.
|
||||||
mktemp-usage = mktemp [OPTION]... [TEMPLATE]
|
mktemp-usage = mktemp [OPTION]... [TEMPLATE]
|
||||||
|
|
||||||
|
# Help messages
|
||||||
|
mktemp-help-directory = Make a directory instead of a file
|
||||||
|
mktemp-help-dry-run = do not create anything; merely print a name (unsafe)
|
||||||
|
mktemp-help-quiet = Fail silently if an error occurs.
|
||||||
|
mktemp-help-suffix = append SUFFIX to TEMPLATE; SUFFIX must not contain a path separator. This option is implied if TEMPLATE does not end with X.
|
||||||
|
mktemp-help-p = short form of --tmpdir
|
||||||
|
mktemp-help-tmpdir = interpret TEMPLATE relative to DIR; if DIR is not specified, use $TMPDIR ($TMP on windows) if set, else /tmp. With this option, TEMPLATE must not be an absolute name; unlike with -t, TEMPLATE may contain slashes, but mktemp creates only the final component
|
||||||
|
mktemp-help-t = Generate a template (using the supplied prefix and TMPDIR (TMP on windows) if set) to create a filename template [deprecated]
|
||||||
|
|
||||||
|
# Error messages
|
||||||
|
mktemp-error-persist-file = could not persist file { $path }
|
||||||
|
mktemp-error-must-end-in-x = with --suffix, template { $template } must end in X
|
||||||
|
mktemp-error-too-few-xs = too few X's in template { $template }
|
||||||
|
mktemp-error-prefix-contains-separator = invalid template, { $template }, contains directory separator
|
||||||
|
mktemp-error-suffix-contains-separator = invalid suffix { $suffix }, contains directory separator
|
||||||
|
mktemp-error-invalid-template = invalid template, { $template }; with --tmpdir, it may not be absolute
|
||||||
|
mktemp-error-too-many-templates = too many templates
|
||||||
|
mktemp-error-not-found = failed to create { $template_type } via template { $template }: No such file or directory
|
||||||
|
mktemp-error-failed-print = failed to print directory name
|
||||||
|
|
||||||
|
# Template types
|
||||||
|
mktemp-template-type-directory = directory
|
||||||
|
mktemp-template-type-file = file
|
||||||
|
|
26
src/uu/mktemp/locales/fr-FR.ftl
Normal file
26
src/uu/mktemp/locales/fr-FR.ftl
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
mktemp-about = Créer un fichier ou répertoire temporaire.
|
||||||
|
mktemp-usage = mktemp [OPTION]... [MODÈLE]
|
||||||
|
|
||||||
|
# Messages d'aide
|
||||||
|
mktemp-help-directory = Créer un répertoire au lieu d'un fichier
|
||||||
|
mktemp-help-dry-run = ne rien créer ; afficher seulement un nom (dangereux)
|
||||||
|
mktemp-help-quiet = Échouer silencieusement si une erreur se produit.
|
||||||
|
mktemp-help-suffix = ajouter SUFFIXE au MODÈLE ; SUFFIXE ne doit pas contenir un séparateur de chemin. Cette option est implicite si MODÈLE ne se termine pas par X.
|
||||||
|
mktemp-help-p = forme courte de --tmpdir
|
||||||
|
mktemp-help-tmpdir = interpréter MODÈLE relativement à RÉP ; si RÉP n'est pas spécifié, utiliser $TMPDIR ($TMP sur windows) si défini, sinon /tmp. Avec cette option, MODÈLE ne doit pas être un nom absolu ; contrairement à -t, MODÈLE peut contenir des barres obliques, mais mktemp ne crée que le composant final
|
||||||
|
mktemp-help-t = Générer un modèle (en utilisant le préfixe fourni et TMPDIR (TMP sur windows) si défini) pour créer un modèle de nom de fichier [obsolète]
|
||||||
|
|
||||||
|
# Messages d'erreur
|
||||||
|
mktemp-error-persist-file = impossible de conserver le fichier { $path }
|
||||||
|
mktemp-error-must-end-in-x = avec --suffix, le modèle { $template } doit se terminer par X
|
||||||
|
mktemp-error-too-few-xs = trop peu de X dans le modèle { $template }
|
||||||
|
mktemp-error-prefix-contains-separator = modèle invalide, { $template }, contient un séparateur de répertoire
|
||||||
|
mktemp-error-suffix-contains-separator = suffixe invalide { $suffix }, contient un séparateur de répertoire
|
||||||
|
mktemp-error-invalid-template = modèle invalide, { $template } ; avec --tmpdir, il ne peut pas être absolu
|
||||||
|
mktemp-error-too-many-templates = trop de modèles
|
||||||
|
mktemp-error-not-found = échec de la création de { $template_type } via le modèle { $template } : Aucun fichier ou répertoire de ce type
|
||||||
|
mktemp-error-failed-print = échec de l'affichage du nom de répertoire
|
||||||
|
|
||||||
|
# Types de modèle
|
||||||
|
mktemp-template-type-directory = répertoire
|
||||||
|
mktemp-template-type-file = fichier
|
|
@ -9,7 +9,9 @@ use clap::{Arg, ArgAction, ArgMatches, Command, builder::ValueParser};
|
||||||
use uucore::display::{Quotable, println_verbatim};
|
use uucore::display::{Quotable, println_verbatim};
|
||||||
use uucore::error::{FromIo, UError, UResult, UUsageError};
|
use uucore::error::{FromIo, UError, UResult, UUsageError};
|
||||||
use uucore::format_usage;
|
use uucore::format_usage;
|
||||||
|
use uucore::locale::{get_message, get_message_with_args};
|
||||||
|
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::io::ErrorKind;
|
use std::io::ErrorKind;
|
||||||
|
@ -25,8 +27,6 @@ use rand::Rng;
|
||||||
use tempfile::Builder;
|
use tempfile::Builder;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use uucore::locale::get_message;
|
|
||||||
|
|
||||||
static DEFAULT_TEMPLATE: &str = "tmp.XXXXXXXXXX";
|
static DEFAULT_TEMPLATE: &str = "tmp.XXXXXXXXXX";
|
||||||
|
|
||||||
static OPT_DIRECTORY: &str = "directory";
|
static OPT_DIRECTORY: &str = "directory";
|
||||||
|
@ -44,35 +44,30 @@ const TMPDIR_ENV_VAR: &str = "TMPDIR";
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
const TMPDIR_ENV_VAR: &str = "TMP";
|
const TMPDIR_ENV_VAR: &str = "TMP";
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Error, Debug)]
|
||||||
enum MkTempError {
|
enum MkTempError {
|
||||||
#[error("could not persist file {path}", path = .0.quote())]
|
#[error("{}", get_message_with_args("mktemp-error-persist-file", HashMap::from([("path".to_string(), .0.quote().to_string())])))]
|
||||||
PersistError(PathBuf),
|
PersistError(PathBuf),
|
||||||
|
|
||||||
#[error("with --suffix, template {template} must end in X", template = .0.quote())]
|
#[error("{}", get_message_with_args("mktemp-error-must-end-in-x", HashMap::from([("template".to_string(), .0.quote().to_string())])))]
|
||||||
MustEndInX(String),
|
MustEndInX(String),
|
||||||
|
|
||||||
#[error("too few X's in template {template}", template = .0.quote())]
|
#[error("{}", get_message_with_args("mktemp-error-too-few-xs", HashMap::from([("template".to_string(), .0.quote().to_string())])))]
|
||||||
TooFewXs(String),
|
TooFewXs(String),
|
||||||
|
|
||||||
/// The template prefix contains a path separator (e.g. `"a/bXXX"`).
|
#[error("{}", get_message_with_args("mktemp-error-prefix-contains-separator", HashMap::from([("template".to_string(), .0.quote().to_string())])))]
|
||||||
#[error("invalid template, {template}, contains directory separator", template = .0.quote())]
|
|
||||||
PrefixContainsDirSeparator(String),
|
PrefixContainsDirSeparator(String),
|
||||||
|
|
||||||
/// The template suffix contains a path separator (e.g. `"XXXa/b"`).
|
#[error("{}", get_message_with_args("mktemp-error-suffix-contains-separator", HashMap::from([("suffix".to_string(), .0.quote().to_string())])))]
|
||||||
#[error("invalid suffix {suffix}, contains directory separator", suffix = .0.quote())]
|
|
||||||
SuffixContainsDirSeparator(String),
|
SuffixContainsDirSeparator(String),
|
||||||
|
|
||||||
#[error("invalid template, {template}; with --tmpdir, it may not be absolute", template = .0.quote())]
|
#[error("{}", get_message_with_args("mktemp-error-invalid-template", HashMap::from([("template".to_string(), .0.quote().to_string())])))]
|
||||||
InvalidTemplate(String),
|
InvalidTemplate(String),
|
||||||
|
|
||||||
#[error("too many templates")]
|
#[error("{}", get_message("mktemp-error-too-many-templates"))]
|
||||||
TooManyTemplates,
|
TooManyTemplates,
|
||||||
|
|
||||||
/// When a specified temporary directory could not be found.
|
#[error("{}", get_message_with_args("mktemp-error-not-found", HashMap::from([("template_type".to_string(), .0.clone()), ("template".to_string(), .1.quote().to_string())])))]
|
||||||
#[error("failed to create {template_type} via template {template}: No such file or directory",
|
|
||||||
template_type = .0,
|
|
||||||
template = .1.quote())]
|
|
||||||
NotFound(String, String),
|
NotFound(String, String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +290,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
&& val == &clap::error::ContextValue::String("[template]".into())
|
&& val == &clap::error::ContextValue::String("[template]".into())
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
return Err(UUsageError::new(1, "too many templates"));
|
return Err(UUsageError::new(
|
||||||
|
1,
|
||||||
|
get_message("mktemp-error-too-many-templates"),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
return Err(e.into());
|
return Err(e.into());
|
||||||
}
|
}
|
||||||
|
@ -340,7 +338,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
} else {
|
} else {
|
||||||
res
|
res
|
||||||
};
|
};
|
||||||
println_verbatim(res?).map_err_context(|| "failed to print directory name".to_owned())
|
println_verbatim(res?).map_err_context(|| get_message("mktemp-error-failed-print"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> Command {
|
pub fn uu_app() -> Command {
|
||||||
|
@ -353,36 +351,33 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(OPT_DIRECTORY)
|
Arg::new(OPT_DIRECTORY)
|
||||||
.short('d')
|
.short('d')
|
||||||
.long(OPT_DIRECTORY)
|
.long(OPT_DIRECTORY)
|
||||||
.help("Make a directory instead of a file")
|
.help(get_message("mktemp-help-directory"))
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_DRY_RUN)
|
Arg::new(OPT_DRY_RUN)
|
||||||
.short('u')
|
.short('u')
|
||||||
.long(OPT_DRY_RUN)
|
.long(OPT_DRY_RUN)
|
||||||
.help("do not create anything; merely print a name (unsafe)")
|
.help(get_message("mktemp-help-dry-run"))
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_QUIET)
|
Arg::new(OPT_QUIET)
|
||||||
.short('q')
|
.short('q')
|
||||||
.long("quiet")
|
.long("quiet")
|
||||||
.help("Fail silently if an error occurs.")
|
.help(get_message("mktemp-help-quiet"))
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_SUFFIX)
|
Arg::new(OPT_SUFFIX)
|
||||||
.long(OPT_SUFFIX)
|
.long(OPT_SUFFIX)
|
||||||
.help(
|
.help(get_message("mktemp-help-suffix"))
|
||||||
"append SUFFIX to TEMPLATE; SUFFIX must not contain a path separator. \
|
|
||||||
This option is implied if TEMPLATE does not end with X.",
|
|
||||||
)
|
|
||||||
.value_name("SUFFIX"),
|
.value_name("SUFFIX"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_P)
|
Arg::new(OPT_P)
|
||||||
.short('p')
|
.short('p')
|
||||||
.help("short form of --tmpdir")
|
.help(get_message("mktemp-help-p"))
|
||||||
.value_name("DIR")
|
.value_name("DIR")
|
||||||
.num_args(1)
|
.num_args(1)
|
||||||
.value_parser(ValueParser::path_buf())
|
.value_parser(ValueParser::path_buf())
|
||||||
|
@ -391,12 +386,7 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_TMPDIR)
|
Arg::new(OPT_TMPDIR)
|
||||||
.long(OPT_TMPDIR)
|
.long(OPT_TMPDIR)
|
||||||
.help(
|
.help(get_message("mktemp-help-tmpdir"))
|
||||||
"interpret TEMPLATE relative to DIR; if DIR is not specified, use \
|
|
||||||
$TMPDIR ($TMP on windows) if set, else /tmp. With this option, \
|
|
||||||
TEMPLATE must not be an absolute name; unlike with -t, TEMPLATE \
|
|
||||||
may contain slashes, but mktemp creates only the final component",
|
|
||||||
)
|
|
||||||
.value_name("DIR")
|
.value_name("DIR")
|
||||||
// Allows use of default argument just by setting --tmpdir. Else,
|
// Allows use of default argument just by setting --tmpdir. Else,
|
||||||
// use provided input to generate tmpdir
|
// use provided input to generate tmpdir
|
||||||
|
@ -410,10 +400,7 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(OPT_T)
|
Arg::new(OPT_T)
|
||||||
.short('t')
|
.short('t')
|
||||||
.help(
|
.help(get_message("mktemp-help-t"))
|
||||||
"Generate a template (using the supplied prefix and TMPDIR \
|
|
||||||
(TMP on windows) if set) to create a filename template [deprecated]",
|
|
||||||
)
|
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(Arg::new(ARG_TEMPLATE).num_args(..=1))
|
.arg(Arg::new(ARG_TEMPLATE).num_args(..=1))
|
||||||
|
@ -475,7 +462,7 @@ fn make_temp_dir(dir: &Path, prefix: &str, rand: usize, suffix: &str) -> UResult
|
||||||
let filename = format!("{prefix}{}{suffix}", "X".repeat(rand));
|
let filename = format!("{prefix}{}{suffix}", "X".repeat(rand));
|
||||||
let path = Path::new(dir).join(filename);
|
let path = Path::new(dir).join(filename);
|
||||||
let s = path.display().to_string();
|
let s = path.display().to_string();
|
||||||
Err(MkTempError::NotFound("directory".to_string(), s).into())
|
Err(MkTempError::NotFound(get_message("mktemp-template-type-directory"), s).into())
|
||||||
}
|
}
|
||||||
Err(e) => Err(e.into()),
|
Err(e) => Err(e.into()),
|
||||||
}
|
}
|
||||||
|
@ -505,7 +492,7 @@ fn make_temp_file(dir: &Path, prefix: &str, rand: usize, suffix: &str) -> UResul
|
||||||
let filename = format!("{prefix}{}{suffix}", "X".repeat(rand));
|
let filename = format!("{prefix}{}{suffix}", "X".repeat(rand));
|
||||||
let path = Path::new(dir).join(filename);
|
let path = Path::new(dir).join(filename);
|
||||||
let s = path.display().to_string();
|
let s = path.display().to_string();
|
||||||
Err(MkTempError::NotFound("file".to_string(), s).into())
|
Err(MkTempError::NotFound(get_message("mktemp-template-type-file"), s).into())
|
||||||
}
|
}
|
||||||
Err(e) => Err(e.into()),
|
Err(e) => Err(e.into()),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue