mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge pull request #7981 from sylvestre/locale2
Improve the locale support
This commit is contained in:
commit
869660baaa
8 changed files with 904 additions and 140 deletions
1
.github/workflows/GnuTests.yml
vendored
1
.github/workflows/GnuTests.yml
vendored
|
@ -162,6 +162,7 @@ jobs:
|
|||
sudo locale-gen
|
||||
sudo locale-gen --keep-existing fr_FR
|
||||
sudo locale-gen --keep-existing fr_FR.UTF-8
|
||||
sudo locale-gen --keep-existing es_ES.UTF-8
|
||||
sudo locale-gen --keep-existing sv_SE
|
||||
sudo locale-gen --keep-existing sv_SE.UTF-8
|
||||
sudo locale-gen --keep-existing en_US
|
||||
|
|
3
.vscode/cSpell.json
vendored
3
.vscode/cSpell.json
vendored
|
@ -26,7 +26,8 @@
|
|||
"tests/**/fixtures/**",
|
||||
"src/uu/dd/test-resources/**",
|
||||
"vendor/**",
|
||||
"**/*.svg"
|
||||
"**/*.svg",
|
||||
"src/uu/*/locales/*.ftl"
|
||||
],
|
||||
|
||||
"enableGlobDot": true,
|
||||
|
|
30
GNUmakefile
30
GNUmakefile
|
@ -5,6 +5,7 @@ PROFILE ?= debug
|
|||
MULTICALL ?= n
|
||||
COMPLETIONS ?= y
|
||||
MANPAGES ?= y
|
||||
LOCALES ?= y
|
||||
INSTALL ?= install
|
||||
ifneq (,$(filter install, $(MAKECMDGOALS)))
|
||||
override PROFILE:=release
|
||||
|
@ -300,7 +301,7 @@ else
|
|||
endif
|
||||
endif
|
||||
|
||||
build-coreutils:
|
||||
build-coreutils: locales
|
||||
${CARGO} build ${CARGOFLAGS} --features "${EXES} $(BUILD_SPEC_FEATURE)" ${PROFILE_CMD} --no-default-features
|
||||
|
||||
build: build-coreutils build-pkgs
|
||||
|
@ -396,7 +397,32 @@ else
|
|||
install-completions:
|
||||
endif
|
||||
|
||||
install: build install-manpages install-completions
|
||||
ifeq ($(LOCALES),y)
|
||||
locales:
|
||||
$(foreach prog, $(INSTALLEES), \
|
||||
if [ -d "$(BASEDIR)/src/uu/$(prog)/locales" ]; then \
|
||||
mkdir -p "$(BUILDDIR)/locales/$(prog)"; \
|
||||
for locale_file in "$(BASEDIR)"/src/uu/$(prog)/locales/*.ftl; do \
|
||||
$(INSTALL) -v "$$locale_file" "$(BUILDDIR)/locales/$(prog)/"; \
|
||||
done; \
|
||||
fi $(newline) \
|
||||
)
|
||||
|
||||
|
||||
install-locales:
|
||||
$(foreach prog, $(INSTALLEES), \
|
||||
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 \
|
||||
$(INSTALL) -v "$$locale_file" "$(DESTDIR)$(DATAROOTDIR)/locales/$(prog)/"; \
|
||||
done; \
|
||||
fi $(newline) \
|
||||
)
|
||||
else
|
||||
install-locales:
|
||||
endif
|
||||
|
||||
install: build install-manpages install-completions install-locales
|
||||
mkdir -p $(INSTALLDIR_BIN)
|
||||
ifeq (${MULTICALL}, y)
|
||||
$(INSTALL) $(BUILDDIR)/coreutils $(INSTALLDIR_BIN)/$(PROG_PREFIX)coreutils
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
# arch
|
||||
|
||||
```
|
||||
arch
|
||||
```
|
||||
|
||||
Display machine architecture
|
||||
|
||||
## After Help
|
||||
|
||||
Determine architecture name for current machine.
|
5
src/uu/arch/locales/en-US.ftl
Normal file
5
src/uu/arch/locales/en-US.ftl
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Error message when system architecture information cannot be retrieved
|
||||
cannot-get-system = cannot get system name
|
||||
|
||||
arch-about = Display machine architecture
|
||||
arch-after-help = Determine architecture name for current machine.
|
5
src/uu/arch/locales/fr-FR.ftl
Normal file
5
src/uu/arch/locales/fr-FR.ftl
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Error message when system architecture information cannot be retrieved
|
||||
cannot-get-system = impossible d'obtenir le nom du système
|
||||
|
||||
arch-about = Afficher l'architecture de la machine
|
||||
arch-after-help = Déterminer le nom de l'architecture pour la machine actuelle.
|
|
@ -7,16 +7,15 @@ use platform_info::*;
|
|||
|
||||
use clap::Command;
|
||||
use uucore::error::{UResult, USimpleError};
|
||||
use uucore::{help_about, help_section};
|
||||
|
||||
static ABOUT: &str = help_about!("arch.md");
|
||||
static SUMMARY: &str = help_section!("after help", "arch.md");
|
||||
use uucore::locale::{self, get_message};
|
||||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
locale::setup_localization(uucore::util_name())?;
|
||||
uu_app().try_get_matches_from(args)?;
|
||||
|
||||
let uts = PlatformInfo::new().map_err(|_e| USimpleError::new(1, "cannot get system name"))?;
|
||||
let uts =
|
||||
PlatformInfo::new().map_err(|_e| USimpleError::new(1, get_message("cannot-get-system")))?;
|
||||
|
||||
println!("{}", uts.machine().to_string_lossy().trim());
|
||||
Ok(())
|
||||
|
@ -25,7 +24,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
pub fn uu_app() -> Command {
|
||||
Command::new(uucore::util_name())
|
||||
.version(uucore::crate_version!())
|
||||
.about(ABOUT)
|
||||
.after_help(SUMMARY)
|
||||
.about(get_message("arch-about"))
|
||||
.after_help(get_message("arch-after-help"))
|
||||
.infer_long_args(true)
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue