Reputation: 101
My script needs to run a program with a specific locale to work correctly, so I want it to check whether that locale is available. I've used this hack for now, but I think there's a better way to do this.
grep ^ja_JP /etc/locale.gen &>/dev/null || echo >&2 "enable any of the japanese locales first"
Upvotes: 6
Views: 4561
Reputation: 123508
man locale
would tell you that locale -a
would list all available locales.
Instead say:
locale -a | grep -q ^ja_JP || echo "enable any of the japanese locales first"
Upvotes: 8
Reputation: 241908
locale -a
should list all the available locales:
if locale -a | grep ^ja_JP ; then
# locale installed...
else
# locale not installed...
fi
Upvotes: 5