mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Push translation utility scripts
This commit is contained in:
parent
b2f6fc753a
commit
cd0252a2b5
39
Scripts/Translations/find-unused.py
Normal file
39
Scripts/Translations/find-unused.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import re, glob
|
||||||
|
|
||||||
|
directory = input("Enter project path (the one containing Bloxstrap.csproj): ")
|
||||||
|
|
||||||
|
existing = []
|
||||||
|
found = []
|
||||||
|
|
||||||
|
with open(f"{directory}\\Resources\\Strings.resx", "r") as file:
|
||||||
|
existing = re.findall("name=\"([a-zA-Z0-9.]+)\" xml:space=\"preserve\"", file.read())
|
||||||
|
|
||||||
|
for filename in glob.glob(f"{directory}\\**\\*.*", recursive=True):
|
||||||
|
if "\\bin\\" in filename or "\\obj\\" in filename or "\\Resources\\" in filename:
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(filename, "r") as file:
|
||||||
|
contents = file.read()
|
||||||
|
|
||||||
|
matches = re.findall("Strings.([a-zA-Z0-9_]+)", contents)
|
||||||
|
for match in matches:
|
||||||
|
if not '_' in match:
|
||||||
|
continue
|
||||||
|
|
||||||
|
ref = match.replace('_', '.')
|
||||||
|
if not ref in found:
|
||||||
|
found.append(ref)
|
||||||
|
|
||||||
|
matches = re.findall("FromTranslation = \"([a-zA-Z0-9.]+)\"", contents)
|
||||||
|
for match in matches:
|
||||||
|
if not match in found:
|
||||||
|
found.append(match)
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
print(f"Could not open {filename}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
for entry in existing:
|
||||||
|
if not entry in found and not "Enums." in entry:
|
||||||
|
print(entry)
|
14
Scripts/Translations/prep.py
Normal file
14
Scripts/Translations/prep.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import glob, shutil
|
||||||
|
|
||||||
|
exports = input("Path of folder of exported Crowdin files: ")
|
||||||
|
dest = input("Destination resources folder: ")
|
||||||
|
|
||||||
|
for filename in glob.glob(f"{exports}\\**\\*.*", recursive=True):
|
||||||
|
print(f"Copying {filename}")
|
||||||
|
|
||||||
|
suffix = ""
|
||||||
|
|
||||||
|
if filename.endswith("Strings.bs-BA.resx"):
|
||||||
|
suffix = "\\Strings.bs.resx"
|
||||||
|
|
||||||
|
shutil.copy(filename, dest + suffix)
|
Loading…
Reference in New Issue
Block a user