Load translations from file, but disable color output

This commit is contained in:
southerntofu 2020-12-01 17:36:12 +01:00
parent 0caa9c0eba
commit 711a04d378
1 changed files with 22 additions and 18 deletions

View File

@ -22,25 +22,29 @@ fi
# - we load the requested language if it exists, fail otherwise
# - when no language is requested, default to something (TODO)
if [[ "$LANG" != "NONE" ]]; then
# Enable colors (escape codes) as echo option
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
# If LANG is a file, load it directly
if [ -f "$LANG" ]; then
locale_strings="$(cat $LANG)"
else
echo "ERROR: could not find translations. Maybe you need to run the setup.sh script?"
exit 1
# Enable colors (escape codes) as echo option
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
# 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
# Takes one argument, looks up translation
@ -305,7 +309,7 @@ done
# Error when the requested basedir (or the default ~/.forgebuild) does not exist
if [ ! -d $BASEDIR ]; then
i18n_basedir="$BASEDIR"
export i18n_basedir="$BASEDIR"
error "missing_basedir"
exit 1
fi