kirienko / gourmet

Gourmet Recipe Manager
GNU General Public License v2.0
30 stars 14 forks source link

PDF-Export in German not working #362

Closed jens4Dev closed 3 years ago

jens4Dev commented 3 years ago

Exporting to PDF fails when language is set to German (de_DE.UTF-8).

Steps to Reproduce

  1. LANG=de_DE.UTF-8
  2. Start Gourmet
  3. Select Export all recipes in File menu
  4. Select PDF as export format, use default file-location (user's home) and default file name recipes.pdf
  5. Leave PDF option as they are & Ok

Expected Behavior

PDF-file is successfully exported and note is shown at top of recipes' list.

Current Behavior

No message is shown in the UI, in terminal a couple of messages are printed:

 Traceback (most recent call last):
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py", line 934, in change_cb
    args = self.get_args_from_opts(self.opts)
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py", line 919, in get_args_from_opts
    args['pagemode'] = self.page_modes[opts[self.OPT_PO][1]] # PAGE MODE
KeyError: None
Traceback (most recent call last):
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/GourmetRecipeManager.py", line 1038, in <lambda>
    '<Control><Shift>T',_('Export all recipes to file'),lambda *args: self.do_export(export_all=True)),
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/GourmetRecipeManager.py", line 698, in do_export
    self.exportManager.offer_multiple_export(
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/exporters/exportManager.py", line 114, in offer_multiple_export
    instance = self.do_multiple_export(recs, fn, exp_type)
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/exporters/exportManager.py", line 155, in do_multiple_export
    myexp, exporterInstance = self.get_multiple_exporter(recs,fn,exp_type,setup_gui,extra_prefs)
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/exporters/exportManager.py", line 140, in get_multiple_exporter
    extra_prefs = self.get_extra_prefs(myexp,extra_prefs)
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/exporters/exportManager.py", line 127, in get_extra_prefs
    extra_prefs = myexp.run_extra_prefs_dialog() or {}
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/plugins/import_export/pdf_plugin/pdf_exporter_plugin.py", line 35, in run_extra_prefs_dialog
    return pdf_exporter.get_pdf_prefs()
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py", line 1029, in get_pdf_prefs
    return pdf_pref_getter.run()
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py", line 912, in run
    return self.get_args_from_opts(self.opts)
  File "/tmp/.mount_GourmeieaQKI/opt/python3.8/lib/python3.8/site-packages/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py", line 919, in get_args_from_opts
    args['pagemode'] = self.page_modes[opts[self.OPT_PO][1]] # PAGE MODE
KeyError: None

Environment

cydanil commented 3 years ago

Interesting, thanks for reporting the issue!
I will look into it this weekend 👍

cydanil commented 3 years ago

Thanks, This happens when changing from one locale (language) to another.
I suppose this is manifesting now because Gourmet used to be in English until we fixed localization in the last release.

Among others, PDF export preferences are stored in the ~/.gourmet/preferences.toml file in the language in which Gourmet was running.
I will do a fix for the preferences to be agnostic. Meanwhile, you may consider deleting the above file (there's nothing crucial in it) or editing it to remove the PDF_EXP section.

cydanil commented 3 years ago

Thanks, This happens when changing from one locale (language) to another.
I suppose this is manifesting now because Gourmet used to be in English until we fixed localization in the last release.

Among others, PDF export preferences are stored in the ~/.gourmet/preferences.toml file in the language in which Gourmet was running.
I will do a fix for the preferences to be agnostic. Meanwhile, you may consider deleting the above file (there's nothing crucial in it) or editing it to remove the PDF_EXP section.

cydanil commented 3 years ago

I was able to make a fix for this.

Working on this highlighted other issues arising when using any of the Index Cards formats.
Once I will have resolved them, I will make a new release.

jens4Dev commented 3 years ago

Deleting the PDF-section in preferences fixed the issue for me - I will test the new release asap.

Thanks a lot!