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
9e9d8d73
Commit
9e9d8d73
authored
Dec 23, 2015
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
53a0db7f
1d4329c2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
6 deletions
+60
-6
weblate/trans/specialchars.py
weblate/trans/specialchars.py
+19
-6
weblate/trans/tests/test_specialchars.py
weblate/trans/tests/test_specialchars.py
+41
-0
No files found.
weblate/trans/specialchars.py
View file @
9e9d8d73
...
...
@@ -31,6 +31,8 @@ CHAR_NAMES = {
u'→'
:
ugettext_lazy
(
'Insert tab character'
),
u'↵'
:
ugettext_lazy
(
'Insert new line'
),
u'…'
:
ugettext_lazy
(
'Insert horizontal ellipsis'
),
u'।'
:
ugettext_lazy
(
'Danda'
),
u'॥'
:
ugettext_lazy
(
'Double danda'
),
}
# Quotes definition for each language, based on CLDR data
...
...
@@ -415,6 +417,10 @@ EM_DASH_LANGS = frozenset((
'sv'
,
'ta'
,
'th'
,
'to'
,
'tr'
,
'uz'
,
'vi'
,
'vo'
,
'yi'
,
'zh'
,
))
EXTRA_CHARS
=
{
'brx'
:
(
u'।'
,
u'॥'
),
}
def
get_quote
(
code
,
data
,
name
):
"""
...
...
@@ -425,19 +431,26 @@ def get_quote(code, data, name):
return
name
,
data
[
'ALL'
]
def
get_char_description
(
char
):
"""Returns verbose description of a character."""
if
char
in
CHAR_NAMES
:
return
CHAR_NAMES
[
char
]
else
:
return
_
(
'Insert character {0}'
).
format
(
char
)
def
get_special_chars
(
language
):
"""
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
yield
get_char_description
(
char
),
char
code
=
language
.
code
.
replace
(
'_'
,
'-'
).
split
(
'-'
)[
0
]
if
code
in
EXTRA_CHARS
:
for
char
in
EXTRA_CHARS
[
code
]:
yield
get_char_description
(
char
),
char
yield
get_quote
(
code
,
DOUBLE_OPEN
,
_
(
'Opening double quote'
))
yield
get_quote
(
code
,
DOUBLE_CLOSE
,
_
(
'Closing double quote'
))
yield
get_quote
(
code
,
SINGLE_OPEN
,
_
(
'Opening single quote'
))
...
...
weblate/trans/tests/test_specialchars.py
0 → 100644
View file @
9e9d8d73
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2015 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <https://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/>.
#
"""
Tests for special chars.
"""
from
unittest
import
TestCase
from
weblate.lang.models
import
Language
from
weblate.trans.specialchars
import
get_special_chars
class
SpecialCharsTest
(
TestCase
):
def
test_af
(
self
):
chars
=
list
(
get_special_chars
(
Language
(
code
=
'af'
)))
self
.
assertEqual
(
len
(
chars
),
10
)
def
test_cs
(
self
):
chars
=
list
(
get_special_chars
(
Language
(
code
=
'cs'
)))
self
.
assertEqual
(
len
(
chars
),
9
)
def
test_brx
(
self
):
chars
=
list
(
get_special_chars
(
Language
(
code
=
'brx'
)))
self
.
assertEqual
(
len
(
chars
),
9
)
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