1
0
Fork 0
mirror of https://github.com/Findus23/matomo-utils.git synced 2024-09-18 14:03:44 +02:00

intial collection

This commit is contained in:
Lukas Winkler 2021-08-25 12:21:56 +02:00
commit e0e1fe2db4
Signed by: lukas
GPG key ID: 54DE4D798D244853
4 changed files with 113 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
.idea/
config.py
*.csv

28
missing_languages.py Normal file
View file

@ -0,0 +1,28 @@
from pathlib import Path
lang_dir = Path("../lang")
languages_in_matomo = set(str(dir.stem) for dir in lang_dir.glob("*.json"))
print(len(languages_in_matomo))
languages_in_transifex = set()
completenesses = {}
names = {}
with open("matomo_matomo.languages.csv") as f:
next(f)
for line in f:
cols = line.split(",")
name = cols[0]
code = cols[1].replace("_", "-").lower()
if code == "-":
continue
completeness = 100 - float(cols[3][:-1])
languages_in_transifex.add(code)
completenesses[code] = completeness
names[code] = name
assert languages_in_matomo - languages_in_transifex == {"dev"}
for code in languages_in_transifex - languages_in_matomo:
print(code, names[code], f"{completenesses[code]:.2f}% complete")

25
sortTranslationKeys.py Normal file
View file

@ -0,0 +1,25 @@
import json
from pathlib import Path
matomo_dir = Path("..")
files = sorted(matomo_dir.glob("**/en.json"))
for file in files:
plugin_json = file.parent.parent / "plugin.json"
if not plugin_json.exists():
continue
with plugin_json.open() as f:
plugin_data = json.load(f)
if "authors" not in plugin_data:
continue
if plugin_data["authors"][0]["name"] != "Lukas Winkler":
continue
if plugin_data["name"] != "DiagnosticsExtended":
continue
print(file)
with file.open("r") as f:
data = json.load(f)
with file.open("w") as f:
json.dump(data, f, indent=4, ensure_ascii=False, sort_keys=True)
f.write("\n")

57
weblate/mass-edit.py Normal file
View file

@ -0,0 +1,57 @@
from typing import Dict
import requests
from config import *
s = requests.Session()
s.headers.update({"Authorization": "Token " + token})
def lock_component(component, unlock=False):
lock = not unlock
lock_url = component["lock_url"]
r = s.post(lock_url, data={"lock": lock})
print(r.json())
r.raise_for_status()
def update_setting(component, settings: Dict):
component_url = component["url"]
r = s.patch(component_url, data=settings)
if r.status_code > 200:
print(r.json())
r.raise_for_status()
components = {}
r = s.get(url + "projects/matomo/components/")
data = r.json()
count = data["count"]
for comp in data["results"]:
components[comp["slug"]] = comp
while data["next"]:
r = s.get(data["next"])
data = r.json()
for comp in data["results"]:
components[comp["slug"]] = comp
assert len(components) == count
phpcomponents = {slug: comp for slug, comp in components.items() if not comp["is_glossary"]}
community_components = {slug: comp for slug, comp in components.items() if "Community" in comp["name"]}
official_components = {slug: components[slug] for slug in set(phpcomponents) - set(community_components)}
for slug, comp in phpcomponents.items():
print(slug, comp["name"])
print(comp["check_flags"])
update_setting(comp, {
"check_flags": "php-format,ignore-optional-plural"
})
# lock_component(comp)
# print("locked")