Commit 53e2f313 authored by Michal Čihař's avatar Michal Čihař

Plurals handling

parent 6569e7e5
from django.db import models
from lang.models import Language
PLURAL_SEPARATOR = '\x00\x00'
class Project(models.Model):
name = models.CharField(max_length = 100)
slug = models.SlugField(db_index = True)
......@@ -29,3 +31,23 @@ class Unit(models.Model):
flags = models.TextField()
source = models.TextField()
target = models.TextField()
def is_plural(self):
return self.source.find(PLURAL_SEPARATOR) != -1
def get_source_plurals(self):
return self.source.split(PLURAL_SEPARATOR)
def get_target_plurals(self):
ret = self.target.split(PLURAL_SEPARATOR)
plurals = self.translation.language.nplurals
if len(ret) == plurals:
return ret
while len(ret) < plurals:
ret.append('')
while len(ret) > plurals:
del(ret[-1])
return ret
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment