-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently we hardcode all messages in EN
but we could pass user's locale from openpanel ui back to opencli
new helper script:
#!/bin/bash
# Usage: translate <msgid> [locale]
# Defaults to $LANG if locale not provided
translate() {
local msgid=$1
local locale=${2:-${LANG%%.*}}
local po_file="translations/$locale/LC_MESSAGES/messages.po"
if [[ ! -f "$po_file" ]]; then
echo "Translation file not found for locale $locale" >&2
return 1
fi
local msgstr=$(awk -v id="msgid \"$msgid\"" '
$0 == id {getline; if ($1 == "msgstr") {
gsub(/^msgstr\s+"|"\s*$/, "", $0)
print $0
exit
}}
' "$po_file")
if [[ -z "$msgstr" ]]; then
echo "$msgid" # fallback to msgid if no translation found
else
echo "$msgstr"
fi
}and in existing scripts do something like:
source ./translations.sh
# LANG=fr
apply_note=$(translate "Note: Please stop and start the service to apply changes." "$LANG")
message+="<br>${apply_note}"
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request