Skip to content

Commit 9a8abc4

Browse files
committed
autofill pure invariants
1 parent 7287c26 commit 9a8abc4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

.pdk/pdk/gleaner.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def locations(msg):
4141

4242
def patch_message(old, new, *, verbose=False):
4343
print(locations(new))
44+
print(":#, fuzzy")
4445
changed = False
4546
invariants = [m.span() for m in P_INVARIANT.finditer(old.id)]
4647
if invariants:
@@ -101,6 +102,18 @@ def print_diff(old, new):
101102
print("\n")
102103

103104

105+
def fill_pure_invariants(catalog):
106+
# 번역되지 않은 것들 중 순수하게 invariant 들을 같은 값으로 채운다.
107+
changed = False
108+
for msg in catalog:
109+
if not msg.string and P_INVARIANT.fullmatch(msg.id):
110+
print(locations(msg))
111+
msg.string = msg.id
112+
print(f"fill {msg.id}")
113+
changed = True
114+
return changed
115+
116+
104117
def glean(filename, *, revision=None, verbose=False):
105118
# update 전후의 .po 파일을 before 와 after 로 읽어들인다
106119
with open(filename) as f:
@@ -142,6 +155,8 @@ def glean(filename, *, revision=None, verbose=False):
142155
print()
143156
print_diff(old, new)
144157

158+
changed = fill_pure_invariants(after) or changed
159+
145160
# 변경된 after 를 저장한다
146161
if changed:
147162
f = io.BytesIO()

0 commit comments

Comments
 (0)