Adrian
Adrian

Reputation: 2656

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

Upvotes: 3

Views: 1223

Answers (1)

Dennis Williamson
Dennis Williamson

Reputation: 360103

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.

Upvotes: 1

Related Questions