Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
pytils ru_strftime:django的俄罗斯一个月案例_Django_Templates_Date - Fatal编程技术网

pytils ru_strftime:django的俄罗斯一个月案例

pytils ru_strftime:django的俄罗斯一个月案例,django,templates,date,Django,Templates,Date,在这种情况下,我怎样才能得到俄罗斯月呢? 此代码: {{date}ru|strftime:“%B,%Y”} 给出“фааааа,2014”。 但我需要“Фааа,2014”:在这种情况下,您不需要使用pytils,只需使用datetime模块的本地化格式: >>>import datetime, locale >>>locale.setlocale(locale.LC_ALL, 'russian_russia') >>>datetime.d

在这种情况下,我怎样才能得到俄罗斯月呢? 此代码: {{date}ru|strftime:“%B,%Y”} 给出“фааааа,2014”。
但我需要“Фааа,2014”:

在这种情况下,您不需要使用pytils,只需使用datetime模块的本地化格式:

>>>import datetime, locale

>>>locale.setlocale(locale.LC_ALL, 'russian_russia')
>>>datetime.datetime.today().strftime("%B, %Y")
'Февраль 2015'

我在ubuntu中更改了语言环境(设置为乌克兰语):>>sudo语言环境gen ru_ru.UTF-8。添加到/etc/environment行:>>LANG=ru\u ru.UTF-8>>LC\u ALL=ru\u ru.UTF-8。不重新启动:export LANG=ru_ru.UTF-8 export LC_ALL=ru_ru.UTF-8。然后按照您所说的设置语言环境:>>locale.setlocale(locale.LC_ALL'ru_.UTF-8')