mirror of
https://github.com/Findus23/matomo_tests.git
synced 2024-08-27 19:52:19 +02:00
initial commit
This commit is contained in:
commit
8065b69963
5 changed files with 211 additions and 0 deletions
133
.gitignore
vendored
Normal file
133
.gitignore
vendored
Normal file
|
@ -0,0 +1,133 @@
|
|||
|
||||
# Created by https://www.gitignore.io/api/python
|
||||
# Edit at https://www.gitignore.io/?templates=python
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# End of https://www.gitignore.io/api/python
|
||||
|
||||
.idea
|
8
.travis.yml
Normal file
8
.travis.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
language: python
|
||||
python:
|
||||
- "3.7"
|
||||
install:
|
||||
- git clone https://github.com/matomo-org/matomo.git
|
||||
- cp config.travis.py config.py
|
||||
script:
|
||||
- python translation_placeholders.py
|
3
config.py
Normal file
3
config.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from pathlib import Path
|
||||
|
||||
matomo_path = Path("/home/lukas/public_html/piwik")
|
3
config.travis.py
Normal file
3
config.travis.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from pathlib import Path
|
||||
|
||||
matomo_path = Path("./matomo")
|
64
translation_placeholders.py
Normal file
64
translation_placeholders.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
import json
|
||||
import re
|
||||
|
||||
from config import matomo_path
|
||||
|
||||
lang_dirs = [matomo_path / "lang"]
|
||||
|
||||
pluginspath = matomo_path / "plugins"
|
||||
|
||||
regex = re.compile(r"%[sducoxXbgGeEfF]")
|
||||
typo_regex = re.compile(r"%%[sducoxXbgGeEfF]")
|
||||
fail = False
|
||||
for plugindir in pluginspath.iterdir():
|
||||
if not plugindir.is_dir():
|
||||
continue
|
||||
if "UptimeRobotMonitor" in str(plugindir):
|
||||
continue
|
||||
langdir = plugindir / "lang"
|
||||
if langdir.exists():
|
||||
lang_dirs.append(langdir)
|
||||
|
||||
for langdir in lang_dirs:
|
||||
with open(langdir / "en.json") as f:
|
||||
data = json.load(f)
|
||||
placeholders = {}
|
||||
master_translations = list(data.values())[0]
|
||||
for key, translation in master_translations.items():
|
||||
typos = typo_regex.findall(translation)
|
||||
if typos:
|
||||
print(typos)
|
||||
num_placeholders = len(regex.findall(translation))
|
||||
placeholders[key] = num_placeholders
|
||||
|
||||
for transfile in langdir.glob("*.json"):
|
||||
if transfile == langdir / "en.json":
|
||||
continue
|
||||
lang = transfile.stem
|
||||
with open(transfile) as f:
|
||||
data = json.load(f)
|
||||
translations = list(data.values())[0]
|
||||
for key, translation in translations.items():
|
||||
typos = typo_regex.findall(translation)
|
||||
if typos:
|
||||
print(transfile)
|
||||
print(typos, translation)
|
||||
print()
|
||||
fail = True
|
||||
num_placeholders = len(regex.findall(translation))
|
||||
try:
|
||||
if placeholders[key] != num_placeholders:
|
||||
print(transfile)
|
||||
print(placeholders[key], num_placeholders)
|
||||
print(master_translations[key])
|
||||
print(translations[key])
|
||||
print()
|
||||
fail = True
|
||||
except KeyError:
|
||||
print(transfile)
|
||||
print(f"Key '{key}' is only in {lang}")
|
||||
print()
|
||||
fail = True
|
||||
|
||||
if fail:
|
||||
exit(1)
|
Loading…
Reference in a new issue