Skip to content

Commit

Permalink
text_revision_history_page_date_format_for_tibetan
Browse files Browse the repository at this point in the history
  • Loading branch information
Lungsangg committed Feb 6, 2025
1 parent e7b7b6c commit 84ac0b4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
21 changes: 21 additions & 0 deletions reader/templatetags/custom_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django import template
from django.utils import timezone
from django.utils import translation
from sefaria.settings import DATE_FORMATS_REVISION_PAGE


register = template.Library()


@register.filter(name='custom_time_format')
def custom_time_format(value):

if not timezone.is_aware(value):
value = timezone.make_aware(value, timezone.get_current_timezone())


current_language = translation.get_language()
date_format_string = DATE_FORMATS_REVISION_PAGE.get(current_language, DATE_FORMATS_REVISION_PAGE['en'])

return value.strftime(date_format_string)

15 changes: 10 additions & 5 deletions sefaria/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@
('zh-hans', "Chinese"),
)

DATE_FORMATS = {
'en': 'N j, Y g:i A', # English: January 5, 2024 2:30 PM
'he': 'ཕྱི་ལོ་Y ཟླ་m ཚེས།j ཆུ་ཚོད།g', # Tibetan: ཕྱི་ལོ་2024 ཟླ་1 ཚེས་5 ཆུ་2 སྐར་30 སྔོན་PM
'ch': 'Y年 m月 j日 g:i A', # Chinese: 2024年1月5日 2:30 PM
'es': 'Y年 m月 j日 g:i A', # Spanish: 2024年1月5日 2:30 PM
DATE_FORMATS_REVISION_PAGE = {
'en': '%b %d, %Y', # English: Jan 05, 2024
'he': 'ཕྱི་ལོ་%Y ཟླ་%m ཚེས་%d', # Tibetan: ཕྱི་ལོ་2024 ཟླ་01 ཚེས་05
'ch': '%Y年%m月%d日', # Chinese: 2024年01月05日
}

DATE_FORMATS_REVISION_PAGE = {
'en': '%b %d, %Y', # English: Jan 05, 2024
'he': 'ཕྱི་ལོ་%Y ཟླ་%m ཚེས་%d', # Tibetan: ཕྱི་ལོ་༢༠༢༤ ཟླ་༠༡ ཚེས་༠༥
'ch': '%Y年%m月%d日', # Chinese: 2024年01月05日
}

SITE_ID = 1
Expand Down
5 changes: 3 additions & 2 deletions templates/elements/activity_feed.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% load i18n humanize sefaria_tags %}
{% load custom_filters %}

<ul id="activityList">
{% for event in activity %}
Expand Down Expand Up @@ -152,8 +153,8 @@


<div class="time">
{{ event.date|naturaltime }}
</div>
{{ event.date|custom_time_format }}
</div>
{% if event.summary %}
<a class="showAllActivity bottom" href="{{ event.history_url }}">{{ event.updates_count }} related &raquo;</a>
{% endif %}
Expand Down

0 comments on commit 84ac0b4

Please sign in to comment.