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
3a23d10b
Commit
3a23d10b
authored
Aug 13, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Per subproject settings for adding new languages (issue #67)
parent
fec7b3be
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
263 additions
and
0 deletions
+263
-0
docs/admin.rst
docs/admin.rst
+6
-0
trans/migrations/0052_auto__add_field_subproject_new_base.py
trans/migrations/0052_auto__add_field_subproject_new_base.py
+216
-0
trans/models/subproject.py
trans/models/subproject.py
+41
-0
No files found.
docs/admin.rst
View file @
3a23d10b
...
...
@@ -25,6 +25,8 @@ organized as project/subproject structure.
Weblate supports wide range of translation formats supported by translate
toolkit, see :ref:`formats` for more information.
.. _monolingual:
Monolingual resources
+++++++++++++++++++++
...
...
@@ -117,6 +119,10 @@ Filemask
translation files (eg. more Gettext domains), you need to create separate
subproject for each. For example ``po/*.po`` or
``locale/*/LC_MESSAGES/django.po``.
Monolingual base language file
Base file containing strings definition for :ref:`monolingual`.
Base file for new translations
Base file used to generate new translations, eg. ``.pot`` file with Gettext.
Report source bugs
Email address used for reporting upstream bugs. This address will also receive
notification about any source string comments made in Weblate.
...
...
trans/migrations/0052_auto__add_field_subproject_new_base.py
0 → 100644
View file @
3a23d10b
This diff is collapsed.
Click to expand it.
trans/models/subproject.py
View file @
3a23d10b
...
...
@@ -145,6 +145,15 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
'for monolingual translation formats.'
)
)
new_base
=
models
.
CharField
(
verbose_name
=
ugettext_lazy
(
'Base file for new translations'
),
max_length
=
200
,
blank
=
True
,
help_text
=
ugettext_lazy
(
'Filename of file which is used for creating new translations.'
'For Gettext choose .pot file.'
)
)
file_format
=
models
.
CharField
(
verbose_name
=
ugettext_lazy
(
'File format'
),
max_length
=
50
,
...
...
@@ -871,6 +880,29 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
'
\
n
'
.
join
(
errors
)
))
def
clean_new_lang
(
self
):
'''
Validates new language choices.
'''
if
self
.
project
.
new_lang
==
'add '
:
if
not
self
.
file_format_cls
.
supports_new_language
():
raise
ValidationError
(
_
(
'Chosen file format does not support adding '
'new translations as chosen in project settings.'
))
filename
=
self
.
get_new_base_filename
()
if
not
self
.
file_format_cls
.
is_valid_base_for_new
(
filename
):
raise
ValidationError
(
_
(
'Format of base file for new translations '
'was not recognized!'
))
elif
self
.
project
.
new_lang
!=
'add '
and
self
.
new_base
:
raise
ValidationError
(
_
(
'Base file for new translations is not used because of '
'project settings.'
))
def
clean
(
self
):
'''
Validator fetches repository and tries to find translation files.
...
...
@@ -927,6 +959,9 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
_
(
'You can not use monolingual translation without base file!'
)
)
# New language options
self
.
clean_new_lang
()
# Suggestions
if
self
.
suggestion_autoaccept
and
not
self
.
suggestion_voting
:
raise
ValidationError
(
_
(
...
...
@@ -940,6 +975,12 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
'''
return
os
.
path
.
join
(
self
.
get_path
(),
self
.
template
)
def
get_new_base_filename
(
self
):
'''
Creates absolute filename for base file for new translations.
'''
return
os
.
path
.
join
(
self
.
get_path
(),
self
.
new_base
)
def
save
(
self
,
*
args
,
**
kwargs
):
'''
Save wrapper which updates backend Git repository and regenerates
...
...
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