Skip to content

localization of email headers, added the datetime format settings in …#934

Merged
tonioo merged 2 commits intomodoboa:masterfrom
christianwgd:master
Oct 8, 2016
Merged

localization of email headers, added the datetime format settings in …#934
tonioo merged 2 commits intomodoboa:masterfrom
christianwgd:master

Conversation

@christianwgd
Copy link
Copy Markdown
Contributor

…test_project settings.py with some docs

Localization of the email header fields by adding a template filter to lib_tags.py that translates the header labels "From", "To", "Date" and "Subject" and is used in the mailheaders template. Added the required translation strings to the locale po files.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Oct 6, 2016

Current coverage is 77.27% (diff: 50.00%)

Merging #934 into master will decrease coverage by 0.01%

@@             master       #934   diff @@
==========================================
  Files           131        131          
  Lines          7005       7009     +4   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           5414       5416     +2   
- Misses         1591       1593     +2   
  Partials          0          0          

Powered by Codecov. Last update 6421eff...0fd1faf

Comment thread test_project/test_project/settings.py Outdated

# emails of the last week
# en-us style
WEBMAIL_SHORT_DATETIME_FORMAT = "l, P"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know part of the code used by the webmail might not be at the right place but the settings related to the webmail should be move the webmail repository. You can take example on the amavis plugin: https://github.com/modoboa/modoboa-amavis/blob/master/modoboa_amavis/settings.py.

Comment thread test_project/test_project/settings.py Outdated
# en-us style
WEBMAIL_DATETIME_FORMAT = "N, j Y P"
# european style
# WEBMAIL_DATETIME_FORMAT = "d. N Y H:i"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Comment thread modoboa/lib/templatetags/lib_tags.py Outdated
names = {'From': _('From'), 'To': _('To'), 'Date': _('Date'), 'Subject': _('Subject')}
if names.has_key(headername):
return names[headername]
return headername
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify those 3 lines into 1 like this:

return names.get(headername, headername)

Comment thread modoboa/lib/templatetags/lib_tags.py Outdated
@register.filter(name='localize_header_name')
def localize_header_name(headername):
""" Localizes the header names """
names = {'From': _('From'), 'To': _('To'), 'Date': _('Date'), 'Subject': _('Subject')}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use " instead of ' for strings. I'm currently updating the code to be consistent but it's a long path...

@christianwgd
Copy link
Copy Markdown
Contributor Author

I put the settings into modoboa because i didn’t find one in modoboa-webmail. Thanks to your hint, i will create one. No problem with the string delimiters, i will change them.

Am 06.10.2016 um 15:08 schrieb Antoine Nguyen notifications@github.com:

@tonioo commented on this pull request.

In test_project/test_project/settings.py #934 (review):

@@ -106,6 +106,25 @@

USE_TZ = True

+# Webmail datetime formats according to
+# https://docs.djangoproject.com/en/1.10/ref/templates/builtins/
+# modoboa-webmail is able to show the datetime of emails
+# in two ways.
+# If none is provided, default is RFC 5322 formatted date.
+# For this, USE_L10N must be set to True!
+
+# emails of the last week
+# en-us style
+WEBMAIL_SHORT_DATETIME_FORMAT = "l, P"
I know part of the code used by the webmail might not be at the right place but the settings related to the webmail should be move the webmail repository. You can take example on the amavis plugin: https://github.com/modoboa/modoboa-amavis/blob/master/modoboa_amavis/settings.py https://github.com/modoboa/modoboa-amavis/blob/master/modoboa_amavis/settings.py.

In test_project/test_project/settings.py #934 (review):

+# modoboa-webmail is able to show the datetime of emails
+# in two ways.
+# If none is provided, default is RFC 5322 formatted date.
+# For this, USE_L10N must be set to True!
+
+# emails of the last week
+# en-us style
+WEBMAIL_SHORT_DATETIME_FORMAT = "l, P"
+# european style
+# WEBMAIL_SHORT_DATETIME_FORMAT = "l, H:i"
+
+# emails older than a week
+# en-us style
+WEBMAIL_DATETIME_FORMAT = "N, j Y P"
+# european style
+# WEBMAIL_DATETIME_FORMAT = "d. N Y H:i"
Same here.

In modoboa/lib/templatetags/lib_tags.py #934 (review):

@@ -94,3 +95,12 @@ def extra_static_content(caller, st_type, user):
"GetStaticContent", caller, st_type, user)
})
)
+
+
+@register.filter(name='localize_header_name')
+def localize_header_name(headername):

  • """ Localizes the header names """
  • names = {'From': _('From'), 'To': _('To'), 'Date': _('Date'), 'Subject': _('Subject')}
  • if names.has_key(headername):
  •    return names[headername]
    
  • return headername
    You can simplify those 3 lines into 1 like this:

return names.get(headername, headername)
In modoboa/lib/templatetags/lib_tags.py #934 (review):

@@ -94,3 +95,12 @@ def extra_static_content(caller, st_type, user):
"GetStaticContent", caller, st_type, user)
})
)
+
+
+@register.filter(name='localize_header_name')
+def localize_header_name(headername):

  • """ Localizes the header names """
  • names = {'From': _('From'), 'To': _('To'), 'Date': _('Date'), 'Subject': _('Subject')}
    Could you please use " instead of ' for strings. I'm currently updating the code to be consistent but it's a long path...


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #934 (review), or mute the thread https://github.com/notifications/unsubscribe-auth/AI2gbwf8-DAoeDCWzjgiRcd8Kuizn8hRks5qxPLngaJpZM4KP54l.

…ime formatting settings to new settings.py in webmail module.
@tonioo tonioo merged commit 0cc3d01 into modoboa:master Oct 8, 2016
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

Successfully merging this pull request may close these issues.

3 participants