From c659947136a1b7032078fcb33096d88537bc054f Mon Sep 17 00:00:00 2001 From: Dorian Peron Date: Fri, 30 Jan 2026 10:32:27 +0100 Subject: [PATCH] *sum: Fix locales fetching from `checksum_common` after installation --- GNUmakefile | 8 ++++++-- src/uucore/build.rs | 9 +++++++++ src/uucore/src/lib/mods/locale.rs | 8 ++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index b1c8ff2dce1..f57d9af1994 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -266,9 +266,13 @@ locales: fi; \ done - +# Some utils require extra locale files outside of their package: +# - *sum binaries need the files from checksum_common +INSTALLEES_WITH_EXTRA_LOCALE = \ + $(INSTALLEES) \ + $(if $(findstring sum, $(INSTALLEES)),checksum_common, ) install-locales: - @for prog in $(INSTALLEES); do \ + @for prog in $(INSTALLEES_WITH_EXTRA_LOCALE); do \ if [ -d "$(BASEDIR)/src/uu/$$prog/locales" ]; then \ mkdir -p "$(DESTDIR)$(DATAROOTDIR)/locales/$$prog"; \ for locale_file in "$(BASEDIR)"/src/uu/$$prog/locales/*.ftl; do \ diff --git a/src/uucore/build.rs b/src/uucore/build.rs index 935394cd4cc..6285e2438b5 100644 --- a/src/uucore/build.rs +++ b/src/uucore/build.rs @@ -144,6 +144,15 @@ fn embed_single_utility_locale( .join(format!("locales/{locale}.ftl")) })?; + if util_name.ends_with("sum") { + embed_component_locales( + embedded_file, + locales_to_embed, + "checksum_common", + |locale| project_root.join(format!("src/uu/checksum_common/locales/{locale}.ftl")), + )?; + } + // Always embed uucore locale file if it exists embed_component_locales(embedded_file, locales_to_embed, "uucore", |locale| { project_root.join(format!("src/uucore/locales/{locale}.ftl")) diff --git a/src/uucore/src/lib/mods/locale.rs b/src/uucore/src/lib/mods/locale.rs index a6dad4c6285..776cf3168be 100644 --- a/src/uucore/src/lib/mods/locale.rs +++ b/src/uucore/src/lib/mods/locale.rs @@ -261,6 +261,14 @@ fn create_english_bundle_from_embedded( bundle.add_resource_overriding(uucore_resource); } + // Checksum algorithms need locale messages from checksum_common + if util_name.ends_with("sum") { + if let Some(uucore_content) = get_embedded_locale("checksum_common/en-US.ftl") { + let uucore_resource = parse_fluent_resource(uucore_content)?; + bundle.add_resource_overriding(uucore_resource); + } + } + // Then, try to load utility-specific strings let locale_key = format!("{util_name}/en-US.ftl"); if let Some(ftl_content) = get_embedded_locale(&locale_key) {