qsgen2: Updated function _msg to enable localization. en_US, es_ES and nb_NO available.

This commit is contained in:
2024-02-14 11:35:47 +01:00
parent 136a9644f5
commit c68dafda4f
4 changed files with 379 additions and 268 deletions

View File

@ -1,106 +1,114 @@
# Usage: _msg <type> "<message>"
_msg info "Usage: qsgen2 add \"Site Name\" \"/path/to/project\""
_msg sub "- Forced Update: Generating Everything"
_msg debug "* ${0:t} cannot parse this site. Exiting. *"
_msg other "Please install Pandoc."
_msg other "https://github.com/jgm/pandoc/releases"
_msg debug "No valid generator found. Are you sure you've selected the correct generator in 'config'?"
if (${globaldebug}); then _msg debug "Using the ${generator} engine for files: ${file_ext}"; fi
if ${debug}; then _msg debug "_list_pages: No Pages found with ext ${file_ext}."; fi
if ${debug}; then _msg debug "_list_pages: Adding file to array: ${file}"; fi
if ${debug}; then _msg debug "_list_blogs: No blog files found."; fi
if ${debug}; then _msg debug "_list_blogs: Adding file to array: $file"; fi
if (${debug}) _msg debug "_blog_cache: HASH VALUE: ${blog_cache[${name}]}"
if (${debug}) _msg debug "1. _blog_cache: ${blog_file}"
if (${debug}) _msg debug "2. _blog_cache: current_cache: ${current_hash}"
if (${debug}) _msg debug "3. _blog_cache: new_cache_file: ${blog_file}$"
if (${debug}) _msg debug "4. _blog_cache: new_current_cache: ${current_hash}"
if (${debug}) _msg debug "PAGES HASH VALUE: ${pages_cache[${name}]}"
if (${debug}) _msg debug "1. pages_cache: ${pages_cache[$file]}"
if (${debug}) _msg debug "1. _pages_cache: current_cache: ${current_hash}"
if (${debug}) _msg debug "2. _pages_cache: pages_file: ${pages_cache[$file]}"
if (${debug}) _msg debug "2. _pages_cache: current_cache: ${current_hash}"
if (${debug}); then _msg debug "_last_updated: Setting date and version in footer"; fi
if (${debug}); then _msg debug "_last_updated: ${upd_msg}"; fi
local upd_msg="Last updated ${today} by <a href=\"https://blog.kekepower.com/qsgen2.html\">${QSGEN} ${VERSION}</a>"
-e "s|#updated|${upd_msg}|")
if (${debug}); then _msg debug "_f_last_updated: Setting date and version in footer of file ${1}"; fi
if (${debug}); then _msg debug "_f_last_updated: ${upd_msg}"; fi
local upd_msg="Last updated ${today} by <a href=\"https://blog.kekepower.com/qsgen2.html\">${QSGEN} ${VERSION}</a>"
-e "s|#updated|${upd_msg}|" \
if (${debug}) _msg debug "_pages: Running function _pages_cache"
_msg sub "* You do not have any pages *"
_msg main "Generating Pages"
if (${debug}) _msg debug "_pages: pages_array is not empty"
if (${debug}) _msg debug "_pages: Setting Pages template"
_msg info "Unable to find the Pages template: ${pages}"
if (${debug}) _msg debug "_pages: Reading Pages template into pages_tpl"
_msg std "- Generating Page: ${pages_in_array%.*}.html"
if (${debug}) _msg debug "_pages: Loading page_content once - ${pages_in_array}"
if (${debug}) _msg debug "_pages: Grepping for page_title"
if (${debug}) _msg debug "_pages: ${page_title}"
if (${debug}) _msg debug "_pages: Removing #title line from page_content"
if (${debug}) _msg debug "_pages: Running engine on ${pages_in_array}"
if (${debug}) _msg debug "_pages: Checking for #link, #showimg and #ytvideo in page_content"
if (${debug}) _msg debug "_pages: #link is present, run _link: page_content"
if (${debug}) _msg debug "_pages: #showimg is present, run _image: page_content"
if (${debug}) _msg debug "_pages: #ytvideo is present, run _youtube: page_content"
if (${debug}) _msg debug "_pages: Replacing BODY with page_content in pages_tpl"
if (${debug}) _msg debug "_pages: Replacing #pagetitle, #tagline and #sitename in pages_tpl"
if (${debug}) _msg debug "_pages: _last_updated in pages_tpl"
if (${debug}) _msg debug "_pages: Lowercase filnames, always"
if (${debug}) _msg debug "_pages: Running _cleanup"
# _msg std "Writing ${www_root}/${pages_title_lower%.*}.html to disk."
if (${debug}) _msg sub "- Parsing ${pages_in_array}"
if (${debug}) _msg sub "- blog_in_index = ${blog_in_index}"
if (${debug}) _msg sub "- Listing blog temp file:"
_msg std "Updating index.html with new blog posts"
if (${debug}) _msg sub "- Parsing ${pages_in_array}"
if (${debug}) _msg sub "- blog_in_index = ${blog_in_index}"
if (${debug}) _msg sub "- Listing blog temp file:"
_msg sub "- No new or updated Pages found"
if (${debug}) _msg debug "_blogs: Running function _list_blogs"
_msg sub "* You do not have any blogs *"
_msg main "Generating Blogs"
if (${debug}) _msg debug "_blogs: Running function _blog_cache"
_msg info "Unable to find theme template for Blogs."
if (${debug}) _msg debug "_blogs: Processing pre-data for ${blog}"
_msg debug "_blogs: DATE metadata missing in ${blog}."
if (${debug}) _msg debug "_blogs: Adding data for ${blog} to array to export"
if (${debug}) _msg debug "_blogs: Processing ${blog}"
_msg std "- Generating Blog: ${blog_index}.html"
if (${debug}) _msg debug "_blogs: Processing substitutes in ${blog}"
if (${debug}) _msg debug "_blogs: Running function $engine for ${blog}"
if (${debug}) _msg debug "_blogs: Checking for #link, #showimg and #ytvideo in blog_content"
if (${debug}) _msg debug "_blogs: #link is present, run _link: blog_content"
if (${debug}) _msg debug "_blogs: #showimg is present, run _link: blog_content"
if (${debug}) _msg debug "_blogs: #ytvideo is present, run _link: blog_content"
if (${debug}) _msg debug "_blogs: Replacing tagline, sitename and pagetitle"
if (${debug}) _msg debug "_blogs: Creating directoty ${www_root}/${blog_dir}"
if (${debug}) _msg debug "_blogs: Writing blog to disk: ${www_root}${blog_url}"
_msg sub "- No new or updated Blogs found"
if (${debug}) _msg sub "* _blogs: Running _blog_idx_for_index"
if (${debug}) _msg sub "* _blogs: Running _blog_index"
_msg sub "- Populating ${project_dir}/blog/index.tmp.html"
if (${debug}) _msg debug "_blog_idx_for_index: Initiating function"
if (${debug}) _msg debug "_blog_idx_for_index: BLOG_META_STR_ARRAY: ${BLOG_META_STR_ARRAY[@]}"
if (${debug}) _msg debug "_blog_idx_for_index: meta_str from BLOG_META_STR_ARRAY from _blogs"
if (${debug}) _msg debug "_blog_idx_for_index: ${meta_str}"
if (${debug}) _msg debug "_blog_idx_for_index: Iterate over each component and extract information"
if (${debug}) _msg debug "_blog_idx_for_index: Running ${engine} on content to catch QStags in Ingress"
if (${debug}) _msg debug "_blog_idx_for_index: Writing _blog_idx_for_index to file: ${project_dir}/blog/index.tmp.html"
if (${debug}) _msg debug "_blog_idx_for_index: blog_list_content = ${blog_list_content}"
if (${debug}) _msg debug "Running function _blog_index"
if (${debug}) _msg debug "_blog_index: blog_in_index = ${blog_in_index}"
_msg std "- Generating the Blog index file"
if (${debug}) _msg debug "_add_blog_list_to_index: Inserting blog list to index.html"
_msg main "Generating Sitemap"
if (${debug}); then _msg debug "Sitemap generated at ${sitemap_file}"; fi
if (${debug}) _msg debug "_link: URL_MAIN(line): ${line}"
if (${debug}) _msg debug "_link_ URL: ${url_dest}"
if (${debug}) _msg debug "_link: Text: ${url_txt}"
if (${debug}) _msg debug "_image: Processing line: ${line}"
if (${debug}) _msg debug "_youtube: Processing line: ${line}"
if (${debug}) _msg debug "_cleanup: Cleaning up tags in content"
_msg debug "_html: Converting QStags in content"
_msg debug "_html: Converting QStags in content"
typeset -A localization
localization=(
_msg_msg_1 "Usage: qsgen2 add \\"Site Name\\" \\"/path/to/project\\""
_msg_msg_2 "- Forced Update: Generating Everything"
_msg_msg_3 "* %SCRIPT_NAME% cannot parse this site. Exiting. *"
_msg_msg_4 "Please install Pandoc."
_msg_msg_5 "https://github.com/jgm/pandoc/releases"
_msg_msg_6 "No valid generator found. Are you sure you\'ve selected the correct generator in \'config\'?"
_msg_msg_7 "Using the ${generator} engine for files: ${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_blogs_msg_3 "_list_blogs: No blog files found."
_list_blogs_msg_4 "_list_blogs: Adding file to array: $file"
_blog_cache_msg_1 "_blog_cache: HASH VALUE: ${blog_cache[${name}]}"
_blog_cache_msg_2 "1. _blog_cache: ${blog_file}"
_blog_cache_msg_3 "2. _blog_cache: current_cache: ${current_hash}"
_blog_cache_msg_4 "3. _blog_cache: new_cache_file: ${blog_file}$"
_blog_cache_msg_5 "4. _blog_cache: new_current_cache: ${current_hash}"
_pages_cache_msg_1 "PAGES HASH VALUE: ${pages_cache[${name}]}"
_pages_cache_msg_2 "1. pages_cache: ${pages_cache[$file]}"
_pages_cache_msg_3 "1. _pages_cache: current_cache: ${current_hash}"
_pages_cache_msg_4 "2. _pages_cache: pages_file: ${pages_cache[$file]}"
_pages_cache_msg_5 "2. _pages_cache: current_cache: ${current_hash}"
_last_updated_msg_1 "_last_updated: Setting date and version in footer"
_last_updated_msg_1 "_last_updated: ${upd_msg}"
_f_last_updated_msg_1 "_f_last_updated: Setting date and version in footer of file ${1}"
_f_last_updated_msg_2 "_f_last_updated: ${upd_msg}"
_f_last_updated_msg_3 "_f_last_updated: File \'${1}\' not found."
_pages_msg_1 "_pages: Running function _pages_cache"
_pages_msg_2 "* You do not have any pages *"
_pages_msg_3 "Generating Pages"
_pages_msg_4 "_pages: pages_array is not empty"
_pages_msg_5 "_pages: Setting Pages template"
_pages_msg_6 "Unable to find the Pages template: ${pages}"
_pages_msg_7 "_pages: Reading Pages template into pages_tpl"
_pages_msg_8 "- Generating Page: ${pages_in_array%.*}.html"
_pages_msg_9 "_pages: Loading page_content once - ${pages_in_array}"
_pages_msg_10 "_pages: Finding page_title"
_pages_msg_11 "_pages: ${page_title}"
_pages_msg_12 "_pages: Removing #title line from page_content"
_pages_msg_13 "_pages: Running engine on ${pages_in_array}"
_pages_msg_14 "_pages: Checking for #link, #showimg and #ytvideo in page_content"
_pages_msg_15 "_pages: #link is present, run _link: page_content"
_pages_msg_16 "_pages: #showimg is present, run _image: page_content"
_pages_msg_17 "_pages: #ytvideo is present, run _youtube: page_content"
_pages_msg_18 "_pages: Replacing #pagetitle, #tagline and #sitename in pages_tpl"
_pages_msg_19 "_pages: Replacing BODY with page_content in pages_tpl"
_pages_msg_20 "_pages: _last_updated in pages_tpl"
_pages_msg_21 "_pages: Lowercase filnames, always"
_pages_msg_22 "_pages: Running _cleanup"
_pages_msg_23 "- Parsing ${pages_in_array}"
_pages_msg_24 "- blog_in_index = ${blog_in_index}"
_pages_msg_25 "- Listing blog temp file:"
_pages_msg_26 "Updating index.html with new blog posts"
_pages_msg_27 "- Parsing ${pages_in_array}"
_pages_msg_28 "- blog_in_index = ${blog_in_index}"
_pages_msg_29 "- Listing blog temp file:"
_pages_msg_30 "- No new or updated Pages found"
_blogs_msg_1 "_blogs: Running function _list_blogs"
_blogs_msg_2 "* You do not have any blogs *"
_blogs_msg_3 "Generating Blogs"
_blogs_msg_4 "_blogs: Running function _blog_cache"
_blogs_msg_5 "Unable to find theme template for Blogs."
_blogs_msg_6 "_blogs: Processing pre-data for ${blog}"
_blogs_msg_7 "_blogs: Looking for DATE: Found"
_blogs_msg_8 "_blogs: Looking for BLOG_TITLE: Found"
_blogs_msg_9 "* _blogs: DATE metadata missing in ${blog}."
_blogs_msg_10 "* _blogs: BLOG_TITLE metadata missing in ${blog}."
_blogs_msg_11 "_blogs: Adding data for ${blog} to array to export"
_blogs_msg_12 "_blogs: Processing ${blog}"
_blogs_msg_13 "- Generating Blog: ${blog_index}.html"
_blogs_msg_14 "_blogs: Processing substitutes in ${blog}"
_blogs_msg_15 "_blogs: Running function $engine for ${blog}"
_blogs_msg_16 "_blogs: Checking for #link, #showimg and #ytvideo in blog_content"
_blogs_msg_17 "_blogs: #link is present, run _link: blog_content"
_blogs_msg_18 "_blogs: #showimg is present, run _link: blog_content"
_blogs_msg_19 "_blogs: #ytvideo is present, run _link: blog_content"
_blogs_msg_20 "_blogs: Replacing tagline, sitename and pagetitle"
_blogs_msg_21 "_blogs: Creating directory ${www_root}${blog_dir}"
_blogs_msg_22 "_blogs: Writing blog to disk: ${www_root}${blog_url}"
_blogs_msg_23 "_blogs: new_updated_blogs=true"
_blogs_msg_24 "- No new or updated Blogs found"
_blogs_msg_25 "* _blogs: Running _blog_idx_for_index"
_blogs_msg_26 "* _blogs: Running _blog_index"
_blog_idx_for_index_msg_1 "- Populating ${project_dir}/blog/index.tmp.html"
_blog_idx_for_index_msg_2 "_blog_idx_for_index: Initiating function"
_blog_idx_for_index_msg_3 "_blog_idx_for_index: BLOG_META_STR_ARRAY: ${BLOG_META_STR_ARRAY[@]}"
_blog_idx_for_index_msg_4 "_blog_idx_for_index: meta_str from BLOG_META_STR_ARRAY from _blogs"
_blog_idx_for_index_msg_5 "_blog_idx_for_index: ${meta_str}"
_blog_idx_for_index_msg_6 "_blog_idx_for_index: Iterate over each component and extract information"
_blog_idx_for_index_msg_7 "_blog_idx_for_index: Running ${engine} on content to catch QStags in Ingress"
_blog_idx_for_index_msg_8 "_blog_idx_for_index: Writing _blog_idx_for_index to file: ${project_dir}/blog/index.tmp.html"
_blog_idx_for_index_msg_9 "_blog_idx_for_index: blog_list_content = ${blog_list_content}"
_blog_index_msg_1 "_blog_index: blog_in_index=${blog_in_index}"
_blog_index_msg_2 "_blog_index: new_updated_blogs=${new_updated_blogs}"
_blog_index_msg_3 "_blog_index: Running function _blog_index"
_blog_index_msg_4 "_blog_index: blog_in_index = ${blog_in_index}"
_blog_index_msg_5 "- Generating Page: ${www_root}/blog/index.html"
_blog_index_msg_6 "_blog_index: Replacing sitename and tagline"
_blog_index_msg_7 "_blog_index: Replacing BODY with content of ${project_dir}/blog/index.tmp.html"
_blog_index_msg_8 "_blog_index: Writing ${www_root}/blog/index.html"
_blog_index_msg_9 "_blog_index: Content length of blog_index_content: ${#blog_index_content}"
_add_blog_list_to_index_msg_1 "_add_blog_list_to_index: Inserting blog list to index.html"
_sitemap_msg_1 "Generating Sitemap"
_sitemap_msg_2 "Sitemap generated at ${sitemap_file}"
_link_msg_1 "_link: URL_MAIN(line): ${line}"
_link_msg_2 "_link_ URL: ${url_dest}"
_link_msg_3 "_link: Text: ${url_txt}"
_image_msg_1 "_image: Processing line: ${line}"
_youtube_msg_1 "_youtube: Processing line: ${line}"
_cleanup_msg_1 "_cleanup: Cleaning up tags in content"
_html_msg_1 "_html: Converting QStags in content"
_zhtml_msg_1 "_zhtml: Converting QStags in content"
)