mirror of https://github.com/tLDP/LDP
USAGE: lampadasql command { language }
This will pipe the file <command> together with each <language> through the m4 macro processor.
This commit is contained in:
parent
32373438e5
commit
df7686ca05
|
@ -0,0 +1,49 @@
|
|||
#!/bin/sh
|
||||
|
||||
check_file()
|
||||
{
|
||||
[ -e "$1" ] && return
|
||||
echo "File $1 does not exist." 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
all_files()
|
||||
{
|
||||
for lang in "$@"; do
|
||||
lang="${lang%.m4}"
|
||||
file="$lang.m4"
|
||||
check_file "$file"
|
||||
m4 -P "-DI18N_lang_code=$lang" "$COMMAND" "$file"
|
||||
done
|
||||
}
|
||||
|
||||
DEFAULT_LANG=$( echo "${LANG%_*}" | tr 'a-z' 'A-Z' )
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "\
|
||||
USAGE: lampadasql command { language }
|
||||
|
||||
This will pipe the file <command> together with each <language>
|
||||
through the m4 macro processor. The suffix '.m4' will be appended
|
||||
if not present.
|
||||
|
||||
If no value for <language> is given, the first two letters of variable
|
||||
\$LANG are used. Right now that would be $DEFAULT_LANG.
|
||||
|
||||
Typically the output of lampadasql is further piped into /usr/bin/psql
|
||||
to execute SQL statements:
|
||||
|
||||
lampadasql update EN | psql lampadas
|
||||
" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COMMAND="${1%.m4}.m4"
|
||||
check_file "$COMMAND"
|
||||
shift
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
all_files $DEFAULT_LANG
|
||||
else
|
||||
all_files "$@"
|
||||
fi
|
Loading…
Reference in New Issue