本文整理汇总了Python中nagare.i18n.set_locale函数的典型用法代码示例。如果您正苦于以下问题:Python set_locale函数的具体用法?Python set_locale怎么用?Python set_locale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_locale函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_era_names
def test_get_era_names(self):
i18n.set_locale(i18n.Locale('en', 'US'))
self.assertEqual(i18n.get_era_names(), {0: u'Before Christ', 1: u'Anno Domini'})
self.assertEqual(i18n.get_era_names(width='wide'), {0: u'Before Christ', 1: u'Anno Domini'})
self.assertEqual(i18n.get_era_names(width='abbreviated'), {0: u'BC', 1: u'AD'})
self.assertEqual(i18n.get_era_names(width='narrow'), {0: u'B', 1: u'A'})
开发者ID:nagareproject,项目名称:core,代码行数:7,代码来源:test_i18n.py
示例2: test_format_time_time_with_format
def test_format_time_time_with_format(self):
i18n.set_locale(i18n.Locale('en', 'US', timezone='Pacific/Pitcairn'))
t = datetime.time(15, 30)
self.assertEqual(i18n.format_time(t, format="hh 'o''clock' a, zzzz"), "03 o'clock PM, Pitcairn Time")
t = datetime.time(15, 30, tzinfo=pytz.timezone('Africa/Niamey'))
self.assertEqual(i18n.format_time(t, format="hh 'o''clock' a, zzzz"), "03 o'clock PM, Pitcairn Time")
开发者ID:nagareproject,项目名称:core,代码行数:8,代码来源:test_i18n.py
示例3: test_format_datetime_with_format
def test_format_datetime_with_format(self):
i18n.set_locale(i18n.Locale('en', 'US', timezone='Pacific/Pitcairn'))
d = datetime.datetime(2007, 4, 1, 15, 30)
self.assertEqual(i18n.format_datetime(d, format="yyyy.MM.dd G 'at' HH:mm:ss zzz"), '2007.04.01 AD at 15:30:00 -0800')
tz = pytz.timezone('Africa/Niamey')
d = tz.localize(datetime.datetime(2007, 4, 1, 15, 30))
self.assertEqual(i18n.format_datetime(d, format="yyyy.MM.dd G 'at' HH:mm:ss zzz"), '2007.04.01 AD at 06:30:00 -0800')
开发者ID:nagareproject,项目名称:core,代码行数:9,代码来源:test_i18n.py
示例4: test_format_time_datetime_with_format
def test_format_time_datetime_with_format(self):
i18n.set_locale(i18n.Locale('en', 'US', timezone='Pacific/Pitcairn'))
d = datetime.datetime(2007, 4, 1, 15, 30)
self.assertEqual(i18n.format_time(d, format="hh 'o''clock' a, zzzz"), u"03 o'clock PM, Pitcairn Time")
tz = pytz.timezone('Africa/Niamey')
d = tz.localize(datetime.datetime(2007, 4, 1, 15, 30))
self.assertEqual(i18n.format_time(d, format="hh 'o''clock' a, zzzz"), u"06 o'clock AM, Pitcairn Time")
开发者ID:nagareproject,项目名称:core,代码行数:9,代码来源:test_i18n.py
示例5: test_format_time_datetime_fr3
def test_format_time_datetime_fr3(self):
i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Africa/Niamey', default_timezone=pytz.UTC))
d = datetime.datetime(2007, 4, 1, 15, 30)
self.assertEqual(i18n.format_time(d, format='full'), u'16:30:00 heure normale d’Afrique de l’Ouest')
self.assertEqual(i18n.format_time(d, format='long'), '16:30:00 +0100')
self.assertEqual(i18n.format_time(d, format='medium'), '16:30:00')
self.assertEqual(i18n.format_time(d), '16:30:00')
self.assertEqual(i18n.format_time(d, format='short'), '16:30')
开发者ID:nagareproject,项目名称:core,代码行数:10,代码来源:test_i18n.py
示例6: test_format_time_datetime_fr1
def test_format_time_datetime_fr1(self):
i18n.set_locale(i18n.Locale('fr', 'FR'))
d = datetime.datetime(2007, 4, 1, 15, 30)
self.assertEqual(i18n.format_time(d, format='full'), '15:30:00 UTC+00:00')
self.assertEqual(i18n.format_time(d, format='long'), '15:30:00 +0000')
self.assertEqual(i18n.format_time(d, format='medium'), '15:30:00')
self.assertEqual(i18n.format_time(d), '15:30:00')
self.assertEqual(i18n.format_time(d, format='short'), '15:30')
开发者ID:nagareproject,项目名称:core,代码行数:10,代码来源:test_i18n.py
示例7: set_locale
def set_locale(self, locale):
"""Set the locale of the request scope
In:
- ``locale`` -- the locale
"""
if locale.dirname is None:
locale.dirname = os.path.join(self.data_path, 'locale')
i18n.set_locale(locale)
开发者ID:apoirier,项目名称:test,代码行数:10,代码来源:wsgi.py
示例8: set_locale
def set_locale(self, locale):
"""Set the locale of the request scope
In:
- ``locale`` -- the locale
"""
if not locale.has_translation_directory():
locale.add_translation_directory(os.path.join(self.data_path, 'locale'))
i18n.set_locale(locale)
开发者ID:nagareproject,项目名称:core,代码行数:10,代码来源:wsgi.py
示例9: test_format_time_time_en
def test_format_time_time_en(self):
i18n.set_locale(i18n.Locale('en', 'US', timezone='Pacific/Pitcairn'))
t = datetime.time(15, 30)
self.assertEqual(i18n.format_time(t, format='full'), '3:30:00 PM Pitcairn Time')
self.assertEqual(i18n.format_time(t, format='long'), '3:30:00 PM -0800')
self.assertEqual(i18n.format_time(t, format='medium'), '3:30:00 PM')
self.assertEqual(i18n.format_time(t), '3:30:00 PM')
self.assertEqual(i18n.format_time(t, format='short'), '3:30 PM')
开发者ID:nagareproject,项目名称:core,代码行数:10,代码来源:test_i18n.py
示例10: test_format_time_time_fr1
def test_format_time_time_fr1(self):
i18n.set_locale(i18n.Locale('fr', 'FR'))
t = datetime.time(15, 30)
self.assertEqual(i18n.format_time(t, format='full'), '15:30:00 UTC+00:00')
self.assertEqual(i18n.format_time(t, format='long'), '15:30:00 +0000')
self.assertEqual(i18n.format_time(t, format='medium'), '15:30:00')
self.assertEqual(i18n.format_time(t), '15:30:00')
self.assertEqual(i18n.format_time(t, format='short'), '15:30')
开发者ID:nagareproject,项目名称:core,代码行数:10,代码来源:test_i18n.py
示例11: test_format_time_time_fr4
def test_format_time_time_fr4(self):
i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Africa/Niamey'))
t = datetime.time(15, 30, tzinfo=pytz.timezone('Pacific/Pitcairn'))
self.assertEqual(i18n.format_time(t, format='full'), u'15:30:00 heure normale d’Afrique de l’Ouest')
self.assertEqual(i18n.format_time(t, format='long'), '15:30:00 +0100')
self.assertEqual(i18n.format_time(t, format='medium'), '15:30:00')
self.assertEqual(i18n.format_time(t), '15:30:00')
self.assertEqual(i18n.format_time(t, format='short'), '15:30')
开发者ID:nagareproject,项目名称:core,代码行数:10,代码来源:test_i18n.py
示例12: test_format_time_time_fr3
def test_format_time_time_fr3(self):
i18n.set_locale(i18n.Locale('fr', 'FR'))
t = datetime.time(15, 30, tzinfo=pytz.timezone('Pacific/Pitcairn'))
self.assertEqual(i18n.format_time(t, format='full'), '15:30:00 UTC+00:00')
self.assertEqual(i18n.format_time(t, format='long'), '15:30:00 +0000')
self.assertEqual(i18n.format_time(t, format='medium'), '15:30:00')
self.assertEqual(i18n.format_time(t), '15:30:00')
self.assertEqual(i18n.format_time(t, format='short'), '15:30')
开发者ID:nagareproject,项目名称:core,代码行数:10,代码来源:test_i18n.py
示例13: test_parse_date_en
def test_parse_date_en(self):
i18n.set_locale(i18n.Locale('en', 'US'))
d = i18n.parse_date('4/1/04')
self.assertIsInstance(d, datetime.date)
self.assertEqual((d.year, d.month, d.day), (2004, 4, 1))
d = i18n.parse_date('4/1/2004')
self.assertIsInstance(d, datetime.date)
self.assertEqual((d.year, d.month, d.day), (2004, 4, 1))
开发者ID:nagareproject,项目名称:core,代码行数:10,代码来源:test_i18n.py
示例14: test_format_datetime
def test_format_datetime(self):
i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Africa/Niamey'))
tz = pytz.timezone('Pacific/Pitcairn')
d = tz.localize(datetime.datetime(2007, 4, 1, 15, 30))
self.assertEqual(i18n.format_datetime(d, format='full'), u'lundi 2 avril 2007 à 00:30:00 heure normale d’Afrique de l’Ouest')
self.assertEqual(i18n.format_datetime(d, format='long'), u'2 avril 2007 à 00:30:00 +0100')
self.assertEqual(i18n.format_datetime(d, format='medium'), u'2 avr. 2007 à 00:30:00')
self.assertEqual(i18n.format_datetime(d), u'2 avr. 2007 à 00:30:00')
self.assertEqual(i18n.format_datetime(d, format='short'), '02/04/2007 00:30')
开发者ID:nagareproject,项目名称:core,代码行数:11,代码来源:test_i18n.py
示例15: test_format_time_datetime_fr4
def test_format_time_datetime_fr4(self):
i18n.set_locale(i18n.Locale('fr', 'FR'))
tz = pytz.timezone('Pacific/Pitcairn')
d = tz.localize(datetime.datetime(2007, 4, 1, 15, 30))
self.assertEqual(i18n.format_time(d, format='full'), '23:30:00 UTC+00:00')
self.assertEqual(i18n.format_time(d, format='long'), '23:30:00 +0000')
self.assertEqual(i18n.format_time(d, format='medium'), '23:30:00')
self.assertEqual(i18n.format_time(d), '23:30:00')
self.assertEqual(i18n.format_time(d, format='short'), '23:30')
开发者ID:nagareproject,项目名称:core,代码行数:11,代码来源:test_i18n.py
示例16: test_context_manager
def test_context_manager(self):
locale1 = i18n.Locale('fr', 'FR', domain='domain1')
locale2 = i18n.Locale('fr', 'FR', domain='domain2')
i18n.set_locale(locale1)
self.assertEqual(i18n.get_locale().domain, 'domain1')
with locale2:
self.assertEqual(i18n.get_locale().domain, 'domain2')
with locale2:
self.assertEqual(i18n.get_locale().domain, 'domain2')
self.assertEqual(i18n.get_locale().domain, 'domain1')
开发者ID:nagareproject,项目名称:core,代码行数:13,代码来源:test_i18n.py
示例17: test_get_timezone_gmt
def test_get_timezone_gmt(self):
utc_date = datetime.datetime(2007, 4, 1, 15, 30)
tz = pytz.timezone('Pacific/Pitcairn')
d = Locale('en', timezone=tz).to_timezone(utc_date)
self.assertEqual(i18n.get_timezone_gmt(d, width='long'), u'UTC-08:00')
self.assertEqual(i18n.get_timezone_gmt(d), u'UTC-08:00')
self.assertEqual(i18n.get_timezone_gmt(d, width='short'), '-0800')
i18n.set_locale(i18n.Locale('en', 'US'))
self.assertEqual(i18n.get_timezone_gmt(d, width='long'), u'GMT-08:00')
self.assertEqual(i18n.get_timezone_gmt(d), u'GMT-08:00')
self.assertEqual(i18n.get_timezone_gmt(d, width='short'), '-0800')
开发者ID:nagareproject,项目名称:core,代码行数:15,代码来源:test_i18n.py
注:本文中的nagare.i18n.set_locale函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论