Created
March 22, 2014 09:40
-
-
Save AndreiPashkin/9703843 to your computer and use it in GitHub Desktop.
Proof of concent for usage of pymorphy for Django admin russian translation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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