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
9642949b
Commit
9642949b
authored
Jan 21, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Share code for translation parsing from command line
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
0516409c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
24 deletions
+27
-24
weblate/trans/management/commands/__init__.py
weblate/trans/management/commands/__init__.py
+16
-0
weblate/trans/management/commands/add_suggestions.py
weblate/trans/management/commands/add_suggestions.py
+6
-12
weblate/trans/management/commands/auto_translate.py
weblate/trans/management/commands/auto_translate.py
+5
-12
No files found.
weblate/trans/management/commands/__init__.py
View file @
9642949b
...
...
@@ -195,3 +195,19 @@ class WeblateLangCommand(WeblateCommand):
"""
raise
NotImplementedError
()
class
WeblateTranslationCommand
(
BaseCommand
):
"""Command with target of one translation."""
args
=
'<project> <component> <language>'
def
get_translation
(
self
,
args
):
"""Get translation object"""
try
:
return
Translation
.
objects
.
get
(
subproject__project__slug
=
args
[
0
],
subproject__slug
=
args
[
1
],
language__code
=
args
[
2
],
)
except
Translation
.
DoesNotExist
:
raise
CommandError
(
'No matching translation project found!'
)
weblate/trans/management/commands/add_suggestions.py
View file @
9642949b
...
...
@@ -20,21 +20,22 @@
from
optparse
import
make_option
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management.base
import
CommandError
from
django.contrib.auth.models
import
User
from
django.http.request
import
HttpRequest
from
weblate.trans.models
import
Translation
from
weblate.accounts.models
import
get_author_name
from
weblate.trans.management.commands
import
WeblateTranslationCommand
class
Command
(
Base
Command
):
"""
class
Command
(
WeblateTranslation
Command
):
"""
WeblateTranslationCommand
Command for mass importing suggestions.
"""
help
=
'imports suggestions'
args
=
'<project> <component> <language> <file>'
option_list
=
Base
Command
.
option_list
+
(
option_list
=
WeblateTranslation
Command
.
option_list
+
(
make_option
(
'--author'
,
default
=
'noreply@weblate.org'
,
...
...
@@ -50,14 +51,7 @@ class Command(BaseCommand):
raise
CommandError
(
'Invalid number of parameters!'
)
# Get translation object
try
:
translation
=
Translation
.
objects
.
get
(
subproject__project__slug
=
args
[
0
],
subproject__slug
=
args
[
1
],
language__code
=
args
[
2
],
)
except
Translation
.
DoesNotExist
:
raise
CommandError
(
'No matching translation project found!'
)
translation
=
self
.
get_translation
(
args
)
# Get user
try
:
...
...
weblate/trans/management/commands/auto_translate.py
View file @
9642949b
...
...
@@ -20,20 +20,20 @@
from
optparse
import
make_option
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management.base
import
CommandError
from
django.contrib.auth.models
import
User
from
weblate.trans.models
import
Translation
,
SubProject
from
weblate.trans.autotranslate
import
auto_translate
from
weblate.trans.management.commands
import
WeblateTranslationCommand
class
Command
(
Base
Command
):
class
Command
(
WeblateTranslation
Command
):
"""
Command for mass automatic translation.
"""
help
=
'performs automatic translation based on other components'
args
=
'<project> <component> <language>'
option_list
=
BaseCommand
.
option_list
+
(
option_list
=
WeblateTranslationCommand
.
option_list
+
(
make_option
(
'--user'
,
default
=
'anonymous'
,
...
...
@@ -72,14 +72,7 @@ class Command(BaseCommand):
raise
CommandError
(
'Invalid number of parameters!'
)
# Get translation object
try
:
translation
=
Translation
.
objects
.
get
(
subproject__project__slug
=
args
[
0
],
subproject__slug
=
args
[
1
],
language__code
=
args
[
2
],
)
except
Translation
.
DoesNotExist
:
raise
CommandError
(
'No matching translation project found!'
)
translation
=
self
.
get_translation
(
args
)
# Get user
try
:
...
...
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