🆕 feat(lang): add new language files

Added new language files to the project. These files contain a list of messages used in the application. The messages are used to display information to the user, such as status updates, error messages, and prompts. The files are named `promenne1.txt`, `promenne2.txt`, `raw_comments.cfg`, `raw_echo.cfg`, and `raw_msg.cfg`.

🆕 feat(lang): add new language files
Added new language files to support localization of the application. The new files include `raw_printf.cfg`, `strings.cfg`, `strings0.cfg`, `strings1.cfg`, and `strings2.cfg`. These files contain translations for various messages and prompts used in the application. The addition of these files will allow users to use the application in their preferred language.

🗑️ chore(translate.sh): remove translate.sh script
The translate.sh script has been removed from the repository as it is no longer needed. The script was used to automatically translate base language strings and add them into the various translations, remove duplicate strings, and rearrange them alphabetically. However, the script is no longer being used and has been removed.
This commit is contained in:
zenobit 2023-04-14 10:53:39 +02:00
parent 545577b497
commit 62a51945e0
11 changed files with 609 additions and 120 deletions

72
lang/tmp/promenne1.txt Normal file
View File

@ -0,0 +1,72 @@
MSG_ADD_STARTED
MSG_ARGUMENTS
MSG_AS_ROOT
MSG_BUGS
MSG_C_ENTRIES
MSG_C_ENTRY
MSG_C_ICONS
MSG_C_ISOS
MSG_CONFIG
MSG_COPY
MSG_CREATING
MSG_C_TRANSLATION
MSG_DEFAULT_TERMINAL
MSG_DESKTOP_ENTRY
MSG_DONE
MSG_DUMP
MSG_ERROR
MSG_FEEDBACK
MSG_FLAWLESS
MSG_FZF
MSG_H_ADD
MSG_H_COPY
MSG_H_DIR
MSG_H_FIRST
MSG_H_GUI
MSG_H_HELP
MSG_H_INSTALL
MSG_H_MODE
MSG_HOMEPAGE
MSG_HOSTED
MSG_H_PUSH
MSG_H_READY
MSG_H_SORT
MSG_H_SUPPORTED
MSG_H_TRANSLATE
MSG_H_TUI
MSG_CHAT
MSG_ICONS
MSG_IMPROVE
MSG_INSTALLING
MSG_INTERM
MSG_INVALID_AGAIN
MSG_KNOW
MSG_LANG
MSG_LANG_CODE
MSG_LANG_CHANGE
MSG_LIKE
MSG_MERGING
MSG_MO
MSG_MODE
MSG_NEEDED
MSG_NEW
MSG_NO
MSG_NO_DISTRO
MSG_NO_VM
MSG_OR_RUN
MSG_PREPARED
MSG_PUSHING
MSG_RUNNING
MSG_SETTINGUP
MSG_S_GUI
MSG_S_INSTALLATION
MSG_SORTING
MSG_STARTING
MSG_STRUCTURE
MSG_S_TUI
MSG_TERMINAL_SET
MSG_TRANSLATION
MSG_TRYING
MSG_U_READY
MSG_U_SUPPORTED
MSG_YAD

73
lang/tmp/promenne2.txt Normal file
View File

@ -0,0 +1,73 @@
MSG_ADD_STARTED
MSG_ARGUMENTS
MSG_AS_ROOT
MSG_BUGS
MSG_C_ENTRIES
MSG_C_ENTRY
MSG_C_ICONS
MSG_C_ISOS
MSG_CONFIG
MSG_COPY
MSG_CREATING
MSG_C_TRANSLATION
MSG_DEFAULT_TERMINAL
MSG_DESKTOP_ENTRY
MSG_DONE
MSG_DUMP
MSG_ERROR
MSG_FEEDBACK
MSG_FLAWLESS
MSG_FZF
MSG_H_ADD
MSG_H_COPY
MSG_H_DIR
MSG_H_FIRST
MSG_H_GUI
MSG_H_HELP
MSG_H_INSTALL
MSG_H_MODE
MSG_HOMEPAGE
MSG_HOSTED
MSG_H_PUSH
MSG_H_READY
MSG_H_SORT
MSG_H_SUPPORTED
MSG_H_TRANSLATE
MSG_H_TUI
MSG_CHAT
MSG_ICONS
MSG_IMPROVE
MSG_INSTALLING
MSG_INTERM
MSG_INVALID
MSG_INVALID_AGAIN
MSG_KNOW
MSG_LANG
MSG_LANG_CODE
MSG_LANG_CHANGE
MSG_LIKE
MSG_MERGING
MSG_MO
MSG_MODE
MSG_NEEDED
MSG_NEW
MSG_NO
MSG_NO_DISTRO
MSG_NO_VM
MSG_OR_RUN
MSG_PREPARED
MSG_PUSHING
MSG_RUNNING
MSG_SETTINGUP
MSG_S_GUI
MSG_S_INSTALLATION
MSG_SORTING
MSG_STARTING
MSG_STRUCTURE
MSG_S_TUI
MSG_TERMINAL_SET
MSG_TRANSLATION
MSG_TRYING
MSG_U_READY
MSG_U_SUPPORTED
MSG_YAD

51
lang/tmp/raw_comments.cfg Normal file
View File

@ -0,0 +1,51 @@
1:#!/usr/bin/env bash
2:# shellcheck disable=1078,1079,1091,2027,2034
4:# shellcheck source=/dev/null
75: #export "VMS_DIR" "DH_CONFIG_DIR" "DH_ICON_DIR" "terminal" "replace" "portable_prefix"
79: # shellcheck source=distrohopper.conf
82: #export "portable_prefix"
85:# installation ---------------------------------------------------------
96: # DEBUG mod
97: #bash -x ./dh 2>&1 | tee output.log
98: #progname="${progname
101: #GTK_THEME="alt-dialog"
109: #export "DH_CONFIG_DIR" "DH_CONFIG" "replace" "DH_ICON_DIR" "PATH_PREFIX" "TMP_DIR" "terminal"
111: # Set traps to catch the signals and exit gracefully
151: comment='Quickly download, create and run VM of any#TODO operating system.'
171: # Find the current distribution and install dependecies
206: # quickget also to config directory for adding new distros...
231:# basic ----------------------------------------------------------------
245: # for files in "$VMS_DIR"/*; do
246: # if [ ! -e *.conf ]; then
247: # echo $"No .conf files found"
248: # return
249: # fi
252: continue # skip processing distrohopper.conf
255: # Use fuzzy matching to find the best matching icon file (ready to run VMs)
258: # If no icon was found, try shorter name (ready to run VMs)
268: comment='Quickly download, create and run VM of any#TODO operating system.'
281: # get supported VMs
297: # Check if there are editions
323: #define functions for buttons
354: --field="Push!!Push changed quickget to quickemu project #todo"
364: # posible
403: # Check if there are any VMs
404: if [ ${#vms[@]} -eq 0 ]; then
408: # Print the names of the available VMs
411: # Action prompt
498:# more -----------------------------------------------------------------
503: # shellcheck disable=2154
506: # shellcheck disable=2086
517:#32
521:#184+
525:#262+
535:#1052+
552: #TODO
553: # Get the name of the script from the command line argument
555: # Get a list of all the function names in the script
557: # Sort the function names alphabetically
559: # Loop through the sorted function names and print the function definitions
562: # Print the function definition to stdout
657:# run ------------------------------------------------------------------
661: if [[ $# -eq 0 ]]; then
666: while [[ $# -gt 0 ]]

87
lang/tmp/raw_echo.cfg Normal file
View File

@ -0,0 +1,87 @@
17:echo "$MSG_RUNNING"
22: echo ""
23: echo "$MSG_DONE"
24: echo ""
25: echo "$MSG_BUGS"
26: echo "$MSG_FEEDBACK"
27: echo "$MSG_LIKE"
28: echo "$MSG_IMPROVE"
29: echo "$MSG_KNOW"
30: echo ""
31: echo "$MSG_FLAWLESS"
32: echo " zenobit"
36: echo "DistroHopper v. $version"
37: echo "quickemu v. $("$portable_prefix"quickemu --version)"
39: echo "$MSG_ARGUMENTS"
41: echo "---------------------------------------------------------"
44: echo "---------------------------------------------------------"
46: echo "---------------------------------------------------------"
49: echo "---------------------------------------------------------"
52: echo "---------------------------------------------------------"
56: echo "---------------------------------------------------------"
58: echo "---------------------------------------------------------"
60: echo "---------------------------------------------------------"
61: echo "$MSG_HOMEPAGE"
62: echo "$MSG_HOSTED"
63: echo "$MSG_CHAT"
88: [ -f "$PATH_PREFIX/yad" ] || echo "$MSG_YAD"
92: [ -f "$PATH_PREFIX/fzf" ] || echo "$MSG_FZF"
139: echo "$MSG_CONFIG"
141: echo "$MSG_ICONS"
146: echo "$MSG_INTERM"
166: echo "VMS_DIR=\"$VMS_DIR\"
182: echo "$MSG_ERROR
208: echo "$MSG_C_ICONS"
210: echo "$MSG_C_ENTRIES"
219: echo "$MSG_NEEDED"
221: echo "$MSG_STRUCTURE" \
223: && echo "$MSG_SETTINGUP" \
225: && echo "$MSG_INSTALLING" \
227: && echo "$MSG_C_ENTRY" \
247: # echo $"No .conf files found"
279: echo "$MSG_INTERM"
284: vm_desktop=$(echo "$get_name" | tr ' ' '_')
295: echo "$MSG_CREATING $vm_desktop $MSG_DESKTOP_ENTRY"
296: echo ""
366: echo " DEBUG
367: echo $?
386: if [ "$(echo "$choices" | wc -l)" = 1 ]; then
405: echo "$MSG_NO_VM"
410: echo "-------------"
412: echo "$MSG_NEW (c)"
433: release=$(echo "$releases" | fzf --cycle --header='Choose Release
438: edition=$(echo "$editions" | fzf --cycle --header='Choose Edition
443: wrelease=$(echo "8
454: answer=$(echo "Default English
459: choosed=$(echo "$(ls ***.conf 2>/dev/null | sed 's/\.conf$//')" | fzf --cycle --header='Choose VM to run
465: releases=$(echo "$result" | head -1)
466: editions=$(echo "$result" | tail -1)
528: echo $RELEASES
532: echo $EDITIONS
543: echo "\${URL}/\${ISO}" "\${HASH}"
547: echo "$MSG_DONE"
558: sorted_function_names=$(echo "$function_names" | sort)
568: echo "$MSG_LANG_CHANGE"
569: echo "$MSG_LANG_CODE"
571: echo "$MSG_LANG
572: echo "$MSG_DUMP"
574: echo "$MSG_MERGING"
576: echo "$MSG_MO"
578: echo "$MSG_COPY $lang $MSG_TRANSLATION '/usr/share/local' $MSG_AS_ROOT"
581: echo "$MSG_C_TRANSLATION '/usr/share/local'..."
587: echo ""
591: echo "$MSG_DEFAULT_TERMINAL
648: echo "$MSG_INVALID_AGAIN"
653: echo "$MSG_TERMINAL_SET $terminal."
679: echo "$MSG_S_INSTALLATION"
684: echo "$MSG_MODE"
689: echo "$MSG_U_SUPPORTED"
694: echo "$MSG_U_READY"
699: echo "$MSG_S_TUI"
704: echo "$MSG_S_GUI"
709: echo "$MSG_ADD_STARTED"
714: echo "$MSG_SORTING"
719: echo "$MSG_PUSHING"
724: echo "$MSG_C_ISOS"
737: echo "$MSG_INVALID
738: echo ""

77
lang/tmp/raw_msg.cfg Normal file
View File

@ -0,0 +1,77 @@
17:MSG_RUNNING
23:MSG_DONE
25:MSG_BUGS
26:MSG_FEEDBACK
27:MSG_LIKE
28:MSG_IMPROVE
29:MSG_KNOW
31:MSG_FLAWLESS
38:MSG_H_FIRST
39:MSG_ARGUMENTS
40:MSG_H_HELP
42:MSG_H_DIR
43:MSG_H_INSTALL
45:MSG_H_MODE
47:MSG_H_SUPPORTED
48:MSG_H_READY
50:MSG_H_TUI
51:MSG_H_GUI
53:MSG_H_ADD
54:MSG_H_SORT
55:MSG_H_PUSH
57:MSG_H_COPY
59:MSG_H_TRANSLATE
61:MSG_HOMEPAGE
62:MSG_HOSTED
63:MSG_CHAT
88:MSG_YAD
92:MSG_FZF
139:MSG_CONFIG
141:MSG_ICONS
146:MSG_INTERM
182:MSG_ERROR
182:MSG_NO_DISTRO
208:MSG_C_ICONS
210:MSG_C_ENTRIES
219:MSG_NEEDED
221:MSG_STRUCTURE
223:MSG_SETTINGUP
225:MSG_INSTALLING
227:MSG_C_ENTRY
279:MSG_INTERM
295:MSG_CREATING
295:MSG_DESKTOP_ENTRY
402:MSG_PREPARED
405:MSG_NO_VM
412:MSG_NEW
413:MSG_OR_RUN
474:MSG_TRYING
479:MSG_TRYING
484:MSG_TRYING
494:MSG_STARTING
547:MSG_DONE
568:MSG_LANG_CHANGE
569:MSG_LANG_CODE
571:MSG_LANG
572:MSG_DUMP
574:MSG_MERGING
576:MSG_MO
578:MSG_COPY
578:MSG_TRANSLATION
578:MSG_AS_ROOT
581:MSG_C_TRANSLATION
591:MSG_DEFAULT_TERMINAL
648:MSG_INVALID_AGAIN
653:MSG_TERMINAL_SET
662:MSG_NO
679:MSG_S_INSTALLATION
684:MSG_MODE
689:MSG_U_SUPPORTED
694:MSG_U_READY
699:MSG_S_TUI
704:MSG_S_GUI
709:MSG_ADD_STARTED
714:MSG_SORTING
719:MSG_PUSHING
724:MSG_C_ISOS

22
lang/tmp/raw_printf.cfg Normal file
View File

@ -0,0 +1,22 @@
38: printf "$MSG_H_FIRST ./dh i && dh s g\n"
40: printf $"\th\thelp\t\t\t$MSG_H_HELP\n"
42: printf $"\td\tdir\t\t\t$MSG_H_DIR\n"
43: printf $"\ti\tinstall\t\t\t$MSG_H_INSTALL\n"
45: printf $"\tm\tmode\t\t\t$MSG_H_MODE\n"
47: printf $"\ts\tsupported\t\t$MSG_H_SUPPORTED\n"
48: printf $"\tr\tready\t\t\t$MSG_H_READY\n"
50: printf $"\tt\ttui\t\t\t$MSG_H_TUI\n"
51: printf $"\tg\tgui\t\t\t$MSG_H_GUI\n"
53: printf $"\ta\tadd\t\t\t$MSG_H_ADD\n"
54: printf $"\tf\tfunctions\t\t$MSG_H_SORT\n"
55: printf $"\tp\tpush\t\t\t$MSG_H_PUSH\n"
57: printf $"\tc\tcopy\t\t\t$MSG_H_COPY\n"
59: printf $"\tl\tlanguage\t\t$MSG_H_TRANSLATE\n"
402: printf "$MSG_PREPARED
409: printf "%s\n" "${vms[@]%.*}"
413: printf "$MSG_OR_RUN\n"
474: printf $"\n $MSG_TRYING %s %s...\n\n" "$os" "$release"
479: printf $"\n $MSG_TRYING %s %s %s...\n\n" "$os" "$release" "$edition"
484: printf $"\n $MSG_TRYING %s %s...\n\n" "$wrelease" "$wlang"
494: printf $"\n $MSG_STARTING %s...\n\n" "$choosed"
662: printf "$MSG_NO\n\n"

73
lang/tmp/strings.cfg Normal file
View File

@ -0,0 +1,73 @@
MSG_ADD_STARTED="Adding new distro started..."
MSG_ARGUMENTS="Possible arguments:"
MSG_AS_ROOT="as root"
MSG_BUGS="PS: You saw some bugs?"
MSG_C_ENTRIES="Copying desktop entries and locales..."
MSG_C_ENTRY="Copying desktop entry..."
MSG_C_ICONS="Copying icons..."
MSG_C_ISOS="Copying ISOs to dir. It will take some time..."
MSG_CONFIG="Sourcing config..."
MSG_COPY="Copying "
MSG_CREATING="Creating..."
MSG_C_TRANSLATION="Copying translation..."
MSG_DEFAULT_TERMINAL="Choose default terminal"
MSG_DESKTOP_ENTRY="Desktop entry (shortcut)"
MSG_DONE="Done"
MSG_DUMP="Dumping language source..."
MSG_ERROR="Error"
MSG_FEEDBACK="Could you please provide feedback?"
MSG_FLAWLESS="Wish you flawless distro hopping..."
MSG_FZF="Missing fzf!"
MSG_H_ADD="Add new distro to quickget"
MSG_H_COPY="Copy all ISOs to target dir (for Ventoy)"
MSG_H_DIR="Set default directory where VMs are stored"
MSG_H_FIRST="example for First run from terminal:"
MSG_H_GUI="Run graphical user interface (GUI)"
MSG_H_HELP="Show this help and exit"
MSG_H_INSTALL="Install DistroHopper"
MSG_H_MODE="Portable mode"
MSG_HOMEPAGE="Homepage: dh.osowoso.xyz"
MSG_HOSTED="Project hosted at: https://github.com/oSoWoSo/DistroHopper"
MSG_H_PUSH="Push changed quickget to quickemu project"
MSG_H_READY="Update ready to run VMs"
MSG_H_SORT="Sort functions in quickget"
MSG_H_SUPPORTED="Update supported VMs"
MSG_H_TRANSLATE="Translate DistroHopper"
MSG_H_TUI="Run terminal user interface (TUI)"
MSG_CHAT="Chat group on SimpleX: https://tinyurl.com/7hm4kcjx"
MSG_ICONS="creating icons dir as root..."
MSG_IMPROVE="What can be improved, added, changed?"
MSG_INSTALLING="Installing DistroHopper..."
MSG_INTERM="Do you want show output in the terminal? (y/n)"
MSG_INVALID_AGAIN="Invalid option, please choose again."
MSG_INVALID="Invalid option:"
MSG_KNOW=" Let me know..."
MSG_LANG_CODE="If you want create new one, insert two digit language code..."
MSG_LANG_CHANGE="Which language change? (en/cs)"
MSG_LANG="Choosed language is:"
MSG_LIKE="How do you like DistroHopper?"
MSG_MERGING="Merging changes... (Do it yourself)"
MSG_MODE="Switching to portable mode!"
MSG_MO="Generating .mo file..."
MSG_NEEDED="Installing needed..."
MSG_NEW=" Do you want to create a new VM? (c)"
MSG_NO_DISTRO="I currently don't have support for your distro"
MSG_NO="No argumet provided!"
MSG_NO_VM="No VMs found."
MSG_OR_RUN=" or run an existing one? (press anything)"
MSG_PREPARED=" Prepared VMs"
MSG_PUSHING="Pushing changes to..."
MSG_RUNNING="DistroHopper is running... Press Ctrl-Q anytime to exit."
MSG_SETTINGUP="Setting up directory..."
MSG_S_GUI="Starting DistroHopper GUI..."
MSG_S_INSTALLATION="Starting installation..."
MSG_SORTING="Sorting functions in template..."
MSG_STARTING=" Starting %s..."
MSG_STRUCTURE="Creating directory structure..."
MSG_S_TUI="Running DistroHopper TUI..."
MSG_TERMINAL_SET="Default terminal set to:"
MSG_TRANSLATION="translation into "
MSG_TRYING="Trying to download "
MSG_U_READY="Updating ready VMs..."
MSG_U_SUPPORTED="Updating supported VMs..."
MSG_YAD="Missing yad!"

0
lang/tmp/strings0.cfg Normal file
View File

77
lang/tmp/strings1.cfg Normal file
View File

@ -0,0 +1,77 @@
17:MSG_RUNNING
23:MSG_DONE
25:MSG_BUGS
26:MSG_FEEDBACK
27:MSG_LIKE
28:MSG_IMPROVE
29:MSG_KNOW
31:MSG_FLAWLESS
38:MSG_H_FIRST
39:MSG_ARGUMENTS
40:MSG_H_HELP
42:MSG_H_DIR
43:MSG_H_INSTALL
45:MSG_H_MODE
47:MSG_H_SUPPORTED
48:MSG_H_READY
50:MSG_H_TUI
51:MSG_H_GUI
53:MSG_H_ADD
54:MSG_H_SORT
55:MSG_H_PUSH
57:MSG_H_COPY
59:MSG_H_TRANSLATE
61:MSG_HOMEPAGE
62:MSG_HOSTED
63:MSG_CHAT
88:MSG_YAD
92:MSG_FZF
139:MSG_CONFIG
141:MSG_ICONS
146:MSG_INTERM
182:MSG_ERROR
182:MSG_NO_DISTRO
208:MSG_C_ICONS
210:MSG_C_ENTRIES
219:MSG_NEEDED
221:MSG_STRUCTURE
223:MSG_SETTINGUP
225:MSG_INSTALLING
227:MSG_C_ENTRY
279:MSG_INTERM
295:MSG_CREATING
295:MSG_DESKTOP_ENTRY
402:MSG_PREPARED
405:MSG_NO_VM
412:MSG_NEW
413:MSG_OR_RUN
474:MSG_TRYING
479:MSG_TRYING
484:MSG_TRYING
494:MSG_STARTING
547:MSG_DONE
568:MSG_LANG_CHANGE
569:MSG_LANG_CODE
571:MSG_LANG
572:MSG_DUMP
574:MSG_MERGING
576:MSG_MO
578:MSG_COPY
578:MSG_TRANSLATION
578:MSG_AS_ROOT
581:MSG_C_TRANSLATION
591:MSG_DEFAULT_TERMINAL
648:MSG_INVALID_AGAIN
653:MSG_TERMINAL_SET
662:MSG_NO
679:MSG_S_INSTALLATION
684:MSG_MODE
689:MSG_U_SUPPORTED
694:MSG_U_READY
699:MSG_S_TUI
704:MSG_S_GUI
709:MSG_ADD_STARTED
714:MSG_SORTING
719:MSG_PUSHING
724:MSG_C_ISOS
737:MSG_INVALID

77
lang/tmp/strings2.cfg Normal file
View File

@ -0,0 +1,77 @@
MSG_RUNNING
MSG_DONE
MSG_BUGS
MSG_FEEDBACK
MSG_LIKE
MSG_IMPROVE
MSG_KNOW
MSG_FLAWLESS
MSG_H_FIRST
MSG_ARGUMENTS
MSG_H_HELP
MSG_H_DIR
MSG_H_INSTALL
MSG_H_MODE
MSG_H_SUPPORTED
MSG_H_READY
MSG_H_TUI
MSG_H_GUI
MSG_H_ADD
MSG_H_SORT
MSG_H_PUSH
MSG_H_COPY
MSG_H_TRANSLATE
MSG_HOMEPAGE
MSG_HOSTED
MSG_CHAT
MSG_YAD
MSG_FZF
MSG_CONFIG
MSG_ICONS
MSG_INTERM
MSG_ERROR
MSG_NO_DISTRO
MSG_C_ICONS
MSG_C_ENTRIES
MSG_NEEDED
MSG_STRUCTURE
MSG_SETTINGUP
MSG_INSTALLING
MSG_C_ENTRY
MSG_INTERM
MSG_CREATING
MSG_DESKTOP_ENTRY
MSG_PREPARED
MSG_NO_VM
MSG_NEW
MSG_OR_RUN
MSG_TRYING
MSG_TRYING
MSG_TRYING
MSG_STARTING
MSG_DONE
MSG_LANG_CHANGE
MSG_LANG_CODE
MSG_LANG
MSG_DUMP
MSG_MERGING
MSG_MO
MSG_COPY
MSG_TRANSLATION
MSG_AS_ROOT
MSG_C_TRANSLATION
MSG_DEFAULT_TERMINAL
MSG_INVALID_AGAIN
MSG_TERMINAL_SET
MSG_NO
MSG_S_INSTALLATION
MSG_MODE
MSG_U_SUPPORTED
MSG_U_READY
MSG_S_TUI
MSG_S_GUI
MSG_ADD_STARTED
MSG_SORTING
MSG_PUSHING
MSG_C_ISOS
MSG_INVALID

View File

@ -1,120 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2022 darkmaster @grm34 Neternels Team
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# [!] ZMB Translate...
# -------------------------------------------------------------------
# This script automatically translates base language strings and adds
# them into the various translations (original will be used on error).
# It also removes duplicate strings and rearranges them alphabetically.
# -------------------------------------------------------------------
# Shell options
shopt -s progcomp
shopt -u dirspell progcomp_alias
_sort_strings() {
# RM duplicate strings from an array and sorts them alphabetically
# Usage: _sort_strings "$@" (array of strings)
# Returns: $sorted_strings (array)
local string strings
declare -A strings
for string in "${@}"; do
[[ $string ]] && IFS=" " strings["${string:- }"]=1
done
# shellcheck disable=SC2207
IFS=$'\n' sorted_strings=($(sort <<< "${!strings[*]}"))
unset IFS
}
_clean_cfg_files() {
# RM duplicates lines and sorts them alphabetically
# Usage: _clean_cfg_files "$@" (array of files)
local file
for file in "$@"; do
mapfile -t strings < "$file"
_sort_strings "${strings[@]}"
printf "%s\n" "${sorted_strings[@]}" > "$file"
done
}
_get_strings_from_cfg() {
# Grabs strings from CFG files
# Usage: _get_strings_from_cfg "$@" (array of files)
# Returns: $<language_code>_strings $cfg_list (arrays)
local file name
for file in "$@"; do
name=${file##*/}; name="${name/.cfg/_strings}"
mapfile -t "$name" < "$file"
[[ $name != en_strings ]] && cfg_list+=("$name")
done
}
_get_string_data() {
# Grabs string name and string value
# Returns: $data (array)
IFS=$'\n' read -d "" -ra data <<< "${1//=/$'\n'}"
data[1]=${data[1]//\"}
unset IFS
}
_translate_string() {
# Usage: _translate_string "string" "language code"
# Returns: $translated (string)
translated="$(curl -s https://api-free.deepl.com/v2/translate \
-d auth_key=f1414922-db81-5454-67bd-9608cdca44b3:fx \
-d "text=$1" -d "target_lang=${2^^}" \
| grep -o '"text":"[^"]*' | grep -o '[^"]*$')"
}
_translate_and_add_missing_strings_into_cfg() {
# Translates then write missing strings from base language
# into the various translation files (from $cfg_list)
local line language trad_strings
for line in "${en_strings[@]:?}"; do
_get_string_data "$line"
for language in "${cfg_list[@]}"; do
declare -n trad_strings="$language"
if [[ "${trad_strings[*]}" != *"${data[0]}="* ]]; then
_translate_string "${data[1]}" "${language/_strings}"
[[ -n $translated ]] && line="${data[0]}=\"${translated}\""
[[ -n $translated ]] && note="translated" || note="original"
trad_strings+=("$line"); file="${language/_strings/.cfg}"
printf "%s\n" "${trad_strings[@]}" > "lang/$file"
echo "=> ${data[0]} (${note}) added into $file"
fi
done
done
}
# Run ZMB Translate
if [[ $1 == zmb ]]; then
echo "Running ZMB translate (this could take a while)..."
_clean_cfg_files lang/*.cfg
_get_strings_from_cfg lang/*.cfg
_translate_and_add_missing_strings_into_cfg
_clean_cfg_files lang/*.cfg
[[ $note ]] && echo "==> done" || echo "==> nothing to translate"
else
echo "ERROR: you must specify 'zmb' as argument"
fi