Skip to content
Snippets Groups Projects
Commit fdcb41ce authored by drebs's avatar drebs
Browse files

Build machine translation db and run tmserver.

parent 6a944c60
Branches 27-add-possibility-to-view-removed-metadata
No related tags found
No related merge requests found
...@@ -65,5 +65,16 @@ RUN /usr/local/sbin/weblate-setup-env.sh; /usr/local/sbin/weblate-install.sh ...@@ -65,5 +65,16 @@ RUN /usr/local/sbin/weblate-setup-env.sh; /usr/local/sbin/weblate-install.sh
# Create project and import languages # Create project and import languages
RUN /usr/local/sbin/weblate-setup-env.sh; /usr/local/sbin/weblate-setup-project.sh RUN /usr/local/sbin/weblate-setup-env.sh; /usr/local/sbin/weblate-setup-project.sh
# Build machine translation db and enable use of tmserver
RUN /usr/local/sbin/weblate-build-tmdb.sh
# TODO: Weblate tries to look for languages supported by tmserver by querying
# ab unexisting API endpoint (/languages), what causes a 404 error and
# prevents the tmserver functionality in Weblate from working properly.
# We have to confirm if this is a bug in Weblate, check if this bug is
# still present in upstream and report/fix accordingly:
# https://github.com/WeblateOrg/weblate/blob/master/weblate/trans/machine/tmserver.py#L54
COPY weblate/fix-tmserver-api.patch /tmp/ RUN patch -p0 -d
/usr/local/share/weblate < /tmp/fix-tmserver-api.patch
# Setup server and serve Weblate using Apache # Setup server and serve Weblate using Apache
CMD /usr/local/sbin/weblate-setup-env.sh; /usr/local/sbin/weblate-run-server.sh CMD /usr/local/sbin/weblate-setup-env.sh; /usr/local/sbin/weblate-run-server.sh
#!/bin/sh
# This script creates a Translation Memory Database from the current Tails
# cloned repository.
DBFILE=/var/lib/weblate/tails-wiki.tmdb
REPO=/var/lib/weblate/repositories/vcs/tails/wikisrcindexpo
create_tmdb() {
for pofile in $( find ${REPO}/wiki/src -iname "*.po" ); do
lang=$( echo ${pofile} | sed -e "s/^.*\.\([a-z][a-z]\)\.po\$/\1/" );
build_tmdb -d ${DBFILE} -s en -t ${lang} ${pofile}
done
}
create_tmdb
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
set -e set -e
weblate_run_server() { weblate_run_server() {
tmserver -d /var/lib/weblate/tails-wiki.tmdb -p 8080 &
/usr/sbin/apache2ctl -D FOREGROUND /usr/sbin/apache2ctl -D FOREGROUND
} }
......
diff --git weblate/trans/machine/tmserver.py weblate/trans/machine/tmserver.py
index 86a6deaf1..08e29d98c 100644
--- weblate/trans/machine/tmserver.py
+++ weblate/trans/machine/tmserver.py
@@ -73,11 +73,7 @@ class TMServerTranslation(MachineTranslation):
'''
Checks whether given language combination is supported.
'''
- if len(self.supported_languages) == 0:
- # Fallback for old tmserver which does not export list of
- # supported languages
- return True
- return (source, language) in self.supported_languages
+ return True
def download_translations(self, source, language, text, unit, user):
'''
...@@ -452,7 +452,7 @@ MT_MYMEMORY_KEY = None ...@@ -452,7 +452,7 @@ MT_MYMEMORY_KEY = None
MT_GOOGLE_KEY = None MT_GOOGLE_KEY = None
# tmserver URL # tmserver URL
MT_TMSERVER = 'http://127.0.0.1:8080/' MT_TMSERVER = 'http://127.0.0.1:8080/tmserver/'
# Title of site to use # Title of site to use
SITE_TITLE = 'Tails translation platform' SITE_TITLE = 'Tails translation platform'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment