From 7b0bc4469f105c4750ed8e56c525914a839bd7d9 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Mon, 16 Sep 2024 20:15:57 +0200 Subject: [PATCH] Improving message for missing packages in LaTeX. --- LogarithmPlotter/i18n/lp_de.ts | 62 ++++++++++++++++------------ LogarithmPlotter/i18n/lp_en.ts | 62 ++++++++++++++++------------ LogarithmPlotter/i18n/lp_es.ts | 62 ++++++++++++++++------------ LogarithmPlotter/i18n/lp_fr.ts | 62 ++++++++++++++++------------ LogarithmPlotter/i18n/lp_hu.ts | 62 ++++++++++++++++------------ LogarithmPlotter/i18n/lp_nb_NO.ts | 62 ++++++++++++++++------------ LogarithmPlotter/i18n/lp_template.ts | 62 ++++++++++++++++------------ LogarithmPlotter/util/latex.py | 23 ++++++----- 8 files changed, 258 insertions(+), 199 deletions(-) diff --git a/LogarithmPlotter/i18n/lp_de.ts b/LogarithmPlotter/i18n/lp_de.ts index 8fa02e1..4f567f9 100644 --- a/LogarithmPlotter/i18n/lp_de.ts +++ b/LogarithmPlotter/i18n/lp_de.ts @@ -720,87 +720,91 @@ Diese Einstellungen können jederzeit über das Menü "Einstellungen" Danksagungen und Beiträge - LogarithmPlotter - + Source code Quellcode - + Original library by Raphael Graf Originalbibliothek von Raphael Graf - + Source Quelle - + Ported to Javascript by Matthew Crumley Portiert auf Javascript von Matthew Crumley - - - - - + + + Website Website - + Ported to QMLJS by Ad5001 Portiert auf QMLJS von Ad5001 - + Libraries included Einschließlich Bibliotheken - + Email E-Mail - + English Englisch - + French Französisch - + German Deutsch - + Hungarian Ungarisch - - + + + Github Github - + Norwegian Norwegisch - + + Spanish + + + + Translations included Einschließlich Übersetzungen - + Improve Verbessern @@ -1236,7 +1240,7 @@ Ausdruck analysiert: %3 latex - + No Latex installation found. If you already have a latex distribution installed, make sure it's installed on your path. Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. @@ -1245,12 +1249,12 @@ Wenn Sie bereits eine LaTeX-Distribution installiert haben, vergewissern Sie sic Andernfalls können Sie eine LaTeX-Distribution wie TeX Live unter https://tug.org/texlive/ herunterladen. - + DVIPNG was not found. Make sure you include it from your Latex distribution. DVIPNG wurde nicht gefunden. Stellen Sie sicher, dass Sie es aus Ihrer LaTeX-Distribution einbinden. - + An exception occured within the creation of the latex formula. Process '{}' ended with a non-zero return code {}: @@ -1263,12 +1267,16 @@ Der Prozess '{}' wurde mit einem Rückgabecode ungleich Null beendet { Bitte vergewissern Sie sich, dass Ihre LaTeX-Installation korrekt ist, und melden Sie einen Fehler, falls dies der Fall ist. - - Your LaTeX installation does not include the '{}' package. Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. + + Your LaTeX installation does not include some required packages: + +- {} (https://ctan.org/pkg/{}) + +Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. - + An exception occured within the creation of the latex formula. Process '{}' took too long to finish: {} diff --git a/LogarithmPlotter/i18n/lp_en.ts b/LogarithmPlotter/i18n/lp_en.ts index 2f4ea77..5d2e492 100644 --- a/LogarithmPlotter/i18n/lp_en.ts +++ b/LogarithmPlotter/i18n/lp_en.ts @@ -720,87 +720,91 @@ These settings can be changed at any time from the "Settings" menu.Thanks and Contributions - LogarithmPlotter - + Source code Source code - + Original library by Raphael Graf Original library by Raphael Graf - + Source Source - + Ported to Javascript by Matthew Crumley Ported to Javascript by Matthew Crumley - - - - - + + + Website Website - + Ported to QMLJS by Ad5001 Ported to QMLJS by Ad5001 - + Libraries included Libraries included - + Email Email - + English English - + French French - + German German - + Hungarian Hungarian - - + + + Github Github - + Norwegian Norwegian - + + Spanish + + + + Translations included Translations included - + Improve Improve @@ -1236,7 +1240,7 @@ Evaluated expression: %3 latex - + No Latex installation found. If you already have a latex distribution installed, make sure it's installed on your path. Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. @@ -1245,12 +1249,12 @@ If you already have a LaTeX distribution installed, make sure it's installe Otherwise, you can download a LaTeX distribution like TeX Live at https://tug.org/texlive/. - + DVIPNG was not found. Make sure you include it from your Latex distribution. DVIPNG was not found. Make sure you include it from your LaTeX distribution. - + An exception occured within the creation of the latex formula. Process '{}' ended with a non-zero return code {}: @@ -1263,12 +1267,16 @@ Process '{}' ended with a non-zero return code {}: Please make sure your LaTeX installation is correct and report a bug if so. - - Your LaTeX installation does not include the '{}' package. Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. + + Your LaTeX installation does not include some required packages: + +- {} (https://ctan.org/pkg/{}) + +Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. - + An exception occured within the creation of the latex formula. Process '{}' took too long to finish: {} diff --git a/LogarithmPlotter/i18n/lp_es.ts b/LogarithmPlotter/i18n/lp_es.ts index bb33fbe..2d8cee0 100644 --- a/LogarithmPlotter/i18n/lp_es.ts +++ b/LogarithmPlotter/i18n/lp_es.ts @@ -682,87 +682,91 @@ - + Source code - + Original library by Raphael Graf - + Source - + Ported to Javascript by Matthew Crumley - - - - - + + + Website - + Ported to QMLJS by Ad5001 - + Libraries included - + Email - + English - + French - + German - + Hungarian - - + + + Github - + Norwegian - + + Spanish + + + + Translations included - + Improve @@ -1149,19 +1153,19 @@ Evaluated expression: %3 latex - + No Latex installation found. If you already have a latex distribution installed, make sure it's installed on your path. Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. - + DVIPNG was not found. Make sure you include it from your Latex distribution. - + An exception occured within the creation of the latex formula. Process '{}' ended with a non-zero return code {}: @@ -1170,12 +1174,16 @@ Please make sure your latex installation is correct and report a bug if so. - - Your LaTeX installation does not include the '{}' package. Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. + + Your LaTeX installation does not include some required packages: + +- {} (https://ctan.org/pkg/{}) + +Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. - + An exception occured within the creation of the latex formula. Process '{}' took too long to finish: {} diff --git a/LogarithmPlotter/i18n/lp_fr.ts b/LogarithmPlotter/i18n/lp_fr.ts index aa78b8f..c920c5d 100644 --- a/LogarithmPlotter/i18n/lp_fr.ts +++ b/LogarithmPlotter/i18n/lp_fr.ts @@ -728,87 +728,91 @@ These settings can always be changed at any time from the "Settings" m Remerciements et contributions - LogarithmPlotter - + Source code Code source - + Original library by Raphael Graf Bibliothèque originale de Raphael Graf - + Source Source - + Ported to Javascript by Matthew Crumley Porté en Javascript par Matthew Crumley - - - - - + + + Website Site web - + Ported to QMLJS by Ad5001 Porté à QMLJS par Ad5001 - + Libraries included Bibliothèques incluses - + Email Email - + English Anglais - + French Français - + German Allemand - + Hungarian Hongrois - - + + + Github Github - + Norwegian Norvégien - + + Spanish + + + + Translations included Traductions incluses - + Improve Améliorer @@ -1245,7 +1249,7 @@ Formule analysée : %3 latex - + No Latex installation found. If you already have a latex distribution installed, make sure it's installed on your path. Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. @@ -1254,12 +1258,12 @@ Si vous avez déjà installé une distribution LaTeX, assurez-vous qu'elle Sinon, vous pouvez télécharger une distribution LaTeX comme TeX Live à l'adresse https://tug.org/texlive/. - + DVIPNG was not found. Make sure you include it from your Latex distribution. DVIPNG n'a pas été trouvé. Assurez-vous de l'inclure dans votre distribution LaTeX. - + An exception occured within the creation of the latex formula. Process '{}' ended with a non-zero return code {}: @@ -1272,12 +1276,16 @@ Le processus '{}' s'est terminé par un code de retour non nul {} Vérifiez que votre installation de LaTeX est correcte et signalez un bogue si c'est le cas. - - Your LaTeX installation does not include the '{}' package. Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. + + Your LaTeX installation does not include some required packages: + +- {} (https://ctan.org/pkg/{}) + +Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. - + An exception occured within the creation of the latex formula. Process '{}' took too long to finish: {} diff --git a/LogarithmPlotter/i18n/lp_hu.ts b/LogarithmPlotter/i18n/lp_hu.ts index 0252785..2829421 100644 --- a/LogarithmPlotter/i18n/lp_hu.ts +++ b/LogarithmPlotter/i18n/lp_hu.ts @@ -720,87 +720,91 @@ Ezek a beállítások bármikor módosíthatók a „Beállítások” menüben. Köszönet és hozzájárulás - LogarithmPlotter - + Source code Forráskód - + Original library by Raphael Graf Eredeti könyvtár: Graf Raphael - + Source Forrás - + Ported to Javascript by Matthew Crumley JavaScript-átalakítás: Crumley Máté - - - - - + + + Website Honlap - + Ported to QMLJS by Ad5001 QMLJS-átalakítás: Ad5001 - + Libraries included Tartalmazott könyvtárak - + Email E-mail - + English angol - + French francia - + German német - + Hungarian magyar - - + + + Github GitHub - + Norwegian norvég - + + Spanish + + + + Translations included A felhasználói felület nyelvei - + Improve Fejlesztés @@ -1236,7 +1240,7 @@ Kiértékelt kifejezés: %3 latex - + No Latex installation found. If you already have a latex distribution installed, make sure it's installed on your path. Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. @@ -1245,12 +1249,12 @@ Ha már telepítve van egy LaTeX disztribúció, győződjön meg arról, hogy a Egyébként letölthet egy LaTeX disztribúciót, például a TeX Live-t a https://tug.org/texlive/ címről. - + DVIPNG was not found. Make sure you include it from your Latex distribution. DVIPNG nem található. Ügyeljen arra, hogy a LaTeX disztribúciójából tartalmazza. - + An exception occured within the creation of the latex formula. Process '{}' ended with a non-zero return code {}: @@ -1263,12 +1267,16 @@ A(z) „{}” folyamat nullától eltérő visszatérési kóddal ({}) végződ Kérjük, ellenőrizze, hogy a LaTeX telepítése helyes-e, és ha igen, jelentse a hibát. - - Your LaTeX installation does not include the '{}' package. Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. + + Your LaTeX installation does not include some required packages: + +- {} (https://ctan.org/pkg/{}) + +Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. - + An exception occured within the creation of the latex formula. Process '{}' took too long to finish: {} diff --git a/LogarithmPlotter/i18n/lp_nb_NO.ts b/LogarithmPlotter/i18n/lp_nb_NO.ts index 99b3698..1f8f3b8 100644 --- a/LogarithmPlotter/i18n/lp_nb_NO.ts +++ b/LogarithmPlotter/i18n/lp_nb_NO.ts @@ -672,87 +672,91 @@ Disse innstillingene kan endres når som helst fra «Innstillinger»-menyen. - + Source code - + Original library by Raphael Graf - + Source - + Ported to Javascript by Matthew Crumley - - - - - + + + Website - + Ported to QMLJS by Ad5001 - + Libraries included - + Email - + English - + French - + German - + Hungarian - - + + + Github - + Norwegian - + + Spanish + + + + Translations included - + Improve @@ -1113,19 +1117,19 @@ Evaluated expression: %3 latex - + No Latex installation found. If you already have a latex distribution installed, make sure it's installed on your path. Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. - + DVIPNG was not found. Make sure you include it from your Latex distribution. - + An exception occured within the creation of the latex formula. Process '{}' ended with a non-zero return code {}: @@ -1134,12 +1138,16 @@ Please make sure your latex installation is correct and report a bug if so. - - Your LaTeX installation does not include the '{}' package. Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. + + Your LaTeX installation does not include some required packages: + +- {} (https://ctan.org/pkg/{}) + +Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. - + An exception occured within the creation of the latex formula. Process '{}' took too long to finish: {} diff --git a/LogarithmPlotter/i18n/lp_template.ts b/LogarithmPlotter/i18n/lp_template.ts index 55e57b6..92ee723 100644 --- a/LogarithmPlotter/i18n/lp_template.ts +++ b/LogarithmPlotter/i18n/lp_template.ts @@ -560,87 +560,91 @@ - + Source code - + Original library by Raphael Graf - + Source - + Ported to Javascript by Matthew Crumley - - - - - + + + Website - + Ported to QMLJS by Ad5001 - + Libraries included - + Email - + English - + French - + German - + Hungarian - - + + + Github - + Norwegian - + + Spanish + + + + Translations included - + Improve @@ -865,19 +869,19 @@ Evaluated expression: %3 latex - + No Latex installation found. If you already have a latex distribution installed, make sure it's installed on your path. Otherwise, you can download a Latex distribution like TeX Live at https://tug.org/texlive/. - + DVIPNG was not found. Make sure you include it from your Latex distribution. - + An exception occured within the creation of the latex formula. Process '{}' ended with a non-zero return code {}: @@ -886,12 +890,16 @@ Please make sure your latex installation is correct and report a bug if so. - - Your LaTeX installation does not include the '{}' package. Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. + + Your LaTeX installation does not include some required packages: + +- {} (https://ctan.org/pkg/{}) + +Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter. - + An exception occured within the creation of the latex formula. Process '{}' took too long to finish: {} diff --git a/LogarithmPlotter/util/latex.py b/LogarithmPlotter/util/latex.py index 7567c56..9ebb1c4 100644 --- a/LogarithmPlotter/util/latex.py +++ b/LogarithmPlotter/util/latex.py @@ -35,6 +35,7 @@ If not found, it will send an alert to the user. """ LATEX_PATH = which('latex') DVIPNG_PATH = which('dvipng') +PACKAGES = ["calligra", "amsfonts", "inputenc"] DEFAULT_LATEX_DOC = Template(r""" \documentclass[]{minimal} @@ -177,16 +178,18 @@ class Latex(QObject): proc.kill() out, err = proc.communicate() output = str(out, 'utf8') + "\n" + str(err, 'utf8') - if 'calligra.sty' in output and 'not found' in output: - # Calligra package not installed. - QMessageBox.warning(None, "LogarithmPlotter - Latex", - QCoreApplication.translate("latex", "Your LaTeX installation does not include the '{}' package. Make sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter.") - .format('calligra')) - else: - QMessageBox.warning(None, "LogarithmPlotter - Latex", - QCoreApplication.translate("latex", "An exception occured within the creation of the latex formula.\nProcess '{}' took too long to finish:\n{}\nPlease make sure your latex installation is correct and report a bug if so.") - .format(" ".join(process), output)) - raise Exception(" ".join(process) + " process timed out:\n" + output) + if 'not found' in output: + for pkg in PACKAGES: + if f'{pkg}.sty' in output: + # Package missing. + QMessageBox.warning(None, "LogarithmPlotter - Latex", + QCoreApplication.translate("latex", "Your LaTeX installation does not include some required packages:\n\n- {} (https://ctan.org/pkg/{})\n\nMake sure said package is installed, or disable the LaTeX rendering in LogarithmPlotter.") + .format(pkg, pkg)) + raise Exception("Latex: Missing package " + pkg) + QMessageBox.warning(None, "LogarithmPlotter - Latex", + QCoreApplication.translate("latex", "An exception occured within the creation of the latex formula.\nProcess '{}' took too long to finish:\n{}\nPlease make sure your latex installation is correct and report a bug if so.") + .format(" ".join(process), output)) + raise Exception(" ".join(process) + " process timed out:\n" + output) def cleanup(self, export_path): """