UMB-CS-682-Team-03 / tracker

0 stars 0 forks source link

German local crashes on certain words #18

Closed patel-malav closed 7 months ago

patel-malav commented 7 months ago

This is probably not a roundup bug but a translation issue

when adding a translation for reset in german

google translate gave me

msgid "Reset" msgstr "zurücksetzen"

the phonetics on u may be the reason or how the text is not utf-8 maybe

rouilj commented 7 months ago

Is the crash in roundup? If so are you getting a python traceback?

patel-malav commented 7 months ago

Trace back

EXCEPTION AT Wed Mar 20 13:21:02 2024 Traceback (most recent call last): File "/home/me/Documents/roundup/roundup/cgi/client.py", line 802, in inner_main self.determine_language() File "/home/me/Documents/roundup/roundup/cgi/client.py", line 1099, in determine_language self.setTranslator(TranslationService.get_translation( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/me/Documents/roundup/roundup/cgi/TranslationService.py", line 119, in get_translation return i18n.get_translation(language=language, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/me/Documents/roundup/roundup/i18n.py", line 225, in get_translation translator = translation_class(mo) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/gettext.py", line 272, in init self._parse(fp) File "/usr/lib/python3.11/gettext.py", line 424, in _parse catalog[str(msg, charset)] = str(tmsg, charset) ^^^^^^^^^^^^^^^^^^ UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/me/Documents/roundup/roundup/scripts/roundup_server.py", line 265, in run_cgi self.inner_run_cgi() File "/home/me/Documents/roundup/roundup/scripts/roundup_server.py", line 515, in inner_run_cgi tracker.Client(tracker, self, env).main() File "/home/me/Documents/roundup/roundup/cgi/client.py", line 547, in main self.inner_main() File "/home/me/Documents/roundup/roundup/cgi/client.py", line 964, in inner_main

rouilj commented 7 months ago

Thanks. I can reproduce.

rouilj commented 7 months ago

To fix this put this as the first item in de.po:

msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"

This provides the i18n subsystem info about the file. The item that is required to stop the crash is the Content-Type setting which switches it from ascii mode to UTF-8 which is needed to handle the umlut.

The Content-Transfer is probably redundant, but it matches what UTF-8 expects. The Plural-Forms is a hint to the i18n engine on how to handle the case where we have:

   You have %d issues
   You have  %d issues

The translation could be the same in some languages. The Plural forms header says that there are only 2 forms in German. If the value for %d is > 1 use the plural form otherwise use the singular form. So it is good to have in a .po file.

Detail if you want: https://lokalise.com/blog/beginners-guide-to-python-i18n/

The full set of headers can be found in any of the .po files in the locale subdirectory. AFAICT except for these three the rest are administrative and not used by the code.