|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /proc/self/root/usr/lib/python2.7/site-packages/timeago/locales/ |
Upload File : |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2016-5-26
@author: hustcc
'''
from __future__ import absolute_import
from timeago import setting
def locale_module(mod, locale):
try:
return getattr(getattr(getattr(mod, 'locales'), locale), 'LOCALE')
except:
raise
def timeago_template(locale, index, ago_in):
'''
simple locale implement
'''
try:
LOCALE = __import__('timeago.locales.' + locale)
LOCALE = locale_module(LOCALE, locale)
except:
locale = setting.DEFAULT_LOCALE
LOCALE = __import__('timeago.locales.' + locale)
LOCALE = locale_module(LOCALE, locale)
if isinstance(LOCALE, list):
return LOCALE[index][ago_in]
else:
return LOCALE(index, ago_in)