I am playing with localizing bash scripts:
I created the file /tmp/hello.sh with this content:
#!/bin/bash
LANGUAGE=es_ES
TEXTDOMAINDIR=/home/adrian/tmp/locale
TEXTDOMAIN=hello
echo $"Hello, world"
Generate hello.pot:
bash --dump-po-strings hello.sh
Now hello.pot contains:
: hello:2
msgid "Hello, world"
msgstr "Hola ..."
If I run
sudo msgfmt -o /home/adrian/tmp/es/LC_MESSAGES/hello.mo hello.pot
LANGUAGE=es_ES ./hello
it does not work. If only works when I copy the mo file to /usr/local/share/locale/es/.
The command below needs to match the variable in your script (or vice versa):
sudo msgfmt -o /home/adrian/tmp/locale/es/LC_MESSAGES/hello.mo hello.pot
Note the addition of locale.
See How to add localization support to your bash scripts and Internationalizing Those Bash Scripts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With