Commit de4556a0 authored by Michal Čihař's avatar Michal Čihař

Split special chars handling to separate file

Issue #406
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent c5ff2af4
......@@ -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',
......
# -*- 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment