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
53e2f313
Commit
53e2f313
authored
Feb 27, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Plurals handling
parent
6569e7e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
trans/models.py
trans/models.py
+22
-0
No files found.
trans/models.py
View file @
53e2f313
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
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