Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
d43d0435
Commit
d43d0435
authored
Nov 29, 2013
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
171f9b56
9024b6aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
9 deletions
+60
-9
trans/formats.py
trans/formats.py
+2
-2
trans/tests/test_models.py
trans/tests/test_models.py
+5
-5
trans/tests/test_views.py
trans/tests/test_views.py
+53
-2
No files found.
trans/formats.py
View file @
d43d0435
...
@@ -149,8 +149,8 @@ class FileUnit(object):
...
@@ -149,8 +149,8 @@ class FileUnit(object):
# Need to apply special magic for plurals here
# Need to apply special magic for plurals here
# as there is no singlular/plural in the source string
# as there is no singlular/plural in the source string
return
join_plural
([
return
join_plural
([
self
.
unit
.
source
.
replace
(
'(s)'
,
''
)
,
self
.
unit
.
source
,
self
.
unit
.
source
.
replace
(
'(s)'
,
's'
)
,
self
.
unit
.
source
,
])
])
if
self
.
is_unit_key_value
():
if
self
.
is_unit_key_value
():
# Need to decode property encoded string
# Need to decode property encoded string
...
...
trans/tests/test_models.py
View file @
d43d0435
...
@@ -147,10 +147,10 @@ class RepoTestCase(TestCase):
...
@@ -147,10 +147,10 @@ class RepoTestCase(TestCase):
'po-mono/en.po'
,
'po-mono/en.po'
,
)
)
def
create_ts
(
self
):
def
create_ts
(
self
,
suffix
=
''
):
return
self
.
_create_subproject
(
return
self
.
_create_subproject
(
'ts'
,
'ts'
,
'ts
/*.ts'
,
'ts
{0}/*.ts'
.
format
(
suffix
)
,
)
)
def
create_iphone
(
self
):
def
create_iphone
(
self
):
...
@@ -355,8 +355,8 @@ class SubProjectTest(RepoTestCase):
...
@@ -355,8 +355,8 @@ class SubProjectTest(RepoTestCase):
self
.
verify_subproject
(
project
,
1
,
'cs'
,
4
)
self
.
verify_subproject
(
project
,
1
,
'cs'
,
4
)
def
test_create_ts
(
self
):
def
test_create_ts
(
self
):
project
=
self
.
create_ts
()
project
=
self
.
create_ts
(
'-translated'
)
self
.
verify_subproject
(
project
,
1
,
'cs'
,
4
,
'Hello, world!'
)
self
.
verify_subproject
(
project
,
1
,
'cs'
,
4
)
unit
=
Unit
.
objects
.
get
(
source__startswith
=
'Orangutan'
)
unit
=
Unit
.
objects
.
get
(
source__startswith
=
'Orangutan'
)
self
.
assertTrue
(
unit
.
is_plural
())
self
.
assertTrue
(
unit
.
is_plural
())
...
@@ -367,7 +367,7 @@ class SubProjectTest(RepoTestCase):
...
@@ -367,7 +367,7 @@ class SubProjectTest(RepoTestCase):
self
.
assertFalse
(
unit
.
is_plural
())
self
.
assertFalse
(
unit
.
is_plural
())
self
.
assertTrue
(
unit
.
translated
)
self
.
assertTrue
(
unit
.
translated
)
self
.
assertFalse
(
unit
.
fuzzy
)
self
.
assertFalse
(
unit
.
fuzzy
)
self
.
assertEqual
(
unit
.
target
,
'Hello, world!'
)
self
.
assertEqual
(
unit
.
target
,
'Hello, world!
\
n
'
)
unit
=
Unit
.
objects
.
get
(
source__startswith
=
'Thank '
)
unit
=
Unit
.
objects
.
get
(
source__startswith
=
'Thank '
)
self
.
assertFalse
(
unit
.
is_plural
())
self
.
assertFalse
(
unit
.
is_plural
())
...
...
trans/tests/test_views.py
View file @
d43d0435
...
@@ -34,6 +34,7 @@ from accounts.models import Profile
...
@@ -34,6 +34,7 @@ from accounts.models import Profile
from
PIL
import
Image
from
PIL
import
Image
import
re
import
re
import
time
import
time
import
unittest
from
urlparse
import
urlsplit
from
urlparse
import
urlsplit
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
...
@@ -97,7 +98,7 @@ class ViewTestCase(RepoTestCase):
...
@@ -97,7 +98,7 @@ class ViewTestCase(RepoTestCase):
def
get_unit
(
self
,
source
=
'Hello, world!
\
n
'
):
def
get_unit
(
self
,
source
=
'Hello, world!
\
n
'
):
translation
=
self
.
get_translation
()
translation
=
self
.
get_translation
()
return
translation
.
unit_set
.
get
(
source
=
source
)
return
translation
.
unit_set
.
get
(
source
__startswith
=
source
)
def
change_unit
(
self
,
target
):
def
change_unit
(
self
,
target
):
unit
=
self
.
get_unit
()
unit
=
self
.
get_unit
()
...
@@ -105,7 +106,10 @@ class ViewTestCase(RepoTestCase):
...
@@ -105,7 +106,10 @@ class ViewTestCase(RepoTestCase):
unit
.
save_backend
(
self
.
get_request
(
'/'
))
unit
.
save_backend
(
self
.
get_request
(
'/'
))
def
edit_unit
(
self
,
source
,
target
,
**
kwargs
):
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
=
{
params
=
{
'checksum'
:
unit
.
checksum
,
'checksum'
:
unit
.
checksum
,
'target'
:
target
,
'target'
:
target
,
...
@@ -341,6 +345,8 @@ class EditTest(ViewTestCase):
...
@@ -341,6 +345,8 @@ class EditTest(ViewTestCase):
'''
'''
Tests for manipulating translation.
Tests for manipulating translation.
'''
'''
has_plurals
=
True
def
setUp
(
self
):
def
setUp
(
self
):
super
(
EditTest
,
self
).
setUp
()
super
(
EditTest
,
self
).
setUp
()
self
.
translation
=
self
.
subproject
.
translation_set
.
get
(
self
.
translation
=
self
.
subproject
.
translation_set
.
get
(
...
@@ -390,6 +396,38 @@ class EditTest(ViewTestCase):
...
@@ -390,6 +396,38 @@ class EditTest(ViewTestCase):
self
.
assertFalse
(
unit
.
fuzzy
)
self
.
assertFalse
(
unit
.
fuzzy
)
self
.
assertBackend
(
1
)
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
):
def
test_merge
(
self
):
# Translate unit to have something to start with
# Translate unit to have something to start with
response
=
self
.
edit_unit
(
response
=
self
.
edit_unit
(
...
@@ -613,6 +651,8 @@ class EditTest(ViewTestCase):
...
@@ -613,6 +651,8 @@ class EditTest(ViewTestCase):
class
EditResourceTest
(
EditTest
):
class
EditResourceTest
(
EditTest
):
has_plurals
=
False
def
create_subproject
(
self
):
def
create_subproject
(
self
):
return
self
.
create_android
()
return
self
.
create_android
()
...
@@ -623,16 +663,22 @@ class EditPoMonoTest(EditTest):
...
@@ -623,16 +663,22 @@ class EditPoMonoTest(EditTest):
class
EditIphoneTest
(
EditTest
):
class
EditIphoneTest
(
EditTest
):
has_plurals
=
False
def
create_subproject
(
self
):
def
create_subproject
(
self
):
return
self
.
create_iphone
()
return
self
.
create_iphone
()
class
EditJavaTest
(
EditTest
):
class
EditJavaTest
(
EditTest
):
has_plurals
=
False
def
create_subproject
(
self
):
def
create_subproject
(
self
):
return
self
.
create_java
()
return
self
.
create_java
()
class
EditXliffTest
(
EditTest
):
class
EditXliffTest
(
EditTest
):
has_plurals
=
False
def
create_subproject
(
self
):
def
create_subproject
(
self
):
return
self
.
create_xliff
()
return
self
.
create_xliff
()
...
@@ -642,6 +688,11 @@ class EditLinkTest(EditTest):
...
@@ -642,6 +688,11 @@ class EditLinkTest(EditTest):
return
self
.
create_link
()
return
self
.
create_link
()
class
EditTSTest
(
EditTest
):
def
create_subproject
(
self
):
return
self
.
create_ts
()
class
SuggestionsTest
(
ViewTestCase
):
class
SuggestionsTest
(
ViewTestCase
):
def
add_suggestion_1
(
self
):
def
add_suggestion_1
(
self
):
return
self
.
edit_unit
(
return
self
.
edit_unit
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment