Commit d43d0435 authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents 171f9b56 9024b6aa
......@@ -149,8 +149,8 @@ class FileUnit(object):
# Need to apply special magic for plurals here
# as there is no singlular/plural in the source string
return join_plural([
self.unit.source.replace('(s)', ''),
self.unit.source.replace('(s)', 's'),
self.unit.source,
self.unit.source,
])
if self.is_unit_key_value():
# Need to decode property encoded string
......
......@@ -147,10 +147,10 @@ class RepoTestCase(TestCase):
'po-mono/en.po',
)
def create_ts(self):
def create_ts(self, suffix=''):
return self._create_subproject(
'ts',
'ts/*.ts',
'ts{0}/*.ts'.format(suffix),
)
def create_iphone(self):
......@@ -355,8 +355,8 @@ class SubProjectTest(RepoTestCase):
self.verify_subproject(project, 1, 'cs', 4)
def test_create_ts(self):
project = self.create_ts()
self.verify_subproject(project, 1, 'cs', 4, 'Hello, world!')
project = self.create_ts('-translated')
self.verify_subproject(project, 1, 'cs', 4)
unit = Unit.objects.get(source__startswith='Orangutan')
self.assertTrue(unit.is_plural())
......@@ -367,7 +367,7 @@ class SubProjectTest(RepoTestCase):
self.assertFalse(unit.is_plural())
self.assertTrue(unit.translated)
self.assertFalse(unit.fuzzy)
self.assertEqual(unit.target, 'Hello, world!')
self.assertEqual(unit.target, 'Hello, world!\n')
unit = Unit.objects.get(source__startswith='Thank ')
self.assertFalse(unit.is_plural())
......
......@@ -34,6 +34,7 @@ from accounts.models import Profile
from PIL import Image
import re
import time
import unittest
from urlparse import urlsplit
from cStringIO import StringIO
......@@ -97,7 +98,7 @@ class ViewTestCase(RepoTestCase):
def get_unit(self, source='Hello, world!\n'):
translation = self.get_translation()
return translation.unit_set.get(source=source)
return translation.unit_set.get(source__startswith=source)
def change_unit(self, target):
unit = self.get_unit()
......@@ -105,7 +106,10 @@ class ViewTestCase(RepoTestCase):
unit.save_backend(self.get_request('/'))
def edit_unit(self, source, target, **kwargs):
unit = self.get_translation().unit_set.get(source=source)
'''
Does edit single unit using web interface.
'''
unit = self.get_unit(source)
params = {
'checksum': unit.checksum,
'target': target,
......@@ -341,6 +345,8 @@ class EditTest(ViewTestCase):
'''
Tests for manipulating translation.
'''
has_plurals = True
def setUp(self):
super(EditTest, self).setUp()
self.translation = self.subproject.translation_set.get(
......@@ -390,6 +396,38 @@ class EditTest(ViewTestCase):
self.assertFalse(unit.fuzzy)
self.assertBackend(1)
def test_plurals(self):
'''
Test plural editing.
'''
if not self.has_plurals:
return
response = self.edit_unit(
'Orangutan',
u'Opice má %d banán.\n',
target_1=u'Opice má %d banány.\n',
target_2=u'Opice má %d banánů.\n',
)
# We should get to second message
self.assertRedirectsOffset(response, self.translate_url, 1)
# Check translations
unit = self.get_unit('Orangutan')
plurals = unit.get_target_plurals()
self.assertEquals(len(plurals), 3)
self.assertEquals(
plurals[0],
u'Opice má %d banán.\n',
)
self.assertEquals(
plurals[1],
u'Opice má %d banány.\n',
)
self.assertEquals(
plurals[2],
u'Opice má %d banánů.\n',
)
def test_merge(self):
# Translate unit to have something to start with
response = self.edit_unit(
......@@ -613,6 +651,8 @@ class EditTest(ViewTestCase):
class EditResourceTest(EditTest):
has_plurals = False
def create_subproject(self):
return self.create_android()
......@@ -623,16 +663,22 @@ class EditPoMonoTest(EditTest):
class EditIphoneTest(EditTest):
has_plurals = False
def create_subproject(self):
return self.create_iphone()
class EditJavaTest(EditTest):
has_plurals = False
def create_subproject(self):
return self.create_java()
class EditXliffTest(EditTest):
has_plurals = False
def create_subproject(self):
return self.create_xliff()
......@@ -642,6 +688,11 @@ class EditLinkTest(EditTest):
return self.create_link()
class EditTSTest(EditTest):
def create_subproject(self):
return self.create_ts()
class SuggestionsTest(ViewTestCase):
def add_suggestion_1(self):
return self.edit_unit(
......
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