Chunk translation clean script to avoid too long url error (#43090)

This commit is contained in:
Paulus Schoutsen 2020-11-11 13:23:16 +01:00 committed by GitHub
parent 68d757e5d2
commit 687923690f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -91,22 +91,25 @@ def run():
print("No missing translations!")
return 0
key_data = lokalise.keys_list(
{"filter_keys": ",".join(missing_keys), "limit": 1000}
)
if len(key_data) != len(missing_keys):
# We can't query too many keys at once, so limit the number to 50.
for i in range(0, len(missing_keys), 50):
chunk = missing_keys[i : i + 50]
key_data = lokalise.keys_list({"filter_keys": ",".join(chunk), "limit": 1000})
if len(key_data) != len(chunk):
print(
f"Lookin up key in Lokalise returns {len(key_data)} results, expected {len(missing_keys)}"
f"Lookin up key in Lokalise returns {len(key_data)} results, expected {len(chunk)}"
)
return 1
print(f"Deleting {len(missing_keys)} keys:")
for key in missing_keys:
print(f"Deleting {len(chunk)} keys:")
for key in chunk:
print(" -", key)
print()
while input("Type YES to delete these keys: ") != "YES":
pass
print(lokalise.keys_delete_multiple([key["key_id"] for key in key_data]))
print()
return 0