From 63ef7c9a1dad3194c1a1958ef58cf8d408ab56be Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 5 Jun 2025 00:02:05 +0200 Subject: [PATCH] l10n: port hostname to translation + add french --- src/uu/hostname/locales/en-US.ftl | 11 +++++++++++ src/uu/hostname/locales/fr-FR.ftl | 13 +++++++++++++ src/uu/hostname/src/hostname.rs | 14 ++++++++------ 3 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 src/uu/hostname/locales/fr-FR.ftl diff --git a/src/uu/hostname/locales/en-US.ftl b/src/uu/hostname/locales/en-US.ftl index 8ad9ab52e..f7a9a26a8 100644 --- a/src/uu/hostname/locales/en-US.ftl +++ b/src/uu/hostname/locales/en-US.ftl @@ -1,2 +1,13 @@ hostname-about = Display or set the system's host name. hostname-usage = hostname [OPTION]... [HOSTNAME] +hostname-help-domain = Display the name of the DNS domain if possible +hostname-help-ip-address = Display the network address(es) of the host +hostname-help-fqdn = Display the FQDN (Fully Qualified Domain Name) (default) +hostname-help-short = Display the short hostname (the portion before the first dot) if possible +hostname-error-permission = hostname: you must be root to change the host name +hostname-error-invalid-name = hostname: invalid hostname '{ $name }' +hostname-error-resolve-failed = hostname: unable to resolve host name '{ $name }' +hostname-error-winsock = failed to start Winsock +hostname-error-set-hostname = failed to set hostname +hostname-error-get-hostname = failed to get hostname +hostname-error-resolve-socket = failed to resolve socket addresses diff --git a/src/uu/hostname/locales/fr-FR.ftl b/src/uu/hostname/locales/fr-FR.ftl new file mode 100644 index 000000000..700b5ff40 --- /dev/null +++ b/src/uu/hostname/locales/fr-FR.ftl @@ -0,0 +1,13 @@ +hostname-about = Afficher ou définir le nom d'hôte du système. +hostname-usage = hostname [OPTION]... [NOM_HÔTE] +hostname-help-domain = Afficher le nom du domaine DNS si possible +hostname-help-ip-address = Afficher la ou les adresses réseau de l'hôte +hostname-help-fqdn = Afficher le FQDN (nom de domaine pleinement qualifié) (par défaut) +hostname-help-short = Afficher le nom d'hôte court (la partie avant le premier point) si possible +hostname-error-permission = hostname : vous devez être root pour changer le nom d'hôte +hostname-error-invalid-name = hostname : nom d'hôte invalide '{ $name }' +hostname-error-resolve-failed = hostname : impossible de résoudre le nom d'hôte '{ $name }' +hostname-error-winsock = échec du démarrage de Winsock +hostname-error-set-hostname = échec de la définition du nom d'hôte +hostname-error-get-hostname = échec de l'obtention du nom d'hôte +hostname-error-resolve-socket = échec de la résolution des adresses de socket diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs index 05252883e..530f44500 100644 --- a/src/uu/hostname/src/hostname.rs +++ b/src/uu/hostname/src/hostname.rs @@ -63,11 +63,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().try_get_matches_from(args)?; #[cfg(windows)] - let _handle = wsa::start().map_err_context(|| "failed to start Winsock".to_owned())?; + let _handle = wsa::start().map_err_context(|| get_message("hostname-error-winsock"))?; match matches.get_one::(OPT_HOST) { None => display_hostname(&matches), - Some(host) => hostname::set(host).map_err_context(|| "failed to set hostname".to_owned()), + Some(host) => { + hostname::set(host).map_err_context(|| get_message("hostname-error-set-hostname")) + } } } @@ -82,7 +84,7 @@ pub fn uu_app() -> Command { .short('d') .long("domain") .overrides_with_all([OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT]) - .help("Display the name of the DNS domain if possible") + .help(get_message("hostname-help-domain")) .action(ArgAction::SetTrue), ) .arg( @@ -90,7 +92,7 @@ pub fn uu_app() -> Command { .short('i') .long("ip-address") .overrides_with_all([OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT]) - .help("Display the network address(es) of the host") + .help(get_message("hostname-help-ip-address")) .action(ArgAction::SetTrue), ) .arg( @@ -98,7 +100,7 @@ pub fn uu_app() -> Command { .short('f') .long("fqdn") .overrides_with_all([OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT]) - .help("Display the FQDN (Fully Qualified Domain Name) (default)") + .help(get_message("hostname-help-fqdn")) .action(ArgAction::SetTrue), ) .arg( @@ -106,7 +108,7 @@ pub fn uu_app() -> Command { .short('s') .long("short") .overrides_with_all([OPT_DOMAIN, OPT_IP_ADDRESS, OPT_FQDN, OPT_SHORT]) - .help("Display the short hostname (the portion before the first dot) if possible") + .help(get_message("hostname-help-short")) .action(ArgAction::SetTrue), ) .arg(