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
9e2b3fe4
Commit
9e2b3fe4
authored
Mar 15, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show nearby messages while translating
parent
166a7d98
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
0 deletions
+32
-0
docs/config.rst
docs/config.rst
+4
-0
html/translate.html
html/translate.html
+13
-0
settings.py
settings.py
+3
-0
trans/models.py
trans/models.py
+12
-0
No files found.
docs/config.rst
View file @
9e2b3fe4
...
...
@@ -26,6 +26,10 @@ All settings are stored in :file:`settings.py` (as usual for Django).
API key for Microsoft Translator service, you can register at http://www.bing.com/developers/createapp.aspx
.. envvar:: NEARBY_MESSAGES
How many messages around current one to show during translating.
.. envvar:: SITE_TITLE
Site title to be used in website and emails as well.
...
...
html/translate.html
View file @
9e2b3fe4
...
...
@@ -156,6 +156,19 @@
<li><a
href=
"/js/similar/{{ unit.id }}/"
>
{% trans "Similar messages" %}
</a></li>
</ul>
<div
id=
"tab-nearby"
>
<table>
<thead>
<tr><th>
{% trans "Source" %}
</th><th>
{% trans "Translation" %}
</th></tr>
</thead>
<tbody>
{% for item in unit.nearby %}
<tr>
<td
class=
"translatetext"
>
{{ item.source|fmttranslation }}
</td>
<td
class=
"translatetext"
>
{{ item.target|fmttranslation:unit.translation.language }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
...
...
settings.py
View file @
9e2b3fe4
...
...
@@ -248,3 +248,6 @@ EMAIL_SUBJECT_PREFIX = '[%s] ' % SITE_TITLE
# Enable remote hooks
ENABLE_HOOKS
=
True
# Number of nearby messages to show in each direction
NEARBY_MESSAGES
=
5
trans/models.py
View file @
9e2b3fe4
...
...
@@ -612,6 +612,18 @@ class Unit(models.Model):
check
=
check
)
def
nearby
(
self
):
'''
Returns list of nearby messages based on location.
'''
print
self
.
position
-
settings
.
NEARBY_MESSAGES
print
self
.
position
+
settings
.
NEARBY_MESSAGES
return
Unit
.
objects
.
filter
(
translation
=
self
.
translation
,
position__gte
=
self
.
position
-
settings
.
NEARBY_MESSAGES
,
position__lte
=
self
.
position
+
settings
.
NEARBY_MESSAGES
,
)
class
Suggestion
(
models
.
Model
):
checksum
=
models
.
CharField
(
max_length
=
40
,
default
=
''
,
blank
=
True
,
db_index
=
True
)
target
=
models
.
TextField
()
...
...
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