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
04666ac3
Commit
04666ac3
authored
Feb 29, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Form for non-plural strings
parent
88394915
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
2 deletions
+37
-2
html/translate.html
html/translate.html
+6
-1
trans/forms.py
trans/forms.py
+8
-0
trans/views.py
trans/views.py
+23
-1
No files found.
html/translate.html
View file @
04666ac3
...
...
@@ -17,7 +17,12 @@
<tr><th>
{% trans "Source" %}
</th><th>
{% trans "Translation" %}
<th></tr>
{% if unit.is_plural %}
{% else %}
<tr><td>
{{ unit.source }}
</td><td
colspan=
"2"
>
{{ form.target }}
</td></tr>
<tr><td>
{{ unit.source }}
</td><td
colspan=
"2"
>
{{ form.checksum }}
{{ form.target }}
<br
/>
{{ form.fuzzy }}
<label
for=
"id_fuzzy"
>
{% trans "Fuzzy" %}
</label>
</td></tr>
{% endif %}
<tr><th>
{% trans "Location" %}
</th></tr>
<tr><td>
{{ unit.get_location_links }}
</td></tr>
...
...
trans/forms.py
0 → 100644
View file @
04666ac3
from
django
import
forms
from
django.utils.translation
import
ugettext_lazy
,
ugettext
as
_
class
TranslationForm
(
forms
.
Form
):
checksum
=
forms
.
CharField
(
widget
=
forms
.
HiddenInput
)
target
=
forms
.
CharField
(
widget
=
forms
.
Textarea
,
required
=
False
)
fuzzy
=
forms
.
BooleanField
(
label
=
ugettext_lazy
(
'Fuzzy'
),
required
=
False
)
trans/views.py
View file @
04666ac3
from
django.shortcuts
import
render_to_response
,
get_object_or_404
from
django.template
import
RequestContext
from
django.conf
import
settings
from
django.http
import
HttpResponseRedirect
from
trans.models
import
Project
,
SubProject
,
Translation
,
Unit
from
trans.forms
import
TranslationForm
def
home
(
request
):
projects
=
Project
.
objects
.
all
()
...
...
@@ -39,13 +41,32 @@ def show_translation(request, project, subproject, lang):
def
translate
(
request
,
project
,
subproject
,
lang
):
obj
=
get_object_or_404
(
Translation
,
language__code
=
lang
,
subproject__slug
=
subproject
,
subproject__project__slug
=
project
)
# Check where we are
rqtype
=
request
.
REQUEST
.
get
(
'type'
,
'all'
)
pos
=
request
.
REQUEST
.
get
(
'oldpos'
,
'-1'
)
try
:
pos
=
int
(
pos
)
except
:
pos
=
-
1
unit
=
obj
.
unit_set
.
filter_type
(
rqtype
).
filter
(
position__gt
=
pos
)[
0
]
# Any form submitted?
if
request
.
method
==
'POST'
:
form
=
TranslationForm
(
request
.
POST
)
if
form
.
is_valid
():
# Check and save
return
HttpResponseRedirect
(
'%s?type=%s&oldpos=%d'
%
(
obj
.
get_translate_url
(),
rqtype
,
pos
))
else
:
# What unit to show
unit
=
obj
.
unit_set
.
filter_type
(
rqtype
).
filter
(
position__gt
=
pos
)[
0
]
# Prepare form
form
=
TranslationForm
(
initial
=
{
'checksum'
:
unit
.
checksum
,
'target'
:
unit
.
target
,
'fuzzy'
:
unit
.
fuzzy
,
})
total
=
obj
.
unit_set
.
all
().
count
()
return
render_to_response
(
'translate.html'
,
RequestContext
(
request
,
{
...
...
@@ -54,4 +75,5 @@ def translate(request, project, subproject, lang):
'unit'
:
unit
,
'total'
:
total
,
'type'
:
rqtype
,
'form'
:
form
,
}))
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