Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n crash fix? #73

Open
ThomasWaldmann opened this issue Nov 9, 2020 · 0 comments
Open

i18n crash fix? #73

ThomasWaldmann opened this issue Nov 9, 2020 · 0 comments
Milestone

Comments

@ThomasWaldmann
Copy link
Member

from moin-devel mailing list by Paul Boddie:

Thanks for taking care of this release!

I don't have a GitHub account that I generally use for personal projects, but 
there is one very simple patch that I would like to suggest that might help 
people generally:

----

diff --git a/MoinMoin/i18n/__init__.py b/MoinMoin/i18n/__init__.py
index 17061a83..b5abdf25 100644
--- a/MoinMoin/i18n/__init__.py
+++ b/MoinMoin/i18n/__init__.py
@@ -255,7 +255,7 @@ class Translation(object):

 def getDirection(lang):
     """ Return the text direction for a language, either 'ltr' or 'rtl'. """
-    return languages[lang]['x-direction']
+    return languages and languages[lang]['x-direction'] or 'ltr'

 def getText(original, request, lang, **kw):
     """ Return a translation of some original text.

----

Previously, when upgrading Moin, there have been times when it just breaks in 
a nasty and seemingly inexplicable way, and I am pretty sure we have had to 
troubleshoot this a few times on this list or via bug reports.

In the above, where there is some cache issue, the getDirection function fails 
because the languages mapping is not set up properly (or at the time of 
invocation), and I am not even sure that the usual "moin maint cleancache" 
advice helps.

This seems to have occurred in different forms several times over the years. 
For example:

https://moinmo.in/MoinMoinBugs/1.8TypeError_in_i18n.__init__after_upgrade
https://moinmo.in/MoinMoinBugs/I18nLanguagesNotSetInSetupI18nPreauth

Interestingly, the latter of the above bug reports links to a patch that 
potentially fixes the problem but only for WSGI. (Yes, I am still using CGI 
for the few wikis I have running.)

Anyway, thanks once again for the hard work!

Paul

@ThomasWaldmann ThomasWaldmann added this to the 1.9.12 milestone Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant