Load translations from file, but disable color output
This commit is contained in:
parent
0caa9c0eba
commit
711a04d378
|
@ -22,25 +22,29 @@ fi
|
||||||
# - we load the requested language if it exists, fail otherwise
|
# - we load the requested language if it exists, fail otherwise
|
||||||
# - when no language is requested, default to something (TODO)
|
# - when no language is requested, default to something (TODO)
|
||||||
if [[ "$LANG" != "NONE" ]]; then
|
if [[ "$LANG" != "NONE" ]]; then
|
||||||
# Enable colors (escape codes) as echo option
|
# If LANG is a file, load it directly
|
||||||
COLORS=1
|
if [ -f "$LANG" ]; then
|
||||||
|
locale_strings="$(cat $LANG)"
|
||||||
# Extract two letters from $LANG
|
|
||||||
locale="${LANG:0:2}"
|
|
||||||
|
|
||||||
# Ensure translations have been setup
|
|
||||||
if [ -d /usr/share/forgebuild/i18n ]; then
|
|
||||||
I18N_DIR=/usr/share/forgebuild/i18n
|
|
||||||
elif [ -d $HOME/.local/share/forgebuild/i18n ]; then
|
|
||||||
I18N_DIR=$HOME/.local/share/forgebuild/i18n
|
|
||||||
else
|
else
|
||||||
echo "ERROR: could not find translations. Maybe you need to run the setup.sh script?"
|
# Enable colors (escape codes) as echo option
|
||||||
exit 1
|
COLORS=1
|
||||||
|
|
||||||
|
# Extract two letters from $LANG
|
||||||
|
locale="${LANG:0:2}"
|
||||||
|
|
||||||
|
# Ensure translations have been setup
|
||||||
|
if [ -d /usr/share/forgebuild/i18n ]; then
|
||||||
|
I18N_DIR=/usr/share/forgebuild/i18n
|
||||||
|
elif [ -d $HOME/.local/share/forgebuild/i18n ]; then
|
||||||
|
I18N_DIR=$HOME/.local/share/forgebuild/i18n
|
||||||
|
else
|
||||||
|
echo "ERROR: could not find translations. Maybe you need to run the setup.sh script?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize translations
|
||||||
|
[ -f $I18N_DIR/$locale.json ] && locale_strings="$(cat $I18N_DIR/$locale.json)" || locale_strings="$(cat $I18N_DIR/en.json)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Initialize translations
|
|
||||||
[ -f $I18N_DIR/$locale.json ] && locale_strings="$(cat $I18N_DIR/$locale.json)" || locale_strings="$(cat $I18N_DIR/en.json)"
|
|
||||||
|
|
||||||
fi # End translations initialization
|
fi # End translations initialization
|
||||||
|
|
||||||
# Takes one argument, looks up translation
|
# Takes one argument, looks up translation
|
||||||
|
@ -305,7 +309,7 @@ done
|
||||||
|
|
||||||
# Error when the requested basedir (or the default ~/.forgebuild) does not exist
|
# Error when the requested basedir (or the default ~/.forgebuild) does not exist
|
||||||
if [ ! -d $BASEDIR ]; then
|
if [ ! -d $BASEDIR ]; then
|
||||||
i18n_basedir="$BASEDIR"
|
export i18n_basedir="$BASEDIR"
|
||||||
error "missing_basedir"
|
error "missing_basedir"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue