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

The import_project now understand langauge filtering

Fixes #904
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent f02f470e
......@@ -139,6 +139,9 @@ base file for monolingual translations.
You can also specify file format to use (see :ref:`formats`) by the
``--file-format`` parameter. The default is autodetection.
You can specify language filtering (see :ref:`component`) by the
``--language-filter`` parameter. It has to be valid regullar expression.
In case you need to specify version control system to use, you can do this using
``--vcs`` parameter. The default version control is Git.
......
......@@ -23,6 +23,7 @@ Released on ? 2015.
* Fixed sitewide search for failing checks.
* Added option to specify source language.
* Improved support for XLIFF files.
* Extended list of options for import_project.
weblate 2.4
-----------
......
......@@ -70,6 +70,14 @@ class Command(BaseCommand):
default='auto',
help='File format type, defaults to autodetection',
),
make_option(
'--language-filter',
default=None,
help=(
'Language filter regular expression to be used for created'
' components'
),
),
make_option(
'--vcs',
default='git',
......@@ -82,6 +90,7 @@ class Command(BaseCommand):
self.filemask = None
self.component_re = None
self.file_format = None
self.language_filter = None
self.name_template = None
self.base_file_template = None
self.vcs = None
......@@ -179,6 +188,7 @@ class Command(BaseCommand):
self.filemask = args[3]
self.vcs = options['vcs']
self.file_format = options['file_format']
self.language_filter = options['language_filter']
self.name_template = options['name_template']
self.base_file_template = options['base_file_template']
if options['component_regexp']:
......@@ -256,10 +266,20 @@ class Command(BaseCommand):
repo=sharedrepo,
branch=branch,
template=template,
file_format=self.file_format,
filemask=self.filemask.replace('**', match)
filemask=self.filemask.replace('**', match),
**self.get_project_attribs()
)
def get_project_attribs(self):
result = {
'file_format': self.file_format,
'vcs': self.vcs,
}
if self.language_filter is not None:
result['language_regex'] = self.language_filter
return result
def import_initial(self, project, repo, branch):
'''
Import the first repository of a project
......@@ -297,10 +317,9 @@ class Command(BaseCommand):
project=project,
repo=repo,
branch=branch,
file_format=self.file_format,
vcs=self.vcs,
template=template,
filemask=self.filemask.replace('**', match)
filemask=self.filemask.replace('**', match),
**self.get_project_attribs()
)
sharedrepo = 'weblate://%s/%s' % (project.slug, slug)
......
......@@ -53,6 +53,21 @@ class ImportProjectTest(RepoTestCase):
# We should have loaded four subprojects
self.assertEqual(project.subproject_set.count(), 4)
def test_import_filter(self):
project = self.create_project()
call_command(
'import_project',
'test',
self.git_repo_path,
'master',
'**/*.po',
language_filter='cs'
)
# We should have loaded four subprojects
self.assertEqual(project.subproject_set.count(), 4)
for component in project.subproject_set.all():
self.assertEqual(component.translation_set.count(), 1)
def test_import_re(self):
project = self.create_project()
call_command(
......
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