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
bbe2593b
Commit
bbe2593b
authored
May 06, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document custom fixups
parent
c9ac0740
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
0 deletions
+54
-0
docs/admin.rst
docs/admin.rst
+17
-0
docs/config.rst
docs/config.rst
+2
-0
examples/fix_foo.py
examples/fix_foo.py
+35
-0
No files found.
docs/admin.rst
View file @
bbe2593b
...
...
@@ -588,6 +588,23 @@ languages using ``dictionary`` Python module:
You can list own class in :setting:`MACHINE_TRANSLATION_SERVICES` and Weblate
will start using that.
.. _custom-autofix:
Custom automatic fixups
-----------------------
You can also implement own automatic fixup in addition to standard ones and
include them in :setting:`AUTOFIX_LIST`.
The automatic fixes are powerful, but can also cause damage, be careful when
writing one.
For example following automatic fixup would replace every occurence of string
``foo`` in translation with ``bar``:
.. literalinclude:: ../examples/fix_foo.py
:language: python
.. _custom-checks:
Customizing checks
...
...
docs/config.rst
View file @
bbe2593b
...
...
@@ -75,6 +75,8 @@ For example you can enable only few of them:
'trans.autofixes.chars.ReplaceTrailingDotsWithEllipsis',
)
.. seealso:: :ref:`autofix`, :ref:`custom-autofix`
.. setting:: BACKGROUND_HOOKS
BACKGROUND_HOOKS
...
...
examples/fix_foo.py
0 → 100644
View file @
bbe2593b
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2013 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <http://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/>.
#
from
trans.autofixes.base
import
AutoFix
from
django.utils.translation
import
ugettext_lazy
as
_
class
ReplaceFooWithBar
(
AutoFix
):
'''
Replaces foo with bar.
'''
name
=
_
(
'Foobar'
)
def
fix_single_target
(
self
,
target
,
source
,
unit
):
if
'foo'
in
target
:
return
target
.
replace
(
'foo'
,
'bar'
),
True
return
target
,
False
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