diff --git a/lang/cs.cfg b/lang/cs.cfg new file mode 100644 index 0000000..44c926e --- /dev/null +++ b/lang/cs.cfg @@ -0,0 +1,71 @@ +MSG_ADD_STARTED="Přidání nového distra zahájeno..." +MSG_BUGS="PS: Viděli jste nějaké chyby?" +MSG_C_DESKTOP="Kopírování položek plochy a místních prostředí..." +MSG_C_ENTRY="Kopírování záznamu na plochu..." +MSG_C_ICONS="Kopírování ikon..." +MSG_C_ISOS="Kopírování ISO do dir. Bude to chvíli trvat..." +MSG_C_LANG="Chcete kopírovat překlad do systému? (y/n)" +MSG_C_TRANS="Kopírování překladu..." +MSG_D_INTERM="Chcete, aby se DistroHopper spouštěl v terminálu? (y/n)" +MSG_DIR="vytvoření konfiguračního adresáře..." +MSG_D_LANG="\\n Pokoušíme se stáhnout systém Windows %s %s...\\n\\n" +MSG_DONE="Hotovo" +MSG_D_OS="\\n Pokus o stažení %s %s...\\n\\n" +MSG_D_RELEASE="\\n Pokus o stažení %s %s %s...\\n\\n" +MSG_DUMP="Odhození jazykového zdroje..." +MSG_ERROR="Chyba" +MSG_FEEDBACK="Mohli byste prosím poskytnout zpětnou vazbu?" +MSG_FZF="Chybí fzf!" +MSG_H_ADD="\\ta\\tadd\\t\\t\\tPřidání nové distribuce do quickget\\n" +MSG_H_COPY="\\tc\\tcopy\\t\\t\\tKopírování všech ISO do cílového adresáře (pro Ventoy)\\n" +MSG_H_DIR="\\td\\tdir\\t\\t\\tNastavení výchozího adresáře, kam se ukládají virtuální počítače\\n" +MSG_H_FIRST="\\texample pro První spuštění z terminálu:" +MSG_H_GUI="\\tg\\tgui\\t\\t\\t Spustit grafické uživatelské rozhraní (GUI)\\n" +MSG_H_HELP="\\th\\thelp\\t\\t\\tZobrazit tuto nápovědu a ukončit\\n" +MSG_H_INSTALL="\\ti\\tinstall\\t\\t\\t\\tInstall DistroHopper\\n" +MSG_H_LANG="\\tl\\tlanguage\\t\\tPřeložit DistroHopper\\n" +MSG_H_MODE="\\Přenosný režim" +MSG_HOMEPAGE="Domovská stránka: dh.osowoso.xyz" +MSG_HOSTED="Projekt je umístěn na adrese: https://github.com/oSoWoSo/DistroHopper" +MSG_H_PUSH="\\tp\\tpush\\t\\t\\tPush změnil quickget na quickemu projektu\\n" +MSG_H_READY="\\tr\\tready\\t\\t\\tUpdate ready to run VMs\\n" +MSG_H_SORT="\\tf\\tfunkce\\t\\tSortovací funkce v quickget\\n" +MSG_H_SUPPORTED="\\ts\\tpodporované\\t\\tAktualizace podporovaných virtuálních počítačů\\n" +MSG_H_TUI="\\tt\\ttui\\t\\t\\tSpustit uživatelské rozhraní terminálu (TUI)\\n" +MSG_CHAT="Chatovací skupina na SimpleX: https://tinyurl.com/7hm4kcjx" +MSG_ICONS="vytvoření adresáře s ikonami jako root..." +MSG_IMPROVE="Co lze zlepšit, přidat, změnit?" +MSG_INSTALLING="Instalace programu DistroHopper..." +MSG_INVALID="Neplatná možnost:" +MSG_LANG_CODE="Pokud chcete vytvořit nový, vložte dvoumístný kód jazyka..." +MSG_LANG_CHANGE="Která jazyková změna? (cs/cs)" +MSG_LANG="Zvolený jazyk je:" +MSG_LETMEKNOW=" Dejte mi vědět..." +MSG_LIKE="Jak se vám líbí DistroHopper?" +MSG_MERG="Sloučení změn... (Udělejte si to sami)" +MSG_MODE="Přepnutí do přenosného režimu!" +MSG_MO="Generování souboru .mo..." +MSG_NEEDED="Potřebná instalace..." +MSG_NEW=" Chcete vytvořit nový virtuální počítač? (c)" +MSG_NO_CONF="Nebyly nalezeny žádné soubory .conf" +MSG_NO_DISTROERROR="V současné době nemám podporu pro vaše distro" +MSG_NO="Nebyl poskytnut žádný argument!\\n\\n" +MSG_NO_VM="Nebyl nalezen žádný virtuální počítač." +MSG_OR_RUN=" nebo spustit stávající? (stiskněte cokoli)\\n" +MSG_PREPARED=" Prepared VMs:\\n-------------\\n\\n" +MSG_PUSHING="Prosazování změn v..." +MSG_Q_INTERM="Chcete, aby quickget zobrazoval výstupy v terminálu? (y/n)" +MSG_R_TUI="Spuštění DistroHopper TUI..." +MSG_RUNNING="DistroHopper je spuštěn... Pro ukončení stiskněte kdykoli klávesu Ctrl-Q." +MSG_SETTINGUP="Nastavení adresáře..." +MSG_S_GUI="Spuštění grafického rozhraní DistroHopper..." +MSG_S_CHOOSED="\\n Začíná %s...\\n\\n" +MSG_S_INSTALL="Zahájení instalace..." +MSG_SORTING="Funkce třídění v šabloně..." +MSG_STRUCTURE="Vytvoření adresářové struktury..." +MSG_U_READY="Aktualizace připravených virtuálních počítačů..." +MSG_U_SUPPORTED="Aktualizace podporovaných virtuálních počítačů..." +MSG_VM="Vytvoření vstupu na plochu..." +MSG_YAD="Chybí yad!" +MSQ_ARGUMENTS="Možné argumenty:" +MSQ_FLAWLESS="Přeji vám bezchybné distro hopping..." diff --git a/lang/de.cfg b/lang/de.cfg new file mode 100644 index 0000000..5a4ce58 --- /dev/null +++ b/lang/de.cfg @@ -0,0 +1,71 @@ +MSG_ADD_STARTED="Hinzufügen einer neuen Distro gestartet..." +MSG_BUGS="PS: Sie haben ein paar Wanzen gesehen?" +MSG_C_DESKTOP="Kopieren von Desktop-Einträgen und Gebietsschemata..." +MSG_C_ENTRY="Kopieren des Desktop-Eintrags..." +MSG_C_ICONS="Kopieren von Symbolen..." +MSG_C_ISOS="Kopieren von ISOs in ein Verzeichnis. Es wird einige Zeit dauern..." +MSG_C_LANG="Möchten Sie die Übersetzung ins System kopieren? (j/n)" +MSG_C_TRANS="Kopieren der Übersetzung..." +MSG_D_INTERM="Möchten Sie, dass DistroHopper im Terminal läuft? (j/n)" +MSG_DIR="Konfigurationsverzeichnis erstellen..." +MSG_D_LANG="\\n Versucht, Windows %s %s herunterzuladen...\\n\\n" +MSG_DONE="Erledigt" +MSG_D_OS="\\n Versucht, %s %s herunterzuladen...\\n\\n" +MSG_D_RELEASE="\\n Versucht, %s %s %s herunterzuladen...\\n\\n" +MSG_DUMP="Dumping der Sprachquelle..." +MSG_ERROR="Fehler" +MSG_FEEDBACK="Könnten Sie uns bitte ein Feedback geben?" +MSG_FZF="Fehlender fzf!" +MSG_H_ADD="\\ta\\tadd\\t\\t\\t Neue Distro zu quickget\\n hinzufügen" +MSG_H_COPY="\\tc\\tcopy\\t\\tCopy all ISOs to target dir (for Ventoy)\\n" +MSG_H_DIR="\\td\\tdir\\t\\t\\tStandardverzeichnis festlegen, in dem VMs gespeichert werden\\n" +MSG_H_FIRST="\\Beispiel für die erste Ausführung vom Terminal aus:" +MSG_H_GUI="\\tg\\tgui\\t\\tAusführen der grafischen Benutzeroberfläche (GUI)\\n" +MSG_H_HELP="\\th\\thelp\\t\\t\\tDiese Hilfe anzeigen und beenden\\n" +MSG_H_INSTALL="\\ti\\tinstall\\t\\t\\tInstallation DistroHopper\\n" +MSG_H_LANG="\\tl\\tlanguage\\t\\tTranslate DistroHopper\\n" +MSG_H_MODE="\\und die Art und Weise und die Art und Weise und die Art und Weise des Tragens." +MSG_HOMEPAGE="Startseite: dh.osowoso.xyz" +MSG_HOSTED="Das Projekt ist zu finden unter: https://github.com/oSoWoSo/DistroHopper" +MSG_H_PUSH="\\tp\\tpush\\t\\tPush änderte quickget in quickemu project\\n" +MSG_H_READY="\\tr\\tready\\t\\t\\tAktualisierung bereit zur Ausführung von VMs\\n" +MSG_H_SORT="\\tf\\tFunktionen\\t\\tSortierfunktionen in quickget\\n" +MSG_H_SUPPORTED="\\ts\\tsunterstützt\\t\\tUnterstützte VMs\\n aktualisieren" +MSG_H_TUI="\\tt\\ttui\\t\\t\\tAusführen der Terminal-Benutzeroberfläche (TUI)\\n" +MSG_CHAT="Chat-Gruppe auf SimpleX: https://tinyurl.com/7hm4kcjx" +MSG_ICONS="Icons-Verzeichnis als Root erstellen..." +MSG_IMPROVE="Was kann verbessert, hinzugefügt, verändert werden?" +MSG_INSTALLING="Installation von DistroHopper..." +MSG_INVALID="Ungültige Option:" +MSG_LANG_CODE="Wenn Sie einen neuen erstellen möchten, geben Sie den zweistelligen Sprachcode ein..." +MSG_LANG="Die gewählte Sprache ist:" +MSG_LANG_CHANGE="Welche Sprache wechseln? (en/cs)" +MSG_LETMEKNOW=" Sag mir Bescheid..." +MSG_LIKE="Wie gefällt Ihnen DistroHopper?" +MSG_MERG="Zusammenführen von Änderungen... (Do it yourself)" +MSG_MODE="Umschalten auf portablen Modus!" +MSG_MO="Erzeugen der .mo-Datei..." +MSG_NEEDED="Installation erforderlich..." +MSG_NEW=" Möchten Sie eine neue VM erstellen? (c)" +MSG_NO_CONF="Keine .conf-Dateien gefunden" +MSG_NO_DISTROERROR="Ich habe derzeit keine Unterstützung für Ihre Distro" +MSG_NO="Es wurden keine Argumente vorgebracht!\\n\\n" +MSG_NO_VM="Keine VMs gefunden." +MSG_OR_RUN=" oder ein bestehendes ausführen? (irgendetwas drücken)\\n" +MSG_PREPARED=" Prepared VMs:\\n-------------\\n\\n" +MSG_PUSHING="Änderungen vorantreiben..." +MSG_Q_INTERM="Möchten Sie, dass quickget die Ausgaben im Terminal anzeigt? (j/n)" +MSG_R_TUI="Laufender DistroHopper TUI..." +MSG_RUNNING="DistroHopper läuft... Drücken Sie jederzeit Strg-Q zum Beenden." +MSG_SETTINGUP="Verzeichnis einrichten..." +MSG_S_GUI="DistroHopper GUI starten..." +MSG_S_CHOOSED="\\n Beginnend mit %s...\\n\\n" +MSG_S_INSTALL="Start der Installation..." +MSG_SORTING="Sortierfunktionen in der Vorlage..." +MSG_STRUCTURE="Verzeichnisstruktur erstellen..." +MSG_U_READY="Aktualisieren von fertigen VMs..." +MSG_U_SUPPORTED="Aktualisieren unterstützter VMs..." +MSG_VM="Desktop-Eintrag erstellen..." +MSG_YAD="Ich vermisse Yad!" +MSQ_ARGUMENTS="Mögliche Argumente:" +MSQ_FLAWLESS="Ich wünsche dir ein fehlerfreies Distro-Hopping..." diff --git a/lang/en.cfg b/lang/en.cfg new file mode 100644 index 0000000..6de6536 --- /dev/null +++ b/lang/en.cfg @@ -0,0 +1,71 @@ +MSG_ADD_STARTED="Adding new distro started..." +MSG_BUGS="PS: You saw some bugs?" +MSG_C_DESKTOP="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_C_LANG="Do you want copy translation to system? (y/n)" +MSG_C_TRANS="Copying translation..." +MSG_D_INTERM="Do you want DistroHopper to run in the terminal? (y/n)" +MSG_DIR="creating config dir..." +MSG_D_LANG="\n Trying to download Windows %s %s...\n\n" +MSG_DONE="Done" +MSG_D_OS="\n Trying to download %s %s...\n\n" +MSG_D_RELEASE="\n Trying to download %s %s %s...\n\n" +MSG_DUMP="Dumping language source..." +MSG_ERROR="Error" +MSG_FEEDBACK="Could you please provide feedback?" +MSG_FZF="Missing fzf!" +MSG_H_ADD="\ta\tadd\t\t\tAdd new distro to quickget\n" +MSG_H_COPY="\tc\tcopy\t\t\tCopy all ISOs to target dir (for Ventoy)\n" +MSG_H_DIR="\td\tdir\t\t\tSet default directory where VMs are stored\n" +MSG_H_FIRST="\texample for First run from terminal:" +MSG_H_GUI="\tg\tgui\t\t\tRun graphical user interface (GUI)\n" +MSG_H_HELP="\th\thelp\t\t\tShow this help and exit\n" +MSG_H_INSTALL="\ti\tinstall\t\t\tInstall DistroHopper\n" +MSG_H_LANG="\tl\tlanguage\t\tTranslate DistroHopper\n" +MSG_H_MODE="\tm\tmode\t\t\tPortable mode\n" +MSG_HOMEPAGE="Homepage: dh.osowoso.xyz" +MSG_HOSTED="Project hosted at: https://github.com/oSoWoSo/DistroHopper" +MSG_H_PUSH="\tp\tpush\t\t\tPush changed quickget to quickemu project\n" +MSG_H_READY="\tr\tready\t\t\tUpdate ready to run VMs\n" +MSG_H_SORT="\tf\tfunctions\t\tSort functions in quickget\n" +MSG_H_SUPPORTED="\ts\tsupported\t\tUpdate supported VMs\n" +MSG_H_TUI="\tt\ttui\t\t\tRun terminal user interface (TUI)\n" +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_INVALID="Invalid option:" +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_LETMEKNOW=" Let me know..." +MSG_LIKE="How do you like DistroHopper?" +MSG_MERG="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_CONF="No .conf files found" +MSG_NO_DISTROERROR="I currently don't have support for your distro" +MSG_NO="No argumet provided!\n\n" +MSG_NO_VM="No VMs found." +MSG_OR_RUN=" or run an existing one? (press anything)\n" +MSG_PREPARED=" Prepared VMs:\n-------------\n\n" +MSG_PUSHING="Pushing changes to..." +MSG_Q_INTERM="Do you want quickget to show outputs in the terminal? (y/n)" +MSG_R_TUI="Running DistroHopper TUI..." +MSG_RUNNING="DistroHopper is running... Press Ctrl-Q anytime to exit." +MSG_SETTINGUP="Setting up directory..." +MSG_S_GUI="Starting DistroHopper GUI..." +MSG_S_CHOOSED="\n Starting %s...\n\n" +MSG_S_INSTALL="Starting installation..." +MSG_SORTING="Sorting functions in template..." +MSG_STRUCTURE="Creating directory structure..." +MSG_U_READY="Updating ready VMs..." +MSG_U_SUPPORTED="Updating supported VMs..." +MSG_VM="Creating desktop entry..." +MSG_YAD="Missing yad!" +MSQ_ARGUMENTS="Possible arguments:" +MSQ_FLAWLESS="Wish you flawless distro hopping..." diff --git a/lang/fr.cfg b/lang/fr.cfg new file mode 100644 index 0000000..6aa6bf9 --- /dev/null +++ b/lang/fr.cfg @@ -0,0 +1,71 @@ +MSG_ADD_STARTED="L'ajout d'une nouvelle distro a démarré..." +MSG_BUGS="PS : Vous avez vu des insectes ?" +MSG_C_DESKTOP="Copie des entrées du bureau et des locales..." +MSG_C_ENTRY="Copie de l'entrée du bureau..." +MSG_C_ICONS="Copier des icônes..." +MSG_C_ISOS="Copie des ISO dans le répertoire. Cela prendra un certain temps..." +MSG_C_LANG="Souhaitez-vous que la copie soit traduite dans le système ? (o/n)" +MSG_C_TRANS="Copier la traduction..." +MSG_D_INTERM="Voulez-vous que DistroHopper s'exécute dans le terminal ? (o/n)" +MSG_DIR="création du répertoire de config..." +MSG_D_LANG="\\nEssayant de télécharger Windows %s %s...\\n\\n" +MSG_DONE="Terminé" +MSG_D_OS="\\N- Trying to download %s %s...\\N- Trying to download %s %s...\\N- Trying to download %s %s..." +MSG_D_RELEASE="\\N- Trying to download %s %s %s...\\N- Trying to download %s %s %s...\\N- Trying to download %s %s %s..." +MSG_DUMP="Déversement de la source linguistique..." +MSG_ERROR="Erreur" +MSG_FEEDBACK="Pourriez-vous nous faire part de vos commentaires ?" +MSG_FZF="Manque le fzf !" +MSG_H_ADD="\\ta\\tadd\\t\\t\\tAjouter une nouvelle distro au quickget\\n" +MSG_H_COPY="\\tc\\tcopy\\t\\t\\tCopy all ISOs to target dir (for Ventoy)\\n" +MSG_H_DIR="\\td\\tdir\\t\\t\\t Définir le répertoire par défaut dans lequel les VM sont stockées\\n" +MSG_H_FIRST="\\Exemple de première exécution à partir du terminal :" +MSG_H_GUI="\\tg\\tgui\\t\\t\\tRun graphical user interface (GUI)\\n" +MSG_H_HELP="\\th\\thelp\\t\\t\\t montrer cette aide et sortir\\n" +MSG_H_INSTALL="\\tin\\t\\t\\t\\t\\tInstallation DistroHopper\\n" +MSG_H_LANG="\\tl\\tlanguage\\tTranslate DistroHopper\\n" +MSG_H_MODE="\\tm\\tmode\\t\\t\\tPortable mode\\n" +MSG_HOMEPAGE="Page d'accueil : dh.osowoso.xyz" +MSG_HOSTED="Projet hébergé à l'adresse suivante : https://github.com/oSoWoSo/DistroHopper" +MSG_H_PUSH="\\tp\\tpush\\t\\t\\tPush changed quickget to quickemu project\\n" +MSG_H_READY="\\N- La mise à jour est prête à exécuter les VMs\\N- La mise à jour est prête à exécuter les VMs\\N- La mise à jour est prête à exécuter les VMs\\N" +MSG_H_SORT="\\tf\\tfunctions\\t\\tSort des fonctions en quickget\\n" +MSG_H_SUPPORTED="\\ts\\tsupported\\t\\tUpdate supported VMs\\n" +MSG_H_TUI="\\tt\\ttui\\t\\t\\tRun terminal user interface (TUI)\\n" +MSG_CHAT="Groupe de discussion sur SimpleX : https://tinyurl.com/7hm4kcjx" +MSG_ICONS="création d'un répertoire d'icônes en tant que racine..." +MSG_IMPROVE="Qu'est-ce qui peut être amélioré, ajouté, modifié ?" +MSG_INSTALLING="Installation de DistroHopper..." +MSG_INVALID="Option non valide :" +MSG_LANG_CODE="Si vous souhaitez en créer un nouveau, insérez un code de langue à deux chiffres..." +MSG_LANG_CHANGE="Quel changement de langue ? (en/cs)" +MSG_LANG="La langue choisie est :" +MSG_LETMEKNOW=" Tenez-moi au courant." +MSG_LIKE="Que pensez-vous de DistroHopper ?" +MSG_MERG="Fusionner les changements... (Faites-le vous-même)" +MSG_MODE="Passer en mode portable !" +MSG_MO="Génération du fichier .mo..." +MSG_NEEDED="Installation nécessaire..." +MSG_NEW=" Voulez-vous créer une nouvelle VM ? (c)" +MSG_NO="Aucun argument n'a été fourni !" +MSG_NO_CONF="Aucun fichier .conf trouvé" +MSG_NO_DISTROERROR="Je n'ai actuellement pas de support pour votre distro" +MSG_NO_VM="Aucune VM n'a été trouvée." +MSG_OR_RUN=" ou d'en utiliser un déjà existant ? (appuyer sur n'importe quoi)\\n" +MSG_PREPARED=" Prepared VMs:\\n-------------\\n\\n" +MSG_PUSHING="Pousser les changements à..." +MSG_Q_INTERM="Voulez-vous que quickget affiche les sorties dans le terminal ? (y/n)" +MSG_R_TUI="Lancement de l'interface utilisateur de DistroHopper..." +MSG_RUNNING="DistroHopper est en cours d'exécution... Appuyez sur Ctrl-Q à tout moment pour quitter." +MSG_SETTINGUP="Mise en place d'un répertoire..." +MSG_S_GUI="Démarrage de l'interface graphique de DistroHopper..." +MSG_S_CHOOSED="\\N- Démarrage de %s...\\N- Démarrage de %s...\\N- Démarrage de %s..." +MSG_S_INSTALL="Démarrage de l'installation..." +MSG_SORTING="Fonctions de tri dans les modèles..." +MSG_STRUCTURE="Création de la structure du répertoire..." +MSG_U_READY="Mise à jour des machines virtuelles prêtes..." +MSG_U_SUPPORTED="Mise à jour des VM prises en charge..." +MSG_VM="Création d'une entrée de bureau..." +MSG_YAD="Yad manquant !" +MSQ_ARGUMENTS="Arguments possibles :" +MSQ_FLAWLESS="Souhaitons que vous soyez irréprochable dans vos sauts de distro..." diff --git a/translate.sh b/translate.sh new file mode 100755 index 0000000..fcb4426 --- /dev/null +++ b/translate.sh @@ -0,0 +1,120 @@ +#!/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: $_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 +