[p2pu-dev] Espanol!
Vladimir Támara Patiño
vtamara at pasosdeJesus.org
Mon Apr 25 17:06:19 UTC 2011
On Mon, Apr 25, 2011 at 11:00:01AM -0400, Jessica Ledbetter wrote:
> I would think we'd store in the database and check there? Like setting
> whether or not we receive plain text emails or HTML?
I agree with you. In the interface, the preferred language should be
in the profile.
> Emails probably for now, yes. If someone has set the session to be Spanish
> and creates a sign-up page, the whole study group might be Spanish so maybe
> okay?
Yes OK.
> Though you're probably right to change that too.
> We can't flag a study
> group as Spanish (yet) so might be confusing to folks.
The title of the course will tell it. As it happens now in the drupal
interface. IMHO, the language of a participatn is enough for now.
By the way, several participants of the courses I have been running speak only
spanish, for they it would be better to see the whole interface in
spanish as well as receiving their emails in spanish --well now they are
trying hard to use the current drupal interface that is completely in english.
I hope to run the nexts courses in the new interface.
Right now, since new.p2pu.org is mainly used by english speakers, the
simplest solution in this moment is that I turn the interface to english, at
least, when I write to a group in english.
However I want to help with this for next release, so here are two ideas of
solution after adding preferred language of a user in the database and in the
interface.
1. We could implement a replacemente for the locale middleware (it's
short), however I prefer the next one
2. Since up to now we have seen requirements only with emails, we could
render the email message in the preferred language of the receiver,
here is a working example on the current sources:
diff --git a/apps/content/models.py b/apps/content/models.py
index 82c31b5..300a2ca 100644
--- a/apps/content/models.py
+++ b/apps/content/models.py
@@ -10,7 +10,8 @@ from django.template.defaultfilters import
truncatewords_html
from django.utils.safestring import mark_safe
from django.utils.timesince import timesince
from django.utils.translation import ugettext_lazy as _
-from django.utils.translation import ugettext
+from django.utils.translation import ugettext, get_language, activate,
deactivate
from django.db.models import Max
from django.template.loader import render_to_string
from django.contrib.sites.models import Site
@@ -182,20 +183,24 @@ def send_content_notification(instance,
is_comment):
project = instance.project
if not is_comment and not instance.listed:
return
- subject =
render_to_string("content/emails/content_update_subject.txt", {
- 'instance': instance,
- 'is_comment': is_comment,
- 'project': project,
- })
- body = render_to_string("content/emails/content_update.txt", {
- 'instance': instance,
- 'is_comment': is_comment,
- 'project': project,
- 'domain': Site.objects.get_current().domain,
- })
for participation in project.participants():
if participation.no_updates or instance.author ==
participation.user:
continue
+ lang = get_language();
+ # Here we should activate the receiver's language instead of en
+ activate('en');
+ subject =
render_to_string("content/emails/content_update_subject.txt",
+ 'instance': instance,
+ 'is_comment': is_comment,
+ 'project': project,
+ })
+ body = render_to_string("content/emails/content_update.txt", {
+ 'instance': instance,
+ 'is_comment': is_comment,
+ 'project': project,
+ 'domain': Site.objects.get_current().domain,
+ })
+ activate(lang);
SendUserEmail.apply_async((participation.user, subject, body))
if instance.author != project.created_by:
SendUserEmail.apply_async((project.created_by, subject, body))
If you agree I will be trying to add language of a user in the database,
in the profile and change where Lernanta send emails to render them in
the language of the receiver.
Best regards.
--
Dios, gracias por tu amor infinito.
--
Vladimir Támara Patiño.
http://vtamara.pasosdeJesus.org/
More information about the p2pu-dev
mailing list