1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-01-26 15:02:54 +02:00

41 lines
1.2 KiB
Python
Raw Normal View History

import os
for filename in os.popen("git diff --name-only").read().split():
if not filename.endswith(".po"):
continue
2023-10-18 19:56:05 +02:00
if "POT-Creation-Date" in os.popen(
f"git diff --unified=0 {filename}").read():
print(
f"Assuming {filename} was changed automatically, skipping msgid check"
)
continue
changed_lines = {
i + 1
2023-10-18 19:56:05 +02:00
for i, line in enumerate(
os.popen(f"git blame {filename}").readlines())
if line.startswith("00000000")
}
saw_msgid = False
with open(filename, "r") as f:
line = f.readline()
line_number = 1
while line:
if line.startswith("msgid"):
saw_msgid = True
elif line.startswith("msgstr"):
saw_msgid = False
if saw_msgid and line_number in changed_lines:
print(f"Changed msgid in file {filename}:{line_number}!")
print(
"Please read https://github.com/google/comprehensive-rust/blob/main/TRANSLATIONS.md#creating-and-updating-translations."
)
exit(1)
line_number += 1
line = f.readline()