diff --git a/edx_notifications/base_data.py b/edx_notifications/base_data.py index f27f9d46..777e8eef 100644 --- a/edx_notifications/base_data.py +++ b/edx_notifications/base_data.py @@ -7,6 +7,7 @@ import dateutil.parser import copy from datetime import datetime, timedelta +from django.utils.translation import ugettext_lazy from freezegun.api import FakeDatetime @@ -59,6 +60,8 @@ def __init__(self, *args, **kwargs): # pylint: disable=unused-argument Initializer which takes in the type this field should be set it is set """ + # from django.utils.functional import __proxy__ + # self._expected_types.append(__proxy__) if not self._expected_types: raise TypeError( @@ -99,6 +102,7 @@ def __set__(self, data_object, value): value_type = type(value) if value and value_type not in self._expected_types: + raise TypeError( ( "Field expected type of '{expected}' got '{got}'" @@ -129,6 +133,14 @@ class StringField(TypedField): _expected_types = [unicode, str] +class LazyField(TypedField): + """ + Specialized subclass of TypedField(unicode) as a convienence for Translations support + """ + + _expected_types = [unicode, str, type(ugettext_lazy())] + + class IntegerField(TypedField): """ Specialized subclass of TypedField(int) as a convienence diff --git a/edx_notifications/const.py b/edx_notifications/const.py index 8a549991..22843fca 100644 --- a/edx_notifications/const.py +++ b/edx_notifications/const.py @@ -3,6 +3,7 @@ """ from django.conf import settings +from django.utils.translation import ugettext_lazy as _ NOTIFICATION_PRIORITY_NONE = 0 NOTIFICATION_PRIORITY_LOW = 1 @@ -99,27 +100,27 @@ 'groups': { 'announcements': { 'name': 'announcements', - 'display_name': 'Announcements', + 'display_name': _('Announcements'), 'group_order': 1 }, 'group_work': { 'name': 'group_work', - 'display_name': 'Group Work', + 'display_name': _('Group Work'), 'group_order': 2 }, 'leaderboards': { 'name': 'leaderboards', - 'display_name': 'Leaderboards', + 'display_name': _('Leaderboards'), 'group_order': 3 }, 'discussions': { 'name': 'discussions', - 'display_name': 'Discussion', + 'display_name': _('Discussion'), 'group_order': 4 }, '_default': { 'name': '_default', - 'display_name': 'Other', + 'display_name': _('Other'), 'group_order': 5 }, }, diff --git a/edx_notifications/data.py b/edx_notifications/data.py index 7bab9851..be712a35 100644 --- a/edx_notifications/data.py +++ b/edx_notifications/data.py @@ -18,7 +18,7 @@ RelatedObjectField, BaseDataObject, BooleanField, -) + LazyField) class NotificationChannel(BaseDataObject): @@ -42,7 +42,7 @@ class NotificationType(BaseDataObject): """ # the name (including namespace) of the notification, e.g. open-edx.lms.forums.reply-to-post - name = StringField() + name = LazyField() # default delivery channel for this type # None = no default @@ -50,7 +50,7 @@ class NotificationType(BaseDataObject): # renderer class - as a string - that will handle the rendering of # this type - renderer = StringField() + renderer = LazyField() # any context information to pass into the renderer renderer_context = DictField() @@ -405,13 +405,13 @@ class NotificationPreference(BaseDataObject): """ # the internal name of the channel - name = StringField() + name = LazyField() # display_name for notification preference - display_name = StringField() + display_name = LazyField() # display description for notification preference - display_description = StringField() + display_description = LazyField() # default_value for notification preference default_value = StringField() @@ -428,7 +428,7 @@ class UserNotificationPreferences(BaseDataObject): # instance of NotificationPreference, None = unloaded preference = RelatedObjectField(NotificationPreference) - value = StringField() + value = LazyField() # timestamps created = DateTimeField() diff --git a/edx_notifications/locale/ar/LC_MESSAGES/django.mo b/edx_notifications/locale/ar/LC_MESSAGES/django.mo new file mode 100644 index 00000000..216c79ff Binary files /dev/null and b/edx_notifications/locale/ar/LC_MESSAGES/django.mo differ diff --git a/edx_notifications/locale/ar/LC_MESSAGES/django.po b/edx_notifications/locale/ar/LC_MESSAGES/django.po new file mode 100644 index 00000000..8bb9b94c --- /dev/null +++ b/edx_notifications/locale/ar/LC_MESSAGES/django.po @@ -0,0 +1,70 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-11-29 17:12+0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " +"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n" + +#: const.py:103 +msgid "Announcements" +msgstr "إعلانات" + +#: const.py:108 +msgid "Group Work" +msgstr "العمل الجماعي" + +#: const.py:113 +msgid "Leaderboards" +msgstr "لوحات المتسابقين" + +#: const.py:118 +msgid "Discussion" +msgstr "النقاش" + +#: const.py:123 +msgid "Other" +msgstr "أخرى" + +#: digests.py:200 +msgid "Receive daily email" +msgstr "استلام بريد إلكتروني يوميًا" + +#: digests.py:201 +msgid "" +"This setting will cause a daily digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"هذا الإعداد سيؤدي لإرسال ملخص يومي بجميع الإشعارات إلى عنوان بريدك " +"الإلكتروني المسجل" + +#: digests.py:210 +msgid "Receive weekly email" +msgstr "استلام بريد إلكتروني أسبوعيًا" + +#: digests.py:211 +msgid "" +"This setting will cause a weekly digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"هذا الإعداد سيؤدي لإرسال ملخص أسبوعي بجميع الإشعارات إلى عنوان بريدك " +"الإلكتروني المسجل" + +#: stores/sql/models.py:145 +#, python-brace-format +#| msgid "Announcement on {annoucement_date}" +msgid "Announcement on {annoucement_date}" +msgstr "{annoucement_date} الإعلان على" \ No newline at end of file diff --git a/edx_notifications/locale/de/LC_MESSAGES/django.mo b/edx_notifications/locale/de/LC_MESSAGES/django.mo new file mode 100644 index 00000000..30c213d6 Binary files /dev/null and b/edx_notifications/locale/de/LC_MESSAGES/django.mo differ diff --git a/edx_notifications/locale/de/LC_MESSAGES/django.po b/edx_notifications/locale/de/LC_MESSAGES/django.po new file mode 100644 index 00000000..51933eef --- /dev/null +++ b/edx_notifications/locale/de/LC_MESSAGES/django.po @@ -0,0 +1,68 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-11-29 17:12+0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: const.py:103 +msgid "Announcements" +msgstr "Ankündigungen" + +#: const.py:108 +msgid "Group Work" +msgstr "Gruppenarbeit" + +#: const.py:113 +msgid "Leaderboards" +msgstr "Ranglisten" + +#: const.py:118 +msgid "Discussion" +msgstr "Diskussionen" + +#: const.py:123 +msgid "Other" +msgstr "" + +#: digests.py:200 +msgid "Receive daily email" +msgstr "Tägliche E-Mail erhalten" + +#: digests.py:201 +msgid "" +"This setting will cause a daily digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"Bei dieser Einstellung wird eine tägliche Zusammenfassung aller Nachrichten " +"an Ihre eingetragene E-Mail Adresse geschickt." + +#: digests.py:210 +msgid "Receive weekly email" +msgstr "Wöchentliche E-Mail erhalten" + +#: digests.py:211 +msgid "" +"This setting will cause a weekly digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"Bei dieser Einstellung wird eine wöchentliche Zusammenfassung " +"allerNachrichten an Ihre eingetragene E-Mail Adresse geschickt." + +#: stores/sql/models.py:145 +#, python-brace-format +msgid "Announcement on {annoucement_date}" +msgstr "Ankündigung am {annoucement_date}" diff --git a/edx_notifications/locale/en/LC_MESSAGES/django.mo b/edx_notifications/locale/en/LC_MESSAGES/django.mo new file mode 100644 index 00000000..88b2449a Binary files /dev/null and b/edx_notifications/locale/en/LC_MESSAGES/django.mo differ diff --git a/edx_notifications/locale/en/LC_MESSAGES/django.po b/edx_notifications/locale/en/LC_MESSAGES/django.po new file mode 100644 index 00000000..ce599eb0 --- /dev/null +++ b/edx_notifications/locale/en/LC_MESSAGES/django.po @@ -0,0 +1,67 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-11-29 17:12+0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: const.py:103 +msgid "Announcements" +msgstr "" + +#: const.py:108 +msgid "Group Work" +msgstr "" + +#: const.py:113 +msgid "Leaderboards" +msgstr "" + +#: const.py:118 +msgid "Discussion" +msgstr "" + +#: const.py:123 +msgid "Other" +msgstr "" + +#: const.py:167 +msgid "Announcement" +msgstr "" + +#: digests.py:200 +msgid "Receive daily email" +msgstr "" + +#: digests.py:201 +msgid "" +"This setting will cause a daily digest of all notifications to be sent to " +"your registered email address" +msgstr "" + +#: digests.py:210 +msgid "Receive weekly email" +msgstr "" + +#: digests.py:211 +msgid "" +"This setting will cause a weekly digest of all notifications to be sent to " +"your registered email address" +msgstr "" + +#: stores/sql/models.py:145 +#, python-brace-format +msgid "Announcement on {annoucement_date}" +msgstr "" diff --git a/edx_notifications/locale/es/LC_MESSAGES/django.mo b/edx_notifications/locale/es/LC_MESSAGES/django.mo new file mode 100644 index 00000000..b10a2f4c Binary files /dev/null and b/edx_notifications/locale/es/LC_MESSAGES/django.mo differ diff --git a/edx_notifications/locale/es/LC_MESSAGES/django.po b/edx_notifications/locale/es/LC_MESSAGES/django.po new file mode 100644 index 00000000..d2ddd52b --- /dev/null +++ b/edx_notifications/locale/es/LC_MESSAGES/django.po @@ -0,0 +1,68 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-11-29 17:12+0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: const.py:103 +msgid "Announcements" +msgstr "Anuncios" + +#: const.py:108 +msgid "Group Work" +msgstr "Trabajo en grupo" + +#: const.py:113 +msgid "Leaderboards" +msgstr "Tableros de calificaciones" + +#: const.py:118 +msgid "Discussion" +msgstr "Debates" + +#: const.py:123 +msgid "Other" +msgstr "" + +#: digests.py:200 +msgid "Receive daily email" +msgstr "Recibir a diario por correo electrónico" + +#: digests.py:201 +msgid "" +"This setting will cause a daily digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"Esta configuración le permite seleccionar que todas las notificaciones se " +"envíen a diario a la dirección de correo electrónico registrada." + +#: digests.py:210 +msgid "Receive weekly email" +msgstr "Recibir una vez semana por correo electrónico" + +#: digests.py:211 +msgid "" +"This setting will cause a weekly digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"Esta configuración le permite seleccionar que todas las notificacionesse " +"envíen una vez por semana a la dirección de correo electrónico registrada." + +#: stores/sql/models.py:145 +#, python-brace-format +msgid "Announcement on {annoucement_date}" +msgstr "anuncio el {annoucement_date}" diff --git a/edx_notifications/locale/fr/LC_MESSAGES/django.mo b/edx_notifications/locale/fr/LC_MESSAGES/django.mo new file mode 100644 index 00000000..0f07a016 Binary files /dev/null and b/edx_notifications/locale/fr/LC_MESSAGES/django.mo differ diff --git a/edx_notifications/locale/fr/LC_MESSAGES/django.po b/edx_notifications/locale/fr/LC_MESSAGES/django.po new file mode 100644 index 00000000..ab8f0506 --- /dev/null +++ b/edx_notifications/locale/fr/LC_MESSAGES/django.po @@ -0,0 +1,68 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-11-29 17:12+0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: const.py:103 +msgid "Announcements" +msgstr "Annonces" + +#: const.py:108 +msgid "Group Work" +msgstr "Travail de groupe" + +#: const.py:113 +msgid "Leaderboards" +msgstr "Classements" + +#: const.py:118 +msgid "Discussion" +msgstr "Discussions" + +#: const.py:123 +msgid "Other" +msgstr "" + +#: digests.py:200 +msgid "Receive daily email" +msgstr "Recevoir un courriel quotidien" + +#: digests.py:201 +msgid "" +"This setting will cause a daily digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"Ce paramètre résultera en l'envoi d'un résumé quotidien de toutes les " +"notifications à votre adresse de courriel enregistré" + +#: digests.py:210 +msgid "Receive weekly email" +msgstr "Recevoir un courriel hebdomadaire" + +#: digests.py:211 +msgid "" +"This setting will cause a weekly digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"Ce paramètre résultera en l'envoi d'un résumé hebdomadaire de toutes les " +"notifications à votre adresse de courriel enregistrée" + +#: stores/sql/models.py:145 +#, python-brace-format +msgid "Announcement on {annoucement_date}" +msgstr "annonce le {annoucement_date}" diff --git a/edx_notifications/locale/ja/LC_MESSAGES/django.mo b/edx_notifications/locale/ja/LC_MESSAGES/django.mo new file mode 100644 index 00000000..9aa4d553 Binary files /dev/null and b/edx_notifications/locale/ja/LC_MESSAGES/django.mo differ diff --git a/edx_notifications/locale/ja/LC_MESSAGES/django.po b/edx_notifications/locale/ja/LC_MESSAGES/django.po new file mode 100644 index 00000000..bf679737 --- /dev/null +++ b/edx_notifications/locale/ja/LC_MESSAGES/django.po @@ -0,0 +1,68 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-11-29 17:12+0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#: const.py:103 +msgid "Announcements" +msgstr "お知らせ" + +#: const.py:108 +msgid "Group Work" +msgstr "グループワーク" + +#: const.py:113 +msgid "Leaderboards" +msgstr "スコアボード" + +#: const.py:118 +msgid "Discussion" +msgstr "検討事項" + +#: const.py:123 +msgid "Other" +msgstr "" + +#: digests.py:200 +msgid "Receive daily email" +msgstr "デイリーメールを受信する" + +#: digests.py:201 +msgid "" +"This setting will cause a daily digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"この設定により、すべての通知の日々のダイジェスト版が、あなたの登録メールアド" +"レスに送信されます。" + +#: digests.py:210 +msgid "Receive weekly email" +msgstr "ウィークリーメールを受信する" + +#: digests.py:211 +msgid "" +"This setting will cause a weekly digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"この設定により、すべての通知の週間ダイジェスト版が、あなたの登録メールアドレ" +"スに送信されます。" + +#: stores/sql/models.py:145 +#, python-brace-format +msgid "Announcement on {annoucement_date}" +msgstr "についての発表 {annoucement_date}" diff --git a/edx_notifications/locale/nl/LC_MESSAGES/django.mo b/edx_notifications/locale/nl/LC_MESSAGES/django.mo new file mode 100644 index 00000000..135c4149 Binary files /dev/null and b/edx_notifications/locale/nl/LC_MESSAGES/django.mo differ diff --git a/edx_notifications/locale/nl/LC_MESSAGES/django.po b/edx_notifications/locale/nl/LC_MESSAGES/django.po new file mode 100644 index 00000000..21cdd599 --- /dev/null +++ b/edx_notifications/locale/nl/LC_MESSAGES/django.po @@ -0,0 +1,68 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-11-29 17:12+0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: const.py:103 +msgid "Announcements" +msgstr "" + +#: const.py:108 +msgid "Group Work" +msgstr "" + +#: const.py:113 +msgid "Leaderboards" +msgstr "" + +#: const.py:118 +msgid "Discussion" +msgstr "" + +#: const.py:123 +msgid "Other" +msgstr "" + +#: const.py:167 +msgid "Announcement" +msgstr "" + +#: digests.py:200 +msgid "Receive daily email" +msgstr "" + +#: digests.py:201 +msgid "" +"This setting will cause a daily digest of all notifications to be sent to " +"your registered email address" +msgstr "" + +#: digests.py:210 +msgid "Receive weekly email" +msgstr "" + +#: digests.py:211 +msgid "" +"This setting will cause a weekly digest of all notifications to be sent to " +"your registered email address" +msgstr "" + +#: stores/sql/models.py:145 +#, python-brace-format +msgid "Announcement on {annoucement_date}" +msgstr "" diff --git a/edx_notifications/locale/pt/LC_MESSAGES/django.mo b/edx_notifications/locale/pt/LC_MESSAGES/django.mo new file mode 100644 index 00000000..d95e85ff Binary files /dev/null and b/edx_notifications/locale/pt/LC_MESSAGES/django.mo differ diff --git a/edx_notifications/locale/pt/LC_MESSAGES/django.po b/edx_notifications/locale/pt/LC_MESSAGES/django.po new file mode 100644 index 00000000..c482805c --- /dev/null +++ b/edx_notifications/locale/pt/LC_MESSAGES/django.po @@ -0,0 +1,68 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-11-29 17:12+0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: const.py:103 +msgid "Announcements" +msgstr "Avisos" + +#: const.py:108 +msgid "Group Work" +msgstr "Trabalho em equipe" + +#: const.py:113 +msgid "Leaderboards" +msgstr "Classificações" + +#: const.py:118 +msgid "Discussion" +msgstr "Discussões" + +#: const.py:123 +msgid "Other" +msgstr "" + +#: digests.py:200 +msgid "Receive daily email" +msgstr "Receber e-mail diário" + +#: digests.py:201 +msgid "" +"This setting will cause a daily digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"Esta configuração fará com que um resumo diário de todas asnotificações seja " +"enviado para seu endereço de e-mail registrado" + +#: digests.py:210 +msgid "Receive weekly email" +msgstr "Receber e-mail semanal" + +#: digests.py:211 +msgid "" +"This setting will cause a weekly digest of all notifications to be sent to " +"your registered email address" +msgstr "" +"Esta configuração fará com que um resumo semanal de todasas notificações " +"seja enviado para o seu endereço de e-mail cadastrado" + +#: stores/sql/models.py:145 +#, python-brace-format +msgid "Announcement on {annoucement_date}" +msgstr "anúncio em {annoucement_date}" diff --git a/edx_notifications/locale/zh_CN/LC_MESSAGES/django.mo b/edx_notifications/locale/zh_CN/LC_MESSAGES/django.mo new file mode 100644 index 00000000..7d948e0a Binary files /dev/null and b/edx_notifications/locale/zh_CN/LC_MESSAGES/django.mo differ diff --git a/edx_notifications/locale/zh_CN/LC_MESSAGES/django.po b/edx_notifications/locale/zh_CN/LC_MESSAGES/django.po new file mode 100644 index 00000000..153730e0 --- /dev/null +++ b/edx_notifications/locale/zh_CN/LC_MESSAGES/django.po @@ -0,0 +1,63 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-11-29 17:12+0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: const.py:103 +msgid "Announcements" +msgstr "公告" + +#: const.py:108 +msgid "Group Work" +msgstr "群组工作" + +#: const.py:113 +msgid "Leaderboards" +msgstr "排行榜" + +#: const.py:118 +msgid "Discussion" +msgstr "讨论" + +#: const.py:123 +msgid "Other" +msgstr "" + +#: digests.py:200 +msgid "Receive daily email" +msgstr "接收每日电子邮件" + +#: digests.py:201 +msgid "" +"This setting will cause a daily digest of all notifications to be sent to " +"your registered email address" +msgstr "此设置将使所有通知的每日摘要都发送到您注册的电子邮件地址" + +#: digests.py:210 +msgid "Receive weekly email" +msgstr "接收每周电子邮件" + +#: digests.py:211 +msgid "" +"This setting will cause a weekly digest of all notifications to be sent to " +"your registered email address" +msgstr "此设置将使所有通知的每周摘要都发送到您注册的电子邮件地址" + +#: stores/sql/models.py:145 +#, python-brace-format +msgid "Announcement on {annoucement_date}" +msgstr "公告 {annoucement_date}" diff --git a/edx_notifications/stores/sql/models.py b/edx_notifications/stores/sql/models.py index 3e86c528..8a1f027d 100644 --- a/edx_notifications/stores/sql/models.py +++ b/edx_notifications/stores/sql/models.py @@ -19,6 +19,7 @@ from edx_notifications import const from django.db.models.signals import pre_delete from django.dispatch import receiver +from django.utils.translation import get_language,ugettext_lazy as _ class SQLNotificationType(models.Model): @@ -48,7 +49,7 @@ def to_data_object(self, options=None): # pylint: disable=unused-argument """ return NotificationType( - name=self.name, + name=_(self.name), renderer=self.renderer, renderer_context=DictField.from_json(self.renderer_context) ) @@ -123,7 +124,7 @@ def to_data_object(self, options=None): # pylint: disable=unused-argument deliver_no_earlier_than=self.deliver_no_earlier_than, expires_at=self.expires_at, expires_secs_after_read=self.expires_secs_after_read, - payload=DictField.from_json(self.payload), # special case, dict<-->JSON string + payload=self.translate_payload_title(DictField.from_json(self.payload)), # special case, dict<-->JSON string created=self.created, resolve_links=DictField.from_json(self.resolve_links), # special case, dict<-->JSON string object_id=self.object_id @@ -131,6 +132,13 @@ def to_data_object(self, options=None): # pylint: disable=unused-argument return msg + def translate_payload_title(self, payload): + if payload and 'notification_type' in payload and payload['notification_type'] == "courseannouncement": + announcement_date = payload['announcement_date'] + title = _('Announcement on {annoucement_date}').format(annoucement_date=announcement_date) + payload['title'] = title + return payload + @classmethod def from_data_object(cls, msg): """ @@ -285,9 +293,9 @@ def to_data_object(self, options=None): # pylint: disable=unused-argument """ return NotificationPreference( - name=self.name, - display_name=self.display_name, - display_description=self.display_description, + name=_(self.name), + display_name=_(self.display_name), + display_description=_(self.display_description), default_value=self.default_value ) @@ -340,7 +348,7 @@ def to_data_object(self, options=None): # pylint: disable=unused-argument return UserNotificationPreferences( user_id=self.user_id, preference=self.preference.to_data_object(), # pylint: disable=no-member, - value=self.value + value=_(self.value) ) @classmethod diff --git a/edx_notifications/stores/sql/tests/test_store_provider.py b/edx_notifications/stores/sql/tests/test_store_provider.py index 84b13b6a..7fdefed8 100644 --- a/edx_notifications/stores/sql/tests/test_store_provider.py +++ b/edx_notifications/stores/sql/tests/test_store_provider.py @@ -22,6 +22,8 @@ BulkOperationTooLarge ) from edx_notifications import const +from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext as getext class TestSQLStoreProvider(TestCase): @@ -119,8 +121,9 @@ def _save_user_notification_preference(self, number_of_queries, preference_name, """ notification_preference = self._save_notification_preference( number_of_queries=number_of_queries, - name=preference_name, - display_name='Test Preference' + name=_(preference_name), + display_name=getext('Test Preference'), + display_description=getext('this is a Test Preference') ) test_user_notification_preference = UserNotificationPreferences( user_id=user_id, @@ -1033,16 +1036,16 @@ def test_get_all_notification_preferences(self): """ test_notification_preference = self._save_notification_preference( number_of_queries=3, - name='test_notification_preference,', - display_name="Test Preference", - display_description="This is the test preference" + name=getext("test_notification_preference,"), + display_name=getext("Test Preference"), + display_description=getext("This is the test preference") ) test2_notification_preference = self._save_notification_preference( number_of_queries=3, - name='notification_preference2', - display_name="Test Preference 2", - display_description="This is the second test preference" + name=getext('notification_preference2'), + display_name=getext("Test Preference 2"), + display_description=getext("This is the second test preference") ) with self.assertNumQueries(1): diff --git a/requirements.txt b/requirements.txt index 746b1a5d..25f6df44 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ # Django/Framework Packages -django==1.8.18 +django==1.8.19 django-model-utils==2.3.1 python-dateutil==2.1 requests==2.9.1 pylru==1.0.6 -djangorestframework==3.2.3 +git+https://github.com/edx/django-rest-framework.git@3c72cb5ee5baebc4328947371195eae2077197b0#egg=djangorestframework==3.2.3 pytz==2016.7 PyContracts==1.7.1 underscore.py==0.1.6 diff --git a/settings.py b/settings.py index 0aa8f0a5..0e05de2f 100644 --- a/settings.py +++ b/settings.py @@ -1,8 +1,8 @@ +#!/usr/bin/bash +# -*- coding: utf-8 -* """ Django settings file for local development purposes """ -import sys - # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os @@ -14,7 +14,7 @@ TEST_ROOT = "tests" TRANSACTIONS_MANAGED = {} USE_TZ = True -TIME_ZONE = {} +TIME_ZONE = 'UTC' SECRET_KEY='SHHHHHH' DATABASES = { @@ -24,6 +24,10 @@ }, } +USE_I18N = True +USE_L10N = True + + INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', @@ -50,19 +54,45 @@ } }) + +LANGUAGE_CODE = "en" +LANGUAGE_COOKIE_NAME = "openedx-language-preference" +LANGUAGES = ( + ('en', u'English '), + ('ar', u'العربية'), # Arabic + ('es', u'Español'), + ('nl', u'Dutch '), + ('pt', u'Português'), + ('zh-cn', u'中文(简体)'), + ('fr', u'Français'), + ('jp', u'日本人'), + ('de', u'Deutsche'), +) + +LOCALE_PATHS = [ + os.path.join(BASE_DIR, 'locale'), +] + MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', + ) ROOT_URLCONF = 'edx_notifications.server.urls' WSGI_APPLICATION = 'edx_notifications.server.wsgi.application' -TEMPLATE_DIRS = ['edx_notifications/server/web/templates'] + +TEMPLATES = [{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': ['edx_notifications/server/web/templates'] +}] NOTIFICATION_STORE_PROVIDER = { "class": "edx_notifications.stores.sql.store_provider.SQLNotificationStoreProvider", @@ -155,4 +185,4 @@ NOTIFICATION_BRANDED_DEFAULT_LOGO = 'edx_notifications/img/edx-openedx-logo-tag.png' # digest email css -NOTIFICATION_DIGEST_EMAIL_CSS = 'edx_notifications/css/email_digests.css' +NOTIFICATION_DIGEST_EMAIL_CSS = 'edx_notifications/css/email_digests.css' \ No newline at end of file diff --git a/setup.py b/setup.py index 291c5806..841e98b8 100755 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ def load_requirements(*requirements_paths): setup( name='edx-notifications', - version='0.6.3', + version='0.6.8', description='Notification subsystem for Open edX', long_description=open('README.md').read(), author='edX', diff --git a/testserver/bokchoy_settings.py b/testserver/bokchoy_settings.py index 7cf3eb42..4c954d4e 100644 --- a/testserver/bokchoy_settings.py +++ b/testserver/bokchoy_settings.py @@ -1,3 +1,5 @@ +#!/usr/bin/bash +# -*- coding: utf-8 -* """ Django settings for edx_notifications test project. For more information on this file, see @@ -37,12 +39,34 @@ 'django_nose', ) + +LANGUAGE_CODE = "en" +LANGUAGE_COOKIE_NAME = "openedx-language-preference" +LANGUAGES = ( + ('en', u'English '), + ('ar', u'العربية'), # Arabic + ('es', u'Español'), + ('nl', u'Dutch '), + ('pt', u'Português'), + ('zh-cn', u'中文(简体)'), + ('fr', u'Français'), + ('jp', u'日本人'), + ('de', u'Deutsche'), +) + +LOCALE_PATHS = [ + os.path.join(BASE_DIR, 'locale'), +] + MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', + ) REST_FRAMEWORK = {