From 31257b3857c4538b218f7835a1f78e017b6dbb13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Flor=C3=A9al=20Cabanettes?= Date: Tue, 17 Mar 2026 11:40:40 +0100 Subject: [PATCH 1/2] Add locale support --- dfb | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/dfb b/dfb index aac3cac..dc52d1a 100755 --- a/dfb +++ b/dfb @@ -19,7 +19,23 @@ dfbar() { typeset dfopt=( -T -x fuse.snapfuse -x overlay -x rootfs -x devtmpfs -x efivarfs ) all df="${df:-df}" [[ " $*" = *\ -*a ]] && dfopt=( -T ) && all=1; set -o pipefail - $df -P "${dfopt[@]}" "$@" | awk -v sym1="$DFBAR_BEGIN" -v sym2="$DFBAR_END" -v all=$all -v col="$DFBAR_COLORS" ' + + # --- TRANSLATION THROUGH GETTEXT --- + # We ask translation for stadard words of df. + # If language is not installed, english is kept. + local h1=$(gettext "coreutils" "Filesystem") + local h2=$(gettext "coreutils" "Type") + local h3=$(gettext "coreutils" "Size") + local h4=$(gettext "coreutils" "Used") + local h5=$(gettext "coreutils" "Available") + local h6=$(gettext "coreutils" "Capacity") + local h7=$(gettext "coreutils" "Mounted on") + + # --- DATA TREATMENT --- + LC_ALL=C $df -P "${dfopt[@]}" "$@" | awk \ + -v sym1="$DFBAR_BEGIN" -v sym2="$DFBAR_END" \ + -v all=$all -v col="$DFBAR_COLORS" \ + -v h1="$h1" -v h2="$h2" -v h3="$h3" -v h4="$h4" -v h5="$h5" -v h6="$h6" -v h7="$h7" ' BEGIN { barlen=10 esc="\033[" @@ -50,13 +66,12 @@ dfbar() { printf esc "?7l" # disable line wrapping getline + + # Ignore brut english line of df, replace by translated version: + h[1]=h1; h[2]=h2; h[3]=h3; h[4]=h4; h[5]=h5; h[6]=h6; h[7]=h7 + # initialize widths with header lengths - for(i=1;i<7;i++) { - h[i]=$i - w[i]=length($i) - } - h[7]=$7 " " $8 # Mounted on - w[7]=length(h[7]) + for(i=1;i<=7;i++) w[i]=length(h[i]) if(barlen>w[6]) w[6]=barlen } ! all && $2 == "tmpfs" && $NF != "/tmp" { next } From e550042e5f47776f98f7c27fb6bb9b7f8423268b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Flor=C3=A9al=20Cabanettes?= Date: Tue, 17 Mar 2026 11:48:30 +0100 Subject: [PATCH 2/2] Don't format for help and version args --- dfb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dfb b/dfb index dc52d1a..db0d804 100755 --- a/dfb +++ b/dfb @@ -16,6 +16,12 @@ type gdf >/dev/null 2>&1 && df=gdf || df=df : ${DFBAR_END:=''} dfbar() { + # Ignore format for help and version + for arg in "$@"; do + if [[ "$arg" == "--help" || "$arg" == "--version" ]]; then + exec $df "$@" + fi + done typeset dfopt=( -T -x fuse.snapfuse -x overlay -x rootfs -x devtmpfs -x efivarfs ) all df="${df:-df}" [[ " $*" = *\ -*a ]] && dfopt=( -T ) && all=1; set -o pipefail