28 Commits

Author SHA1 Message Date
Christopher Allan Webber
f6bad0eb26 Merge branch 'master' into merge-python3-port
Has some issues, will iteratively fix!

Conflicts:
	mediagoblin/gmg_commands/__init__.py
	mediagoblin/gmg_commands/deletemedia.py
	mediagoblin/gmg_commands/users.py
	mediagoblin/oauth/views.py
	mediagoblin/plugins/api/views.py
	mediagoblin/tests/test_api.py
	mediagoblin/tests/test_edit.py
	mediagoblin/tests/test_oauth1.py
	mediagoblin/tests/test_util.py
	mediagoblin/tools/mail.py
	mediagoblin/webfinger/views.py
	setup.py
2014-09-16 14:01:43 -05:00
Berker Peksag
15c3461b1f Disable cache support of LazyProxy.
Since Babel 1.0, there's a enable_cache keyword argument of LazyProxy,
but we can't pass it directly.
2014-07-28 15:24:49 +03:00
Berker Peksag
cf3b5926f4 Cleanup mediagoblin._compat and fix translation tests. 2014-07-28 13:27:19 +03:00
Berker Peksag
f9a7201c32 Use mediagoblin._compat.{ugettext, ungettext} on Python 3. 2014-06-02 22:25:27 +03:00
Christopher Allan Webber
b02e37c297 removing zh and ja from RTL list. medicalwei reports they are not RTL languages.
This commit sponsored by Philipp Edelmann.  Thanks!
2014-06-02 10:39:23 -05:00
Christopher Allan Webber
023cda0974 Fix Babel version restriction. Onward and upward!
(Fix suggested by simonft... thanks!)
2014-03-22 11:02:24 -05:00
Jiyda Mint Moussa
4a4e4e4ae8 Added rtl language support
RTL languages like Arabic, Hebrew etc were displayed from left
to right. I fixed this by adding a function to check
whether the language of the locale is rtl and change the
direction of the html in "base.html" accordingly.

[Fixes #220]
2013-04-29 00:01:30 +03:00
Elrond
5ae0cbaa55 No lazy_* needed here; Add ReallyLazyProxy.__repr__.
One should use lazy_* only if you have a good reason.

This one found by our unit tests!

For example add_message adds the message to the session,
the session needs to be serialized (with json) and well,
LazyProxy is not serializable.

To aid in debugging, gave our ReallyLazyProxy a __repr__.
2013-04-25 14:31:29 +02:00
Christopher Allan Webber
c47be4b8ba Adding ReallyLazyProxy, a proxy that does what we expect :) 2013-04-24 16:40:30 -05:00
Elrond
50cb512220 Create set_thread_locale and use it.
Setting up a new template env should not directly touch the
translation tools, but go through a function in
translations.py.
2013-04-24 22:30:50 +02:00
Jessica T
f1c3807db7 Adds the timesince ability which fixes #394 2013-04-11 22:37:48 +01:00
Elrond
04453ccf42 Better Py3 compat: d.has_key(k) -> k in d
py3 does not have dict.has_key any more. You have to use
"key in dict" instead. As that works in python2 as well,
let's use that.

Also some small bits of pep8.
2013-01-30 15:03:04 +01:00
Sebastian Spaeth
c843de8a57 Add example to the lazy gettext version to make clear when it's appropriate
I needed an example to really get when lazy_gettext would be good...
2012-12-14 15:16:49 +01:00
Sebastian Spaeth
c39b9afc83 Fallback to "en_US" if browser does not send preferred languages
E.g. in our test suite we don't send an "accepted languages" header, which
caused the language matching to fail. So we need to explicitely fallback to
en_US, in case request.accepted_languages is None. This fixes the tests and
all cases where user browsers don't send preferred languages.

This also fixes issue #562, the AVAILABLE_LOCALES are already case-normalized
and we don't need to fudge the preferred language through the lower_upper_locale
thing for each and every request.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-04 09:44:07 +01:00
Sebastian Spaeth
826919c97c en_US is always available
We were using "en" as fallback only when no preferred language matched.
This is obviously bad. Always insert en_US as available locale, so we
can match it with the accept_languages.

Don't set available_locales as mg_global, per discussion with paroneaya,
make it a global var in translate.py

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-02 02:46:50 +01:00
Christopher Allan Webber
e4e7fbeeaa Fixing bug where not all conditions returned a language in get_locale_from_request()
Just had to change the indentation level of the last commit.
2012-12-01 19:36:52 -06:00
Sebastian Spaeth
d53ca5e506 Fall back to "en" if we don't find matching translations
In case of no matching translations, target_lang was "None" which
blew up things. Fall back to "en" in case we don't find a
corresponding translation.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-02 01:39:53 +01:00
Sebastian Spaeth
6ef75af50e Honor user's browser language (#558)
Previously we would attempt to satisfy the user's first language
preference, immediately falling back to english if that was not
possible. Now, we will get the best match of the user's preferred
languages.

This requires storing the available locales on app startup, so we
have mg_globals.available_locales ready to compare them against the
list of preferred user languages.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-02 00:29:30 +01:00
Sebastian Spaeth
7b9f9d1edb Fix i18n in our browser
We only ever served english pages since the switch to werkzeug's requests.
Fix this by actually checking the accepted languages that our web browser
sends and using that or falling back to english.

This is not optimal, imaging our browser sends "klingon, de" as accepted
languages and we happen to not have a klingon translation ready (a deficiency
that should be corrected immediately anyway!!). We would then fall back
to english rather than sending the sensible and pleasant German language
which the user would understand. This will require more backend work though.

Removing the gettext.find() in mg_globals.py. It looked in the wrong directory
anyway (mediagoblin/translations) and as that does not exist, had always returned
None without anyone noticing.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-01 23:40:10 +01:00
Joar Wandborg
1ec7ff2adb Fixed 404 page under werkzeug.routing
- Removed ?lang=<langcode> feature due to incompatibility with werkzeug
  routes in the current state of the architecture.
2012-10-14 20:05:44 +02:00
Joar Wandborg
111a609df5 Replaced all request.POST with request.form, ...
- Fixed error handling in OAuth plugin
- Changed request.POST file fields to request.files
2012-09-29 21:08:20 +02:00
Joar Wandborg
f1d06e1d6c Switch from webob.Request to werkzeug.wrappers.Request 2012-09-29 21:08:20 +02:00
Aleksej
9d3e56d500 replaced os.path.split()[0] with os.path.dirname() and corrected a couple of comments 2012-08-13 16:07:58 +04:00
Jakob Kramer
c80982c7a0 make mg_globals.translations thread-safe
I added mg_globals.thread_scope (an instance of threading.local)
and made `translations' an attribute of it.
2012-07-18 19:25:53 +02:00
Christopher Allan Webber
cf29e8a824 It's 2012 all up in here 2012-02-02 09:44:13 -06:00
Christopher Allan Webber
4715091970 Support for older webobs and newer webobs both in accept language mess :) 2011-10-15 16:57:45 -05:00
Christopher Allan Webber
ed59426466 Fixes issue662, MediaGoblin was broken by recent WebOb release.
From WebOb release notes:

  "Accept.best_matches() is gone; use list(request.accept) or
  request.accept.best_match(..) instead (applies to all Accept-*
  headers) or similar with request.accept_language."

... seems that's what borked it...
2011-10-15 16:46:04 -05:00
Aaron Williamson
ae3bc7fabf Moved common, translation, template, and url code out of util.py and into tools/[file].py 2011-10-01 09:31:42 -04:00