Skip to content

Instantly share code, notes, and snippets.

@AndreiPashkin
Created March 22, 2014 09:40
Show Gist options
  • Save AndreiPashkin/9703843 to your computer and use it in GitHub Desktop.
Save AndreiPashkin/9703843 to your computer and use it in GitHub Desktop.
Proof of concent for usage of pymorphy for Django admin russian translation
# coding=utf-8
import pymorphy2
morph = pymorphy2.MorphAnalyzer()
verbose_name = u'Статья'
p = morph.parse(verbose_name)[0]
print(
u'Создать' + u' ' +
morph.parse(u'новый')[0].inflect({p.tag.number,
p.tag.gender,
'accs'}).word +
u' ' +
p.inflect({'accs'}).word.capitalize()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment