imiolek-ireneusz / eduActiv8

Educational Activities for Kids
https://www.eduactiv8.org
GNU General Public License v3.0
34 stars 26 forks source link

Check MO files before using #35

Closed glixx closed 5 years ago

glixx commented 5 years ago
eduactiv8
Working directory: /usr/share/eduactiv8
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "/usr/share/eduactiv8/eduactiv8.py", line 649, in <module>
    main()
  File "/usr/share/eduactiv8/eduactiv8.py", line 639, in main
    app.run()
  File "/usr/share/eduactiv8/eduactiv8.py", line 354, in run
    self.set_up_user()
  File "/usr/share/eduactiv8/eduactiv8.py", line 223, in set_up_user
    self.lang.load_language()
  File "/usr/share/eduactiv8/classes/lang.py", line 44, in load_language
    self.get_lang_attr()
  File "/usr/share/eduactiv8/classes/lang.py", line 51, in get_lang_attr
    self.trans[self.lang] = gettext.GNUTranslations(open(filename, "rb"))
FileNotFoundError: [Errno 2] Нет такого файла или каталога: '/usr/share/locale/uk/LC_MESSAGES/eduactiv8.mo'

If file does not exist then do not switch on it and do not remember choice, just ignoring.

imiolek-ireneusz commented 5 years ago

This appears to have happened just after the start of the game probably using saved language selection from the previous installation.

Is there any eduactiv8.mo file in any supported language in /usr/share/locale/? The files may have not been installed there. When it comes to checking, I've had a try/except block there but for some reason, I was reading the file twice. The first time before the try block... must have been some debugging artefact that was forgotten about - I will get it fixed. If the translation file is not there, the program is set to use default messages.

try:     self.trans[self.lang] = gettext.GNUTranslations(open(filename, "rb")) except IOError:     print("Locale not found. Using default messages")     self.trans[self.lang] = gettext.NullTranslations()

glixx commented 5 years ago

Output is on switching language. The second start is impossible.

imiolek-ireneusz commented 5 years ago

Is that when run form a built package or from the source? If from a package, where do you move the locale files when installing? /usr/share/locale/? or somewhere else?

To start again - change the name of your progress database temporarily. It's located at: /.local/share/eduactiv8/eduactiv8.db

glixx commented 5 years ago

I catched very interesting bug in Mageia 7 beta1. All files are present in package, but locales were installed only with according installed locales in system.

imiolek-ireneusz commented 5 years ago

UPDATE: After having installed the Mageia 7 I can see what is going on. The 6fdbd5553ddbc3cae6d00519156e06bed6decf82 commit does fix the issue with the program crashing, however, the program is still failing to find locale files, since, as you stated, they were not installed, so basically uses default messages in all languages.

No idea how to fix this one though, since this is on the installer side of things. Could the locale files within the package be left where they are, or would that violate any system/packaging rules?

glixx commented 5 years ago

Could the locale files within the package be left where they are

Yes in your case, because settings of some distrubutions skip installation of locales if they are extra, but you need all locales to switch between them in GUI.

But you can improve algorithm. As you can see %_install_langs from /etc/rpm/macros has all English locales and your locale. So dialog of langs can contents only available locales if MO file is exist.

imiolek-ireneusz commented 5 years ago

I'd rather keep all the languages, so kids, for instance, can learn Spanish or other language for that matter even though their system is not necessarily supporting that language out of the box. And that lets me get away with redesigning the way language selections are displayed, saving myself some time here :)

glixx commented 5 years ago

Ok