1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-15 06:44:16 +00:00

Fixed time plural display and change tag name

This commit is contained in:
zhengxie
2012-11-05 17:27:57 +08:00
parent 64b0f182b4
commit 02f368a014
19 changed files with 96 additions and 56 deletions

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-10-27 14:27+0800\n" "POT-Creation-Date: 2012-11-05 17:20+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -50,19 +50,38 @@ msgstr ""
msgid "The two password fields didn't match." msgid "The two password fields didn't match."
msgstr "" msgstr ""
#: templatetags/seahub_tags.py:116 #: templatetags/seahub_tags.py:123
#, python-format #, python-format
msgid "%d days ago" msgid "%(days)d day ago"
msgstr "%d 天前" msgid_plural "%(days)d days ago"
msgstr[0] "%(days)d 天前"
#: templatetags/seahub_tags.py:118 #: templatetags/seahub_tags.py:130
msgid "%d hours ago" #, python-format
msgstr "%d 小时前" msgid "%(hours)d hour ago"
msgid_plural "%(hours)d hours ago"
msgstr[0] "%(hours)d 小时前"
#: templatetags/seahub_tags.py:120 #: templatetags/seahub_tags.py:137
msgid "%d minutes ago" #, python-format
msgstr "%d 分钟前" msgid "%(minutes)d minute ago"
msgid_plural "%(minutes)d minutes ago"
msgstr[0] "%(minutes)d 分钟前"
#: templatetags/seahub_tags.py:122 #: templatetags/seahub_tags.py:143
msgid "%d seconds ago" #, python-format
msgstr "%d 秒前" msgid "%(seconds)d second ago"
msgid_plural "%(seconds)d seconds ago"
msgstr[0] "%(seconds)d 秒前"
#: templatetags/seahub_tags.py:148
msgid "0 second ago"
msgstr "0 秒前"
#: templatetags/seahub_tags.py:214
msgid "Read-Write"
msgstr "可读写"
#: templatetags/seahub_tags.py:216
msgid "Read-Only"
msgstr "只读"

View File

@@ -8,6 +8,7 @@ from django.core.cache import cache
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils import translation from django.utils import translation
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
from profile.models import Profile from profile.models import Profile
from profile.settings import NICKNAME_CACHE_TIMEOUT, NICKNAME_CACHE_PREFIX from profile.settings import NICKNAME_CACHE_TIMEOUT, NICKNAME_CACHE_PREFIX
@@ -98,9 +99,9 @@ def translate_commit_desc(value):
return '\n'.join(ret_list) return '\n'.join(ret_list)
@register.filter(name='translate_commit_time') @register.filter(name='translate_seahub_time')
def translate_commit_time(value): def translate_seahub_time(value):
"""Translate commit time to human frindly format instead of timestamp""" """Translate seahub time to human friendly format instead of timestamp"""
if isinstance(value, int) or isinstance(value, long): # check whether value is int if isinstance(value, int) or isinstance(value, long): # check whether value is int
val = datetime.fromtimestamp(value) val = datetime.fromtimestamp(value)
@@ -118,24 +119,44 @@ def translate_commit_time(value):
if days * 24 * 60 * 60 + seconds > limit: if days * 24 * 60 * 60 + seconds > limit:
return val.strftime("%Y-%m-%d") return val.strftime("%Y-%m-%d")
elif days > 0: elif days > 0:
return _(u'%d days ago') % (days) ret = ungettext(
'%(days)d day ago',
'%(days)d days ago',
days ) % { 'days': days }
return ret
elif seconds > 60 * 60: elif seconds > 60 * 60:
return _(u'%d hours ago') % (seconds/3600) hours = seconds / 3600
ret = ungettext(
'%(hours)d hour ago',
'%(hours)d hours ago',
hours ) % { 'hours': hours }
return ret
elif seconds > 60: elif seconds > 60:
return _(u'%d minutes ago') % (seconds/60) minutes = seconds/60
ret = ungettext(
'%(minutes)d minute ago',
'%(minutes)d minutes ago',
minutes ) % { 'minutes': minutes }
return ret
elif seconds > 0:
ret = ungettext(
'%(seconds)d second ago',
'%(seconds)d seconds ago',
seconds ) % { 'seconds': seconds }
return ret
else: else:
return _(u'%d seconds ago') % (seconds) return _(u'0 second ago')
@register.filter(name='translate_remain_time') # @register.filter(name='translate_remain_time')
def translate_remain_time(value): # def translate_remain_time(value):
if value > 24 * 60 * 60: # if value > 24 * 60 * 60:
return u'%d' % (value/24/3600) # return u'%d 天' % (value/24/3600)
elif value > 60 * 60: # elif value > 60 * 60:
return u'%d 小时' % (value/3600) # return u'%d 小时' % (value/3600)
elif value > 60: # elif value > 60:
return u'%d 分钟' % (value/60) # return u'%d 分钟' % (value/60)
else: # else:
return u'%d' % (value) # return u'%d 秒' % (value)
@register.filter(name='email2nickname') @register.filter(name='email2nickname')
def email2nickname(value): def email2nickname(value):
@@ -190,8 +211,8 @@ def char2pinyin(value):
@register.filter(name='translate_permission') @register.filter(name='translate_permission')
def translate_permission(value): def translate_permission(value):
if value == 'rw': if value == 'rw':
return u'可读写' return _(u'Read-Write')
elif value == 'r': elif value == 'r':
return u'只可浏览' return _(u'Read-Only')
else: else:
return '' return ''

View File

@@ -89,7 +89,7 @@
<td>{{ repo.props.desc }}</td> <td>{{ repo.props.desc }}</td>
<td> <td>
{% if repo.latest_modify %} {% if repo.latest_modify %}
{{ repo.latest_modify|translate_commit_time }} {{ repo.latest_modify|translate_seahub_time }}
{% else %} {% else %}
—— —— —— ——
{% endif %} {% endif %}
@@ -130,7 +130,7 @@
</div> </div>
<div class="txt fright"> <div class="txt fright">
<div class="msg-hd"> <div class="msg-hd">
<span class="time">{{ msg.timestamp|translate_commit_time }}</span> <span class="time">{{ msg.timestamp|translate_seahub_time }}</span>
<a href="{{ SITE_ROOT }}profile/{{ msg.from_email }}/" title="{{ msg.from_email }}">{{ msg.from_email|email2nickname }}</a> <a href="{{ SITE_ROOT }}profile/{{ msg.from_email }}/" title="{{ msg.from_email }}">{{ msg.from_email|email2nickname }}</a>
</div> </div>
<div class="msg-bd"> <div class="msg-bd">

View File

@@ -12,7 +12,7 @@
</div> </div>
<div class="txt fright"> <div class="txt fright">
<div class="msg-hd"> <div class="msg-hd">
<span class="time">{{ msg.timestamp|translate_commit_time }}</span> <span class="time">{{ msg.timestamp|translate_seahub_time }}</span>
<a href="{% url 'user_profile' msg.from_email %}">{{ msg.from_email|email2nickname }}</a> <a href="{% url 'user_profile' msg.from_email %}">{{ msg.from_email|email2nickname }}</a>
<span class="group">{% trans "Group: " %}<a href="{% url 'group_info' msg.group_id %}">{{ msg.group_name }}</a></span> <span class="group">{% trans "Group: " %}<a href="{% url 'group_info' msg.group_id %}">{{ msg.group_name }}</a></span>
</div> </div>

View File

@@ -40,7 +40,7 @@
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.repo_id }}/">{{ repo.props.repo_name }}</a></td> <td><a href="{{ SITE_ROOT }}repo/{{ repo.props.repo_id }}/">{{ repo.props.repo_name }}</a></td>
<td>{{ repo.props.repo_desc }}</td> <td>{{ repo.props.repo_desc }}</td>
{% if repo.last_modified %} {% if repo.last_modified %}
<td>{{ repo.last_modified|translate_commit_time }}</td> <td>{{ repo.last_modified|translate_seahub_time }}</td>
{% else %} {% else %}
<td>--</td> <td>--</td>
{% endif %} {% endif %}

View File

@@ -7,7 +7,7 @@
<div class="txt fright"> <div class="txt fright">
<div class="comment-hd w100 ovhd"> <div class="comment-hd w100 ovhd">
<a href="{% url 'user_profile' comment.from_email %}" title="{{ comment.from_email }}" class="fleft">{{ comment.from_email|email2nickname }}</a> <a href="{% url 'user_profile' comment.from_email %}" title="{{ comment.from_email }}" class="fleft">{{ comment.from_email|email2nickname }}</a>
<span class="time fright">{{ comment.timestamp|translate_commit_time }}</span> <span class="time fright">{{ comment.timestamp|translate_seahub_time }}</span>
</div> </div>
<p class="comment-bd">{{ comment.message|seahub_urlize|find_at|linebreaksbr }}</p> <p class="comment-bd">{{ comment.message|seahub_urlize|find_at|linebreaksbr }}</p>
</div> </div>

View File

@@ -28,7 +28,7 @@
{% for commit in commits %} {% for commit in commits %}
<tr> <tr>
<td class="time"> <td class="time">
{{ commit.props.ctime|translate_commit_time }} {{ commit.props.ctime|translate_seahub_time }}
{% if commit.is_current_version %} {% if commit.is_current_version %}
{% trans '(current version)' %} {% trans '(current version)' %}
{% endif %} {% endif %}

View File

@@ -12,7 +12,7 @@
</div> </div>
<div class="txt fright"> <div class="txt fright">
<div class="msg-hd"> <div class="msg-hd">
<span class="time">{{ msg.timestamp|translate_commit_time }}</span> <span class="time">{{ msg.timestamp|translate_seahub_time }}</span>
<a href="{% url 'user_profile' msg.from_email %}">{{ msg.from_email|email2nickname }}</a> <a href="{% url 'user_profile' msg.from_email %}">{{ msg.from_email|email2nickname }}</a>
<span class="group">留言所属:<a href="{% url 'public_home' %}">公共页面</a></span> <span class="group">留言所属:<a href="{% url 'public_home' %}">公共页面</a></span>
</div> </div>

View File

@@ -36,7 +36,7 @@
<td><a href="{% url 'repo' repo.props.repo_id %}">{{ repo.props.repo_name }}</a></td> <td><a href="{% url 'repo' repo.props.repo_id %}">{{ repo.props.repo_name }}</a></td>
<td>{{ repo.props.repo_desc }}</td> <td>{{ repo.props.repo_desc }}</td>
{% if repo.props.last_modified %} {% if repo.props.last_modified %}
<td>{{ repo.props.last_modified|translate_commit_time }}</td> <td>{{ repo.props.last_modified|translate_seahub_time }}</td>
{% else %} {% else %}
<td>--</td> <td>--</td>
{% endif %} {% endif %}

View File

@@ -58,7 +58,7 @@
{% trans "Unknown"%} {% trans "Unknown"%}
{% endif %} {% endif %}
</span> </span>
<span class="time">{{ current_commit.props.ctime|translate_commit_time }}</span> <span class="time">{{ current_commit.props.ctime|translate_seahub_time }}</span>
</p> </p>
<div id="ls-ch" class="hide"></div><!--list modification details of a commit--> <div id="ls-ch" class="hide"></div><!--list modification details of a commit-->
</div> </div>

View File

@@ -20,7 +20,7 @@
{% for commit in commits %} {% for commit in commits %}
<tr> <tr>
<td class="time">{{ commit.ctime|translate_commit_time }}</td> <td class="time">{{ commit.ctime|translate_seahub_time }}</td>
<td> <td>
{% if commit.creator_name %} {% if commit.creator_name %}
{% if not commit.second_parent_id %} {% if not commit.second_parent_id %}

View File

@@ -20,7 +20,7 @@
{% trans "Unknown"%} {% trans "Unknown"%}
{% endif %} {% endif %}
</span> </span>
<span class="time">{{ current_commit.props.ctime|translate_commit_time }}</span> <span class="time">{{ current_commit.props.ctime|translate_seahub_time }}</span>
</p> </p>
</div> </div>

View File

@@ -41,7 +41,7 @@
<td class="icon-container"><img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory" %}" /></td> <td class="icon-container"><img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory" %}" /></td>
{% if show_recycle_root %} {% if show_recycle_root %}
<td><a href="{% url 'repo_recycle_view' repo.id %}?commit_id={{ dirent.commit_id }}&base={{ dirent.basedir|urlencode }}&p=/{{ dirent.obj_name|urlencode }}">{{ dirent.obj_name }}</a></td> <td><a href="{% url 'repo_recycle_view' repo.id %}?commit_id={{ dirent.commit_id }}&base={{ dirent.basedir|urlencode }}&p=/{{ dirent.obj_name|urlencode }}">{{ dirent.obj_name }}</a></td>
<td>{{ dirent.delete_time|translate_commit_time }}</td> <td>{{ dirent.delete_time|translate_seahub_time }}</td>
<td></td> <td></td>
<td><a class="op" href="{% url 'repo_revert_dir' repo.id %}?commit={{ dirent.commit_id }}&p={{ dirent.basedir|urlencode }}{{dirent.obj_name|urlencode}}">{% trans "Restore" %}</a></td> <td><a class="op" href="{% url 'repo_revert_dir' repo.id %}?commit={{ dirent.commit_id }}&p={{ dirent.basedir|urlencode }}{{dirent.obj_name|urlencode}}">{% trans "Restore" %}</a></td>
{% else %} {% else %}
@@ -58,7 +58,7 @@
<td class="icon-container"><img src="{{ MEDIA_URL }}img/file/{{ dirent.obj_name|file_icon_filter }}" alt="{% trans "File" %}" /></td> <td class="icon-container"><img src="{{ MEDIA_URL }}img/file/{{ dirent.obj_name|file_icon_filter }}" alt="{% trans "File" %}" /></td>
{% if show_recycle_root %} {% if show_recycle_root %}
<td><a class="op" href="{% url 'repo_view_file' repo.id %}?obj_id={{ dirent.obj_id }}&commit_id={{ dirent.commit_id }}&base={{ dirent.basedir|urlencode }}&p=/{{ dirent.obj_name|urlencode }}&from=recycle">{{ dirent.obj_name }}</a></td> <td><a class="op" href="{% url 'repo_view_file' repo.id %}?obj_id={{ dirent.obj_id }}&commit_id={{ dirent.commit_id }}&base={{ dirent.basedir|urlencode }}&p=/{{ dirent.obj_name|urlencode }}&from=recycle">{{ dirent.obj_name }}</a></td>
<td>{{ dirent.delete_time|translate_commit_time }}</td> <td>{{ dirent.delete_time|translate_seahub_time }}</td>
<td>{{ dirent.file_size|filesizeformat }}</td> <td>{{ dirent.file_size|filesizeformat }}</td>
<td><a class="op" href="{% url 'repo_revert_file' repo.id %}?commit={{ dirent.commit_id }}&p={{ dirent.basedir|urlencode }}{{dirent.obj_name|urlencode}}&from=recycle">{% trans "Restore" %}</a></td> <td><a class="op" href="{% url 'repo_revert_file' repo.id %}?commit={{ dirent.commit_id }}&p={{ dirent.basedir|urlencode }}{{dirent.obj_name|urlencode}}&from=recycle">{% trans "Restore" %}</a></td>
{% else %} {% else %}

View File

@@ -85,7 +85,7 @@
<div id="file-commit-info"> <div id="file-commit-info">
<div class="latest-commit ovhd"> <div class="latest-commit ovhd">
<p class="latest-commit-info fleft"> <p class="latest-commit-info fleft">
{% avatar latest_contributor 20 %} <a href="{% url 'user_profile' latest_contributor %}" class="name">{{ latest_contributor|email2nickname }}</a><span class="time">{{ last_modified|translate_commit_time}}</span><span>{% trans "updated this file"%}</span> {% avatar latest_contributor 20 %} <a href="{% url 'user_profile' latest_contributor %}" class="name">{{ latest_contributor|email2nickname }}</a><span class="time">{{ last_modified|translate_seahub_time}}</span><span>{% trans "updated this file"%}</span>
{% if filetype == 'Text' or filetype == 'Markdown' %} {% if filetype == 'Text' or filetype == 'Markdown' %}
{% if last_commit_id %} {% if last_commit_id %}
<span><a class="file-diff" href="{% url 'text_diff' repo.id %}?p={{path|urlencode}}&commit={{last_commit_id}}">{% trans "Detail"%}</a></span> <span><a class="file-diff" href="{% url 'text_diff' repo.id %}?p={{path|urlencode}}&commit={{last_commit_id}}">{% trans "Detail"%}</a></span>
@@ -176,7 +176,7 @@
<div class="txt fright"> <div class="txt fright">
<div class="comment-hd w100 ovhd"> <div class="comment-hd w100 ovhd">
<a href="{% url 'user_profile' comment.from_email %}" title="{{ comment.from_email }}" class="fleft">{{ comment.from_email|email2nickname }}</a> <a href="{% url 'user_profile' comment.from_email %}" title="{{ comment.from_email }}" class="fleft">{{ comment.from_email|email2nickname }}</a>
<span class="time fright">{{ comment.timestamp|translate_commit_time }}</span> <span class="time fright">{{ comment.timestamp|translate_seahub_time }}</span>
</div> </div>
<p class="comment-bd">{{ comment.message|seahub_urlize|find_at|linebreaksbr }}</p> <p class="comment-bd">{{ comment.message|seahub_urlize|find_at|linebreaksbr }}</p>
</div> </div>

View File

@@ -20,7 +20,7 @@
{% for commit in commits %} {% for commit in commits %}
<tr> <tr>
<td class="time">{{ commit.ctime|translate_commit_time }}</td> <td class="time">{{ commit.ctime|translate_seahub_time }}</td>
<td> <td>
{% if commit.creator_name %} {% if commit.creator_name %}
{% if not commit.second_parent_id %} {% if not commit.second_parent_id %}

View File

@@ -11,7 +11,7 @@
</div> </div>
<div class="txt fright"> <div class="txt fright">
<div class="event-hd"> <div class="event-hd">
<span class="time">{{ commit.ctime|translate_commit_time }}</span> <span class="time">{{ commit.ctime|translate_seahub_time }}</span>
<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a> <a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a>
</div> </div>
<p>{% trans 'Updated library' %} <a href="{{SITE_ROOT}}repo/{{repo.id}}">{{ repo.name }}</a></p> <p>{% trans 'Updated library' %} <a href="{{SITE_ROOT}}repo/{{repo.id}}">{{ repo.name }}</a></p>
@@ -37,7 +37,7 @@
</div> </div>
<div class="txt fright"> <div class="txt fright">
<div class="event-hd"> <div class="event-hd">
<span class="time">{{ ev.timestamp|translate_commit_time }}</span> <span class="time">{{ ev.timestamp|translate_seahub_time }}</span>
<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a> <a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a>
</div> </div>
<p>{% trans 'Created library' %} <a href="{{SITE_ROOT}}repo/{{repo_id}}">{{ repo_name }}</a></p> <p>{% trans 'Created library' %} <a href="{{SITE_ROOT}}repo/{{repo_id}}">{{ repo_name }}</a></p>
@@ -52,7 +52,7 @@
</div> </div>
<div class="txt fright"> <div class="txt fright">
<div class="event-hd"> <div class="event-hd">
<span class="time">{{ ev.timestamp|translate_commit_time }}</span> <span class="time">{{ ev.timestamp|translate_seahub_time }}</span>
<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a> <a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a>
</div> </div>
<p>{% trans 'Deleted library' %} {{ repo_name }}</p> <p>{% trans 'Deleted library' %} {{ repo_name }}</p>

View File

@@ -26,7 +26,7 @@
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/">{{ repo.props.name }}</a></td> <td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/">{{ repo.props.name }}</a></td>
<td>{{ repo.props.desc }}</td> <td>{{ repo.props.desc }}</td>
{% if repo.latest_modify %} {% if repo.latest_modify %}
<td>{{ repo.latest_modify|translate_commit_time }}</td> <td>{{ repo.latest_modify|translate_seahub_time }}</td>
{% else %} {% else %}
<td>--</td> <td>--</td>
{% endif %} {% endif %}
@@ -72,7 +72,7 @@
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.repo_id }}">{{ repo.props.repo_name }}</a></td> <td><a href="{{ SITE_ROOT }}repo/{{ repo.props.repo_id }}">{{ repo.props.repo_name }}</a></td>
<td>{{ repo.props.repo_desc }}</td> <td>{{ repo.props.repo_desc }}</td>
{% if repo.props.last_modified %} {% if repo.props.last_modified %}
<td>{{ repo.props.last_modified|translate_commit_time }}</td> <td>{{ repo.props.last_modified|translate_seahub_time }}</td>
{% else %} {% else %}
<td>--</td> <td>--</td>
{% endif %} {% endif %}
@@ -109,7 +109,7 @@
<a href="{% url 'repo_view_file' sfile.repo.id %}?p={{ sfile.path|urlencode }}">{{ sfile.formatted_path }}</a> <a href="{% url 'repo_view_file' sfile.repo.id %}?p={{ sfile.path|urlencode }}">{{ sfile.formatted_path }}</a>
</td> </td>
<td>{{ sfile.repo.name }}</td> <td>{{ sfile.repo.name }}</td>
<td>{{ sfile.last_modified|translate_commit_time }}</td> <td>{{ sfile.last_modified|translate_seahub_time }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View File

@@ -3,7 +3,7 @@
{% load url from future %} {% load url from future %}
{% block main_panel %} {% block main_panel %}
<h2 class="file-modification-hd"><span class="op-target">{{ u_filename }}</span> {% trans "modification details" %} <a href="{% url 'user_profile' current_commit.creator_name %}">{% avatar current_commit.creator_name 16 %}</a><span class="modifier">{{ current_commit.creator_name|email2nickname }}</span><span class="time">{{ current_commit.ctime|translate_commit_time }}</span></h2> <h2 class="file-modification-hd"><span class="op-target">{{ u_filename }}</span> {% trans "modification details" %} <a href="{% url 'user_profile' current_commit.creator_name %}">{% avatar current_commit.creator_name 16 %}</a><span class="modifier">{{ current_commit.creator_name|email2nickname }}</span><span class="time">{{ current_commit.ctime|translate_seahub_time }}</span></h2>
<p class="path"> <p class="path">
{% trans "Current Path:" %} {% trans "Current Path:" %}
{% for name, link in zipped %} {% for name, link in zipped %}