qsgen2: Update strings in language files
This commit is contained in:
parent
e2c7f85125
commit
a3e7eee83d
@ -1,12 +1,14 @@
|
|||||||
typeset -A localization
|
typeset -A localization
|
||||||
localization=(
|
localization=(
|
||||||
_msg_msg_1 "Usage: qsgen2 add \\"Site Name\\" \\"/path/to/project\\""
|
_qsgen2_msg_1 "Usage: qsgen2 add \\"Site Name\\" \\"/path/to/project\\""
|
||||||
_msg_msg_2 "- Forced Update: Generating Everything"
|
_qsgen2_msg_2 "- Forced Update: Generating Everything"
|
||||||
_msg_msg_3 "* %SCRIPT_NAME% cannot parse this site. Exiting. *"
|
_qsgen2_msg_3 "* %SCRIPT_NAME% cannot parse this site. Exiting. *"
|
||||||
_msg_msg_4 "Please install Pandoc."
|
_qsgen2_msg_4 "Please install Pandoc."
|
||||||
_msg_msg_5 "https://github.com/jgm/pandoc/releases"
|
_qsgen2_msg_5 "No valid generator found. Are you sure you\'ve selected the correct generator in \'config\'?"
|
||||||
_msg_msg_6 "No valid generator found. Are you sure you\'ve selected the correct generator in \'config\'?"
|
_qsgen2_msg_6 "Using the ${generator} engine for files: ${file_ext}"
|
||||||
_msg_msg_7 "Using the ${generator} engine for files: ${file_ext}"
|
_qsgen2_msg_7 "- Created by kekePower - 2018-$(strftime "%Y")"
|
||||||
|
_qsgen2_msg_8 "- See '${1} help' for more information."
|
||||||
|
_qsgen2_msg_9 "Contents of the Config file:"
|
||||||
_list_pages_msg_1 "_list_pages: No Pages found with ext ${file_ext}."
|
_list_pages_msg_1 "_list_pages: No Pages found with ext ${file_ext}."
|
||||||
_list_pages_msg_2 "_list_pages: Adding file to array: ${file}"
|
_list_pages_msg_2 "_list_pages: Adding file to array: ${file}"
|
||||||
_list_blogs_msg_3 "_list_blogs: No blog files found."
|
_list_blogs_msg_3 "_list_blogs: No blog files found."
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
typeset -A localization
|
typeset -A localization
|
||||||
localization=(
|
localization=(
|
||||||
_msg_msg_1 "Bruk: qsgen2 add \"Nettstedsnavn\" \"sti/til/prosjekt\""
|
_qsgen2_msg_1 "Bruk: qsgen2 add \"Nettstedsnavn\" \"sti/til/prosjekt\""
|
||||||
_msg_msg_2 "- Tvungen oppdatering: Genererer alt"
|
_qsgen2_msg_2 "- Tvungen oppdatering: Genererer alt"
|
||||||
_msg_msg_3 "* %SCRIPT_NAME% kan ikke analysere dette nettstedet. Avslutter. *"
|
_qsgen2_msg_3 "* %SCRIPT_NAME% kan ikke analysere dette nettstedet. Avslutter. *"
|
||||||
_msg_msg_4 "Vennligst installer Pandoc."
|
_qsgen2_msg_4 "Vennligst installer Pandoc."
|
||||||
_msg_msg_5 "https://github.com/jgm/pandoc/releases"
|
_qsgen2_msg_5 "Ingen gyldig generator funnet. Er du sikker på at du har valgt riktig generator i 'config'?"
|
||||||
_msg_msg_6 "Ingen gyldig generator funnet. Er du sikker på at du har valgt riktig generator i 'config'?"
|
_qsgen2_msg_6 "Bruker ${generator}-motoren for filer: ${file_ext}"
|
||||||
_msg_msg_7 "Bruker ${generator}-motoren for filer: ${file_ext}"
|
_qsgen2_msg_7 "- Laget av kekePower - 2018-$(strftime "%Y")"
|
||||||
|
_qsgen2_msg_8 "- Se '${1} help' for mer informasjon."
|
||||||
|
_qsgen2_msg_9 "Innhold i Config filen:"
|
||||||
_list_pages_msg_1 "_list_pages: Ingen sider funnet med utvidelse ${file_ext}."
|
_list_pages_msg_1 "_list_pages: Ingen sider funnet med utvidelse ${file_ext}."
|
||||||
_list_pages_msg_2 "_list_pages: Legger til fil i array: ${file}"
|
_list_pages_msg_2 "_list_pages: Legger til fil i array: ${file}"
|
||||||
_list_blogs_msg_3 "_list_blogs: Ingen blogginnlegg funnet."
|
_list_blogs_msg_3 "_list_blogs: Ingen blogginnlegg funnet."
|
||||||
|
133
qsgen2
133
qsgen2
@ -28,76 +28,6 @@ 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}"
|
||||||
|
|
||||||
_add_site() {
|
|
||||||
|
|
||||||
local site_name="${1}"
|
|
||||||
local project_dir="${2}"
|
|
||||||
local sites_file="${HOME}/.config/qsgen2/sites.qsc"
|
|
||||||
|
|
||||||
# Ensure the configuration directory and sites file exist
|
|
||||||
mkdir -p "${HOME}/.config/qsgen2"
|
|
||||||
touch "${sites_file}"
|
|
||||||
|
|
||||||
# Check if the site already exists in the file
|
|
||||||
if grep -q "^${site_name}|" "${sites_file}"; then
|
|
||||||
echo "Site '$site_name' already exists."
|
|
||||||
return 1 # Exit the function with an error status.
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Validate project directory
|
|
||||||
if [[ ! -d "${project_dir}" ]]; then
|
|
||||||
echo "The specified project directory does not exist."
|
|
||||||
return 1 # Exit the function with an error status.
|
|
||||||
fi
|
|
||||||
# Determine the new site number by counting existing lines
|
|
||||||
local site_number=$(( $(wc -l < "${sites_file}") + 1 ))
|
|
||||||
|
|
||||||
# Add the site to the sites file
|
|
||||||
echo "${site_number}|${site_name}|${project_dir}" >> "${sites_file}"
|
|
||||||
echo "Site '${site_name}' added successfully."
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
_list_sites() {
|
|
||||||
|
|
||||||
local config_dir="${HOME}/.config/qsgen2"
|
|
||||||
local sites_file="${config_dir}/sites.qsc"
|
|
||||||
|
|
||||||
# Ensure the configuration directory exists; create it if it doesn't.
|
|
||||||
# This might be more relevant in other parts of your script.
|
|
||||||
mkdir -p "$config_dir"
|
|
||||||
touch "${sites_file}"
|
|
||||||
|
|
||||||
if [[ -f "$sites_file" ]]; then
|
|
||||||
echo "Registered Sites:"
|
|
||||||
while IFS='|' read -r site_name site_dir; do
|
|
||||||
printf "${magenta}%-30s${end} - Directory: ${blue}%-50s${end}\n" "Site: $site_name" "$site_dir"
|
|
||||||
done < "$sites_file"
|
|
||||||
else
|
|
||||||
echo "No sites registered."
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function _version() {
|
|
||||||
echo "${yellow}- Created by kekePower - 2018-$(strftime "%Y")${end}"
|
|
||||||
echo "${yellow}- https://github.com/kekePower/qsgen2/${end}"
|
|
||||||
echo "${yellow}- See '${1} help' for more information.${end}"
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
|
|
||||||
function _help() {
|
|
||||||
echo "This is where I'll write the Help documentation."
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ "$1" == "version" || "$1" == "-v" || "$1" == "--version" ]]; then
|
|
||||||
_version ${0:t}
|
|
||||||
elif [[ "$1" == "help" || "$1" == "-h" || "$1" == "--help" ]]; then
|
|
||||||
_help ${0:t}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Loading Zsh modules
|
# Loading Zsh modules
|
||||||
zmodload zsh/files
|
zmodload zsh/files
|
||||||
zmodload zsh/datetime
|
zmodload zsh/datetime
|
||||||
@ -112,22 +42,18 @@ else
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Load language
|
||||||
|
autoload ${language}
|
||||||
|
|
||||||
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 "${red}Contents of Config file:${end}"
|
echo "_qsgen2_msg_9"
|
||||||
for qslines in ${qsconfig}
|
for qslines in ${qsconfig}
|
||||||
do
|
do
|
||||||
echo "${yellow}${qslines}${end}"
|
echo "${yellow}${qslines}${end}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load language
|
|
||||||
autoload ${language}
|
|
||||||
|
|
||||||
# Define cache files for blogs and pages
|
|
||||||
blog_cache_file="${project_dir}/.blog_cache"
|
|
||||||
pages_cache_file="${project_dir}/.pages_cache"
|
|
||||||
|
|
||||||
function _msg() {
|
function _msg() {
|
||||||
# Usage: _msg <type> "key"
|
# Usage: _msg <type> "key"
|
||||||
local type=$1
|
local type=$1
|
||||||
@ -136,45 +62,63 @@ function _msg() {
|
|||||||
|
|
||||||
# Check if message exists for the key
|
# Check if message exists for the key
|
||||||
if [[ -z "$msg" ]]; then
|
if [[ -z "$msg" ]]; then
|
||||||
echo "Localization key '$key' not found."
|
printf "Localization key '%s' not found.\n" "$key"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Dynamic replacement for known placeholders
|
# Dynamic replacement for known placeholders
|
||||||
msg=${msg//"%SCRIPT_NAME%"/${0:t}}
|
msg=${msg//"%SCRIPT_NAME%"/${0:t}}
|
||||||
|
|
||||||
# Apply color formatting based on type
|
# Apply color formatting based on type and use printf for safe output
|
||||||
case ${type} in
|
case ${type} in
|
||||||
std)
|
std)
|
||||||
echo -e "${green}${msg}${end}"
|
printf "${green}%s${end}\n" "$msg"
|
||||||
;;
|
;;
|
||||||
info)
|
info)
|
||||||
echo -e "${yellow}${msg}${end}"
|
printf "${yellow}%s${end}\n" "$msg"
|
||||||
;;
|
;;
|
||||||
debug)
|
debug)
|
||||||
echo -e "${red}${msg}${end}"
|
printf "${red}%s${end}\n" "$msg"
|
||||||
;;
|
;;
|
||||||
other)
|
other)
|
||||||
echo -e "${bold_yellow}${msg}${end}"
|
printf "${bold_yellow}%s${end}\n" "$msg"
|
||||||
;;
|
;;
|
||||||
sub)
|
sub)
|
||||||
echo -e "${magenta}${msg}${end}"
|
printf "${magenta}%s${end}\n" "$msg"
|
||||||
;;
|
;;
|
||||||
main)
|
main)
|
||||||
echo -e "${white}${green_bg} ${msg} ${end}"
|
printf "${white}${green_bg} %s ${end}\n" "$msg"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "${msg}"
|
printf "%s\n" "$msg"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _version() {
|
||||||
|
_msg info "_qsgen2_msg_7"
|
||||||
|
echo "${yellow}- https://github.com/kekePower/qsgen2/${end}"
|
||||||
|
_msg info "_qsgen2_msg_7"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
function _help() {
|
||||||
|
echo "This is where I'll write the Help documentation."
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "$1" == "version" || "$1" == "-v" || "$1" == "--version" ]]; then
|
||||||
|
_version ${0:t}
|
||||||
|
elif [[ "$1" == "help" || "$1" == "-h" || "$1" == "--help" ]]; then
|
||||||
|
_help ${0:t}
|
||||||
|
fi
|
||||||
|
|
||||||
case ${1} in
|
case ${1} in
|
||||||
add)
|
add)
|
||||||
if [[ $# -eq 3 ]]; then
|
if [[ $# -eq 3 ]]; then
|
||||||
_add_site "$2" "$3"
|
_add_site "$2" "$3"
|
||||||
else
|
else
|
||||||
_msg info "Usage: qsgen2 add \"Site Name\" \"/path/to/project\""
|
_msg info "_qsgen2_msg_1"
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
@ -183,7 +127,7 @@ case ${1} in
|
|||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
force)
|
force)
|
||||||
_msg sub "- Forced Update: Generating Everything"
|
_msg sub "_qsgen2_msg_2"
|
||||||
: >| "$blog_cache_file" # Truncate the blog cache before doing update
|
: >| "$blog_cache_file" # Truncate the blog cache before doing update
|
||||||
: >| "$pages_cache_file" # Truncate the page cache before doing update
|
: >| "$pages_cache_file" # Truncate the page cache before doing update
|
||||||
;;
|
;;
|
||||||
@ -194,7 +138,7 @@ esac
|
|||||||
|
|
||||||
# Let's check if qsgen2 can generate this site by checking if 'generator' is available
|
# Let's check if qsgen2 can generate this site by checking if 'generator' is available
|
||||||
if [[ ! ${generator} ]] || [[ -d $(pwd)/.git ]]; then
|
if [[ ! ${generator} ]] || [[ -d $(pwd)/.git ]]; then
|
||||||
_msg debug "* ${0:t} cannot parse this site. Exiting. *"
|
_msg debug "_qsgen2_msg_3"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -205,7 +149,7 @@ if [[ ${generator} == "native" ]]; then
|
|||||||
export file_ext="qst"
|
export file_ext="qst"
|
||||||
elif [[ ${generator} == "markdown" ]]; then
|
elif [[ ${generator} == "markdown" ]]; then
|
||||||
if [[ ! -f /usr/local/bin/pandoc ]]; then
|
if [[ ! -f /usr/local/bin/pandoc ]]; then
|
||||||
_msg other "Please install Pandoc."
|
_msg other "_qsgen2_msg_4"
|
||||||
_msg other "https://github.com/jgm/pandoc/releases"
|
_msg other "https://github.com/jgm/pandoc/releases"
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
@ -215,17 +159,20 @@ elif [[ ${generator} == "markdown" ]]; then
|
|||||||
export file_ext="md"
|
export file_ext="md"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
_msg debug "No valid generator found. Are you sure you've selected the correct generator in 'config'?"
|
_msg debug "_qsgen2_msg_5"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (${globaldebug}); then _msg debug "Using the ${generator} engine for files: ${file_ext}"; fi
|
if (${globaldebug}); then _msg debug "_qsgen2_msg_6"; fi
|
||||||
|
|
||||||
builtin cd ${project_dir}
|
builtin cd ${project_dir}
|
||||||
|
|
||||||
# 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")
|
||||||
|
# Define cache files for blogs and pages
|
||||||
|
blog_cache_file="${project_dir}/.blog_cache"
|
||||||
|
pages_cache_file="${project_dir}/.pages_cache"
|
||||||
|
|
||||||
# Let's create arrays of all the files we'll be working on
|
# Let's create arrays of all the files we'll be working on
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user