Internationalizing Bash scripts Internationalizing Bash scripts shell shell

Internationalizing Bash scripts


The author of that tutorial forgot the following step:

export TEXTDOMAIN=rand.sh

which should be performed when step shown as export TEXTDOMAINDIR=/home/lji/locale is done (substituting the appropriate directory name).

You can use $"" instead of gettext:

$ cat rand.sh#!/bin/bashTEXTDOMAINDIR=$HOME/locale   # probably not the best place for these files, but OK for testingTEXTDOMAIN=rand.shgettext -s "Greeting"echo $"Greeting"$ ./rand.shHello, I can generate a random number between 2 numbers that you provideHello, I can generate a random number between 2 numbers that you provide

Note that the Bash manual says that some systems may make use of the variables $LC_MESSAGES, $TEXTDOMAIN and $TEXTDOMAINDIR in different ways.