Commit 1e641834 authored by Julien Pivotto's avatar Julien Pivotto

Progress on ToX

Signed-off-by: Julien Pivotto's avatarJulien Pivotto <roidelapluie@inuits.eu>
parent fa0b94d6
......@@ -14,7 +14,7 @@ do
tmpdir="$(mktemp -d)"
cp -rv $i/input/ "$tmpdir"
./tox.py "$tmpdir/input"
if diff "$tmpdir/input" "$i/output"
if diff -r "$tmpdir/input" "$i/output"
then
echo -e "Test $(basename $i) \e[1;32mSUCCESS\e[0m" | tee -a "$results"
else
......
<html>
<head>
<title>This is a test</title>
</head>
<body>
<p>This is a test of the ToX project.</p>
<p>This too.</p>
</body>
</html>
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: French\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr "Ceci est un test"
#: index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
msgid "This too."
msgstr "Ceci aussi."
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: Dutch\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: nl\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr ""
#: index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
msgid "This too."
msgstr "Ceci aussi."
<html>
<head>
<title>This is a test</title>
</head>
<body>
<p>This is a test of the ToX project.</p>
<p>This too.</p>
</body>
</html>
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: French\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr "Ceci est un test"
#: index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
msgid "This too."
msgstr "Ceci aussi."
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: Dutch\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: nl\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr "Ceci est un test"
#: index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
msgid "This too."
msgstr ""
<html>
<head>
<title>This is a test</title>
</head>
<body>
<p>This is a test of the ToX project.</p>
<p>This too.</p>
</body>
</html>
<html>
<head>
<title>Ceci est un test</title>
</head>
<body>
<p>Ceci est un test du projet ToX</p>
<p>Ceci aussi.</p>
</body>
</html>
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: French\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr "Ceci est un test"
#: index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
msgid "This too."
msgstr "Ceci aussi."
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: Dutch\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: nl\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr ""
#: index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
msgid "This too."
msgstr "Ceci aussi."
<html>
<head>
<title>This is a test</title>
</head>
<body>
<p>This is a test of the ToX project.</p>
<p>This too.</p>
</body>
</html>
<html>
<head>
<title>Ceci est un test</title>
</head>
<body>
<p>Ceci est un test du projet ToX</p>
<p>Ceci aussi.</p>
</body>
</html>
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: French\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr "Ceci est un test"
#: index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
msgid "This too."
msgstr "Ceci aussi."
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-07-17 21:07+0200\n"
"PO-Revision-Date: 2016-07-17 21:08+0200\n"
"Last-Translator: <roidelapluie@localhost>\n"
"Language-Team: Dutch\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Translate Toolkit 1.13.0\n"
"Language: nl\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: index.en.xhtml+html.head.title:3
msgid "This is a test"
msgstr "Ceci est un test"
#: index.en.xhtml+html.body.p:6
msgid "This is a test of the ToX project."
msgstr "Ceci est un test du projet ToX"
#: index.en.xhtml+html.body.p:7
msgid "This too."
msgstr ""
#!/usr/bin/env python
"""lingvoj.py
Usage:
tox.py <sourcedir>
Options:
sourcedir: Path to the source directory
"""
import os
from docopt import docopt
from translate.storage import factory
import logging
logging.basicConfig(level=logging.DEBUG)
class Tox:
def __init__(self, directory):
self.directory = directory
def run(self):
self.walk_into_dirs()
return 0
def walk_into_dirs(self):
for dirpath, _, filenames in os.walk(self.directory):
if 'locale.pot' in filenames:
logging.debug('Pot in %s' % dirpath)
pofiles = self.get_po_files(filenames)
filenames = self.extract_files_from_pot(dirpath)
logging.debug('Filenames files: %s' % filenames)
logging.debug('Po files: %s' % pofiles)
for pofile in pofiles:
for filename in filenames:
pofile_obj = factory.getobject(os.path.join(dirpath, pofile))
self.is_pofile_translated_for_file()
for unit in pofile_x.unit_iter():
self.is_
print unit.sourcecomments
def extract_files_from_pot(self, dirpath):
filenames = set()
with open(os.path.join(dirpath, 'locale.pot'), 'r') as f:
for line in f:
if line.startswith('#: '):
filename = line[3:].split('+')[0]
filenames.add(filename)
return filenames
def get_po_files(self, filenames):
results = []
for filename in filenames:
if not filename.startswith('locale.'):
logging.debug('Filename does not start with locale.: %s' % filename)
continue
if not filename.endswith('.po'):
logging.debug('Filename does not ends with .po: %s' % filename)
continue
if not len(filename.split('.')) == 3:
logging.debug('Filename does not contain 2 dots: %s' % filename)
continue
results.append(filename)
return results
def main():
arguments = docopt(__doc__, version='0.1')
srcdir=arguments['<sourcedir>']
exit(Tox(srcdir).run())
if __name__ == '__main__':
main()
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