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
5889ed4e
Commit
5889ed4e
authored
Jul 08, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add validation for empty language code
Issue #153 Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
7ddc4069
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
weblate/trans/models/subproject.py
weblate/trans/models/subproject.py
+4
-0
weblate/trans/tests/test_models.py
weblate/trans/tests/test_models.py
+26
-0
No files found.
weblate/trans/models/subproject.py
View file @
5889ed4e
...
...
@@ -1039,6 +1039,10 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
translated_langs
=
set
()
for
match
in
matches
:
code
=
self
.
get_lang_code
(
match
)
if
not
code
:
raise
ValidationError
(
_
(
'Got empty language code for %s, please check filemask!'
)
%
match
)
lang
=
Language
.
objects
.
auto_get_or_create
(
code
=
code
)
if
code
in
langs
:
raise
ValidationError
(
_
(
...
...
weblate/trans/tests/test_models.py
View file @
5889ed4e
...
...
@@ -689,6 +689,32 @@ class SubProjectTest(RepoTestCase):
subproject
.
run_hook
(
'true'
)
)
def
test_lang_code
(
self
):
subproject
=
SubProject
()
subproject
.
filemask
=
'Solution/Project/Resources*.resx'
self
.
assertEqual
(
subproject
.
get_lang_code
(
'Solution/Project/Resources.es-mx.resx'
),
'.es-mx'
)
self
.
assertEqual
(
subproject
.
get_lang_code
(
'Solution/Project/Resources.resx'
),
''
)
self
.
assertRaisesMessage
(
ValidationError
,
'Got empty language code for '
'Solution/Project/Resources.resx, please check filemask!'
,
subproject
.
clean_lang_codes
,
[
'Solution/Project/Resources.resx'
,
'Solution/Project/Resources.de.resx'
,
'Solution/Project/Resources.es.resx'
,
'Solution/Project/Resources.es-mx.resx'
,
'Solution/Project/Resources.fr.resx'
,
'Solution/Project/Resources.fr-fr.resx'
,
]
)
class
TranslationTest
(
RepoTestCase
):
"""
...
...
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