omab / python-social-auth

Social auth made simple
http://psa.matiasaguirre.net
BSD 3-Clause "New" or "Revised" License
2.83k stars 1.09k forks source link

Internationalization support #903

Closed dmzkrsk closed 7 years ago

dmzkrsk commented 8 years ago

I want to propose/discuss a possibility to add an i18n support for python-social-auth

Here's my patch with some notes

I just want to be sure, that I'm moving in right direction and there's a possibility for merge it with base project.

What I did:

I discovered a Strategy class and subclasses for each web framework, and decided to put internationalization stuff in this class. And these strategies are injected everywhere in library core

In base class I created a method ugettext, which, by default, just return a string, that was passed as only argument

In Django subclass (I have no much experience with other supported frameworks) I overrode it with Django's own ugettext function

I wrapped each message (all messages, that I could find) with backend.strategy.ugettext (or similar), so they are translated

For default django app I manually created django.po file with translations for Russian language

Other frameworks should provide their ugettext implementation and translation resources

And it all works as expected

dmzkrsk commented 8 years ago

Fixed tests

omab commented 7 years ago

I'll close this since the split to https://github.com/python-social-auth a solution that's framework independent seems like a more suitable solution.

Thanks!