Skip to content

Instantly share code, notes, and snippets.

@xfenix
Created March 13, 2015 22:01
Show Gist options
  • Save xfenix/139ddb50e6c863de7353 to your computer and use it in GitHub Desktop.
Save xfenix/139ddb50e6c863de7353 to your computer and use it in GitHub Desktop.
def rupluralize(value, endings):
try:
endings = endings.split(',')
if value % 100 in (11, 12, 13, 14):
return endings[2]
if value % 10 == 1:
return endings[0]
if value % 10 in (2, 3, 4):
return endings[1]
else:
return endings[2]
except:
raise TemplateSyntaxError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment