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
de4556a0
Commit
de4556a0
authored
Oct 23, 2014
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split special chars handling to separate file
Issue #406 Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
c5ff2af4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
12 deletions
+46
-12
weblate/trans/forms.py
weblate/trans/forms.py
+2
-12
weblate/trans/specialchars.py
weblate/trans/specialchars.py
+44
-0
No files found.
weblate/trans/forms.py
View file @
de4556a0
...
...
@@ -31,6 +31,7 @@ from weblate.lang.models import Language
from
weblate.trans.models
import
Unit
from
weblate.trans.models.source
import
PRIORITY_CHOICES
from
weblate.trans.checks
import
CHECKS
from
weblate.trans.specialchars
import
get_special_chars
from
urllib
import
urlencode
import
weblate
...
...
@@ -63,13 +64,6 @@ PLURALS_TEMPLATE = u'''
<p class="help-block">{2}</p>
'''
SPECIAL_CHARS
=
(
u'→'
,
u'↵'
,
u'…'
)
CHAR_NAMES
=
{
u'→'
:
_
(
'Insert tab character'
),
u'↵'
:
_
(
'Insert new line'
),
u'…'
:
_
(
'Insert horizontal ellipsis'
),
}
def
escape_newline
(
value
):
'''
...
...
@@ -108,11 +102,7 @@ class PluralTextarea(forms.Textarea):
# Special chars
chars
=
[]
for
char
in
SPECIAL_CHARS
:
if
char
in
CHAR_NAMES
:
name
=
CHAR_NAMES
[
char
]
else
:
name
=
ugettext
(
'Insert character {0}'
).
format
(
char
)
for
name
,
char
in
get_special_chars
():
chars
.
append
(
BUTTON_TEMPLATE
.
format
(
'specialchar'
,
...
...
weblate/trans/specialchars.py
0 → 100644
View file @
de4556a0
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2014 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <http://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Helper code to get user special chars specific for given language.
"""
from
django.utils.translation
import
ugettext
as
_
SPECIAL_CHARS
=
(
u'→'
,
u'↵'
,
u'…'
)
CHAR_NAMES
=
{
u'→'
:
_
(
'Insert tab character'
),
u'↵'
:
_
(
'Insert new line'
),
u'…'
:
_
(
'Insert horizontal ellipsis'
),
}
def
get_special_chars
():
"""
Returns list of special characters.
"""
for
char
in
SPECIAL_CHARS
:
if
char
in
CHAR_NAMES
:
name
=
CHAR_NAMES
[
char
]
else
:
name
=
_
(
'Insert character {0}'
).
format
(
char
)
yield
name
,
char
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