Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash localizing

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/.

like image 657
Adrian Avatar asked Feb 24 '26 12:02

Adrian


1 Answers

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.

like image 83
Dennis Williamson Avatar answered Feb 27 '26 01:02

Dennis Williamson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!