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
e1036ef8
Commit
e1036ef8
authored
Mar 07, 2016
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
580b2f28
64a21aee
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
0 deletions
+89
-0
docs/admin/config.rst
docs/admin/config.rst
+6
-0
docs/admin/continuous.rst
docs/admin/continuous.rst
+4
-0
examples/hook-update-resx
examples/hook-update-resx
+78
-0
weblate/trans/scripts.py
weblate/trans/scripts.py
+1
-0
No files found.
docs/admin/config.rst
View file @
e1036ef8
...
...
@@ -544,6 +544,12 @@ POST_UPDATE_SCRIPTS
List of scripts which are allowed as post update scripts. The script needs to be
later enabled in the :ref:`component`.
Weblate comes with few example hook scripts which you might find useful:
:file:`examples/hook-update-resx`
Updates resx file to match template by adding new translations and removing
obsolete ones.
.. seealso::
:ref:`processing`
...
...
docs/admin/continuous.rst
View file @
e1036ef8
...
...
@@ -258,6 +258,10 @@ Additionally following environment variables are available:
File mask for current component.
.. envvar:: WL_TEMPLATE
File name of template for monolingual translations (can be empty).
.. envvar:: WL_FILE_FORMAT
File format used in current component.
...
...
examples/hook-update-resx
0 → 100755
View file @
e1036ef8
#! /usr/bin/env python
"""
Post update hook script to update message IDs in the resx file.
"""
from
__future__
import
print_function
import
glob
import
os
import
subprocess
import
sys
from
translate.storage.resx
import
RESXFile
def
build_index
(
storage
):
index
=
{}
for
unit
in
storage
.
units
:
index
[
unit
.
getid
()]
=
unit
return
index
def
update_file
(
template
,
index
,
filename
):
storage
=
RESXFile
.
parsefile
(
filename
)
sindex
=
build_index
(
storage
)
# Add missing units
for
unit
in
template
.
units
:
if
unit
.
getid
()
not
in
sindex
:
storage
.
addunit
(
unit
,
True
)
# Remove extra units
for
unit
in
storage
.
units
:
if
unit
.
getid
()
not
in
index
:
storage
.
body
.
remove
(
unit
.
xmlelement
)
storage
.
save
()
def
main
():
if
os
.
environ
.
get
(
'WL_FILE_FORMAT'
)
!=
'resx'
:
print
(
'Invalid file format!'
)
sys
.
exit
(
1
)
if
not
os
.
environ
.
get
(
'WL_TEMPLATE'
):
print
(
'Missing template!'
)
sys
.
exit
(
1
)
if
not
os
.
environ
.
get
(
'WL_FILEMASK'
):
print
(
'Missing filemask!'
)
sys
.
exit
(
1
)
if
not
os
.
environ
.
get
(
'WL_PATH'
):
print
(
'Missing path!'
)
sys
.
exit
(
1
)
os
.
chdir
(
os
.
environ
.
get
(
'WL_PATH'
))
templatename
=
os
.
environ
.
get
(
'WL_TEMPLATE'
)
template
=
RESXFile
.
parsefile
(
templatename
)
index
=
build_index
(
template
)
for
filename
in
glob
.
glob
(
os
.
environ
.
get
(
'WL_FILEMASK'
)):
if
filename
!=
templatename
:
update_file
(
template
,
index
,
filename
)
if
subprocess
.
call
([
'git'
,
'commit'
,
'--dry-run'
,
'-a'
])
==
0
:
ret
=
subprocess
.
call
(
[
'git'
,
'commit'
,
'-a'
,
'-m'
,
'Updated translation files'
]
)
sys
.
exit
(
ret
)
if
__name__
==
'__main__'
:
main
()
weblate/trans/scripts.py
View file @
e1036ef8
...
...
@@ -72,6 +72,7 @@ def run_hook(component, translation, script, *args):
environment
[
'WL_REPO'
]
=
target
.
repo
environment
[
'WL_PATH'
]
=
target
.
get_path
()
environment
[
'WL_FILEMASK'
]
=
component
.
filemask
environment
[
'WL_TEMPLATE'
]
=
component
.
template
environment
[
'WL_FILE_FORMAT'
]
=
component
.
file_format
if
translation
:
environment
[
'WL_LANGUAGE'
]
=
translation
.
language_code
...
...
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