Files
org.parres.whitenoise/scripts/validate-locales-keys.sh
JeffGandGitHub d01e480dfa feat(widgets): add WnProfileSwitcherItem component (#188)
* feat(widgets): add WnProfileSwitcherItem component

- Create reusable profile switcher item for switch profile screen
- Use WnAvatarSize.medium (56px) per Figma specs
- Use WnMiddleEllipsisText for npub display with middle truncation
- Add widgetbook showcase with real npub examples
- Refactor SwitchProfileScreen to use new component

Closes #141

* fix: rename sloth package imports to whitenoise and fix l10n validation

- Update wn_profile_switcher_item imports from sloth to whitenoise
- Update test and widgetbook imports from sloth to whitenoise
- Fix validate-locales-keys.sh to use LC_ALL=C for consistent sorting
- Include auto-generated plugin registrant updates

* refactor: compute formatted pubkey once in WnProfileSwitcherItem build

Extract formatPublicKey(npubFromHex(pubkey) ?? pubkey) into a local
final variable to avoid duplicate computation in the build method.
2026-02-06 11:54:47 +01:00

87 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
set -eo pipefail
# Use C locale for consistent sorting across different environments
export LC_ALL=C
TEMPLATE="${1:-lib/l10n/app_en.arb}"
ERRORS=0
MISSING_COUNT=0
EXTRA_COUNT=0
JQ_STDERR=$(mktemp)
trap 'rm -f "$JQ_STDERR"' EXIT
echo "=== L10n Validation ==="
echo "Template: $TEMPLATE"
if [ ! -f "$TEMPLATE" ]; then
echo "❌ Template file not found: $TEMPLATE"
exit 1
fi
if ! TEMPLATE_KEYS=$(jq -r 'keys[] | select(startswith("@") | not)' "$TEMPLATE" 2>"$JQ_STDERR" | sort); then
echo "❌ Failed to parse template $TEMPLATE:"
sed 's/^/ /' "$JQ_STDERR"
exit 1
fi
echo "Template keys: $(echo "$TEMPLATE_KEYS" | wc -l | tr -d ' ')"
echo ""
L10N_DIR=$(dirname "$TEMPLATE")
for ARB in "$L10N_DIR"/app_*.arb; do
if [ "$ARB" = "$TEMPLATE" ]; then
continue
fi
LANG=$(basename "$ARB" .arb | sed 's/app_//')
if ! ARB_KEYS=$(jq -r 'keys[] | select(startswith("@") | not)' "$ARB" 2>"$JQ_STDERR" | sort); then
echo "❌ $LANG: Failed to parse ARB file:"
sed 's/^/ /' "$JQ_STDERR"
ERRORS=$((ERRORS + 1))
continue
fi
MISSING=$(comm -23 <(echo "$TEMPLATE_KEYS") <(echo "$ARB_KEYS"))
EXTRA=$(comm -13 <(echo "$TEMPLATE_KEYS") <(echo "$ARB_KEYS"))
HAS_ERROR=0
if [ -n "$MISSING" ]; then
echo "❌ $LANG: Missing keys:"
echo "$MISSING" | sed 's/^/ - /'
MISSING_COUNT=$((MISSING_COUNT + 1))
HAS_ERROR=1
fi
if [ -n "$EXTRA" ]; then
echo "❌ $LANG: Extra/orphaned keys (not in template):"
echo "$EXTRA" | sed 's/^/ - /'
EXTRA_COUNT=$((EXTRA_COUNT + 1))
HAS_ERROR=1
fi
if [ $HAS_ERROR -eq 1 ]; then
ERRORS=$((ERRORS + 1))
else
echo "✅ $LANG: All keys valid"
fi
done
echo ""
if [ $ERRORS -gt 0 ]; then
ERROR_DETAILS=""
[ $MISSING_COUNT -gt 0 ] && ERROR_DETAILS="$MISSING_COUNT with missing keys"
if [ $EXTRA_COUNT -gt 0 ]; then
[ -n "$ERROR_DETAILS" ] && ERROR_DETAILS="$ERROR_DETAILS, "
ERROR_DETAILS="${ERROR_DETAILS}$EXTRA_COUNT with extra keys"
fi
echo "❌ $ERRORS locale(s) have validation errors: $ERROR_DETAILS"
exit 1
else
echo "✅ All locales validated successfully!"
fi