Add po/ to the linters
This commit is contained in:
parent
6f45d164a5
commit
7b2992ab3f
1
.flake8
1
.flake8
|
@ -1,6 +1,7 @@
|
||||||
[flake8]
|
[flake8]
|
||||||
builtins = _
|
builtins = _
|
||||||
max-line-length = 100
|
max-line-length = 100
|
||||||
|
show-source = true
|
||||||
|
|
||||||
# Temporary
|
# Temporary
|
||||||
exclude = src/diffuse/main.py
|
exclude = src/diffuse/main.py
|
||||||
|
|
|
@ -22,10 +22,10 @@ jobs:
|
||||||
- run: pip install -r requirements.txt
|
- run: pip install -r requirements.txt
|
||||||
|
|
||||||
- name: Flake8
|
- name: Flake8
|
||||||
run: flake8 src/
|
run: flake8 src/ po/
|
||||||
|
|
||||||
- name: MyPy
|
- name: MyPy
|
||||||
run: mypy src/
|
run: mypy src/ po/
|
||||||
|
|
||||||
meson-build-test:
|
meson-build-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
@ -20,17 +20,18 @@
|
||||||
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import glob
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
def check_translation(filename):
|
def check_translation(filename):
|
||||||
subprocess.run(["msgfmt", "-c", "-v", filename])
|
subprocess.run(['msgfmt', '-c', '-v', filename])
|
||||||
|
|
||||||
|
|
||||||
def update_translation(filename):
|
def update_translation(filename):
|
||||||
print(f"Updating translation file '{filename}'...")
|
print(f'Updating translation file "{filename}"...')
|
||||||
|
|
||||||
# Get language
|
# Get language
|
||||||
lang = os.path.splitext(filename)[0]
|
lang = os.path.splitext(filename)[0]
|
||||||
|
@ -40,17 +41,34 @@ def update_translation(filename):
|
||||||
shutil.move(filename, tmpfile)
|
shutil.move(filename, tmpfile)
|
||||||
|
|
||||||
# Create a new .po file for this language
|
# Create a new .po file for this language
|
||||||
emptypofile = os.path.join(tmpdir, f"{lang}.empty.po")
|
emptypofile = os.path.join(tmpdir, f'{lang}.empty.po')
|
||||||
subprocess.run(["msginit", "--no-wrap", "--no-translator", "-l", lang, "-o", emptypofile, "-i", "diffuse.pot"])
|
subprocess.run([
|
||||||
|
'msginit',
|
||||||
|
'--no-wrap',
|
||||||
|
'--no-translator',
|
||||||
|
'-l',
|
||||||
|
lang,
|
||||||
|
'-o',
|
||||||
|
emptypofile,
|
||||||
|
'-i',
|
||||||
|
'diffuse.pot'])
|
||||||
|
|
||||||
# Merge with the old translation
|
# Merge with the old translation
|
||||||
subprocess.run(["msgmerge", "-q", "--no-wrap", tmpfile, emptypofile, "-o", filename])
|
subprocess.run([
|
||||||
|
'msgmerge',
|
||||||
|
'-q',
|
||||||
|
'--no-wrap',
|
||||||
|
tmpfile,
|
||||||
|
emptypofile,
|
||||||
|
'-o',
|
||||||
|
filename])
|
||||||
|
|
||||||
# Validate translation
|
# Validate translation
|
||||||
print(f"Validate {filename}:")
|
print(f'Validate "{filename}":')
|
||||||
check_translation(filename)
|
check_translation(filename)
|
||||||
|
|
||||||
print(f"Update done.")
|
print('Update done.')
|
||||||
|
|
||||||
|
|
||||||
# Setup argument parser
|
# Setup argument parser
|
||||||
parser = argparse.ArgumentParser(description='Update translation files (.po).')
|
parser = argparse.ArgumentParser(description='Update translation files (.po).')
|
||||||
|
@ -68,7 +86,7 @@ po_files.sort()
|
||||||
|
|
||||||
if args.check_only:
|
if args.check_only:
|
||||||
for file in po_files:
|
for file in po_files:
|
||||||
print(f"Validate {file}:")
|
print(f'Validate "{file}":')
|
||||||
check_translation(file)
|
check_translation(file)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue