qsgen2: Moved stuff around, updated a few comments and changed how the language file is loaded.

This commit is contained in:
Stig-Ørjan Smelror 2024-02-16 10:37:01 +01:00
parent 56bb8f5ef3
commit 368512e65e

23
qsgen2
View File

@ -28,11 +28,7 @@ include common/colors
echo "${magenta}${blue_bg} ${QSGEN} ${end}${bold_white}${blue_bg}${VERSION} ${end}" echo "${magenta}${blue_bg} ${QSGEN} ${end}${bold_white}${blue_bg}${VERSION} ${end}"
# Loading Zsh modules # Check for, and source, the config file for this specific website
zmodload zsh/files
zmodload zsh/datetime
# Check for, an source, the config file for this specific website
if [[ -f $(pwd)/config ]]; then if [[ -f $(pwd)/config ]]; then
if (${globaldebug}); then echo "${red}Config file found and sourced${end}\n${yellow} - $(pwd)/config${end}"; fi if (${globaldebug}); then echo "${red}Config file found and sourced${end}\n${yellow} - $(pwd)/config${end}"; fi
builtin source $(pwd)/config builtin source $(pwd)/config
@ -42,23 +38,20 @@ else
exit exit
fi fi
# Load language # Load language as defined in config
found=false
typeset -A qsgenlang typeset -A qsgenlang
for dir in $fpath; do for dir in $fpath; do
if [[ -f "${dir}/${language}" ]]; then if [[ -f "${dir}/${language}" ]]; then
# echo "Language file: ${dir}/${language}" # echo "Language file: ${dir}/${language}"
source "${dir}/${language}" source "${dir}/${language}"
found=true
break break
else
# Fall back to en_US if defined language isn't found
echo "Defined language, ${language}, not found. Using en_US."
source "${dir}/en_US"
fi fi
done done
if ! $found; then
echo "Language file '${language}' not found in fpath."
# Fallback or error handling
fi
if (${globaldebug}); then if (${globaldebug}); then
qsconfig=$( cat $(pwd)/config | grep -v \# | awk '{print substr($0, index($0, " ") + 1)}' ) qsconfig=$( cat $(pwd)/config | grep -v \# | awk '{print substr($0, index($0, " ") + 1)}' )
echo "Content of Config file" echo "Content of Config file"
@ -176,6 +169,10 @@ if (${globaldebug}); then _msg debug "_qsgen2_msg_6"; fi
builtin cd ${project_dir} builtin cd ${project_dir}
# Loading Zsh modules
zmodload zsh/files
zmodload zsh/datetime
# Let's put these here for now. # Let's put these here for now.
export today=$(strftime "%Y-%m-%d - %T") export today=$(strftime "%Y-%m-%d - %T")
export blogdate=$(strftime "%a-%Y-%b-%d") export blogdate=$(strftime "%a-%Y-%b-%d")