Compare commits
2 Commits
4300b15431
...
33d03481e4
| Author | SHA1 | Date | |
|---|---|---|---|
| 33d03481e4 | |||
| ed4c3d0d00 |
File diff suppressed because it is too large
Load Diff
@ -108,19 +108,32 @@ def update_po_file(file_path, translations_to_update):
|
|||||||
for msgctxt, new_msgstr in translations_to_update.items():
|
for msgctxt, new_msgstr in translations_to_update.items():
|
||||||
if msgctxt in po_data:
|
if msgctxt in po_data:
|
||||||
entry = po_data[msgctxt]
|
entry = po_data[msgctxt]
|
||||||
|
current_msgstr = entry['msgstr']
|
||||||
|
|
||||||
|
# 먼저 현재 값과 새 값이 다른지 확인
|
||||||
|
if current_msgstr == new_msgstr:
|
||||||
|
# 변경사항 없음 - 건너뜀 (로그 출력 안함)
|
||||||
|
continue
|
||||||
|
|
||||||
original_block = entry['original_block']
|
original_block = entry['original_block']
|
||||||
|
|
||||||
old_msgstr_part = f'msgstr "{entry["msgstr"]}"'
|
# 백슬래시와 쌍따옴표를 올바르게 이스케이프
|
||||||
escaped_new_msgstr = new_msgstr.replace('"', '\\"')
|
escaped_new_msgstr = new_msgstr.replace('\\', '\\\\').replace('"', '\\"')
|
||||||
new_msgstr_part = f'msgstr "{escaped_new_msgstr}"'
|
|
||||||
|
# msgstr 라인 전체를 교체하는 정규식
|
||||||
if old_msgstr_part in original_block:
|
updated_block = re.sub(
|
||||||
updated_block = original_block.replace(old_msgstr_part, new_msgstr_part)
|
r'^(msgstr\s+)\".*\"$',
|
||||||
|
r'\1"' + escaped_new_msgstr + '"',
|
||||||
|
original_block,
|
||||||
|
flags=re.MULTILINE
|
||||||
|
)
|
||||||
|
|
||||||
|
if updated_block != original_block:
|
||||||
content = content.replace(original_block, updated_block)
|
content = content.replace(original_block, updated_block)
|
||||||
logging.info(f" > 업데이트: msgctxt='{msgctxt}'")
|
logging.info(f" > 업데이트: msgctxt='{msgctxt}'")
|
||||||
update_count += 1
|
update_count += 1
|
||||||
else:
|
else:
|
||||||
logging.warning(f" > 패턴 불일치 (업데이트 실패): msgctxt='{msgctxt}'의 msgstr을 원본에서 찾지 못했습니다.")
|
logging.warning(f" > 정규식 교체 실패: msgctxt='{msgctxt}'")
|
||||||
else:
|
else:
|
||||||
logging.warning(f" > msgctxt 찾기 실패: '{msgctxt}'를 PO 파일에서 찾을 수 없습니다.")
|
logging.warning(f" > msgctxt 찾기 실패: '{msgctxt}'를 PO 파일에서 찾을 수 없습니다.")
|
||||||
|
|
||||||
|
|||||||
3515
번역업데이트.tsv
Normal file
3515
번역업데이트.tsv
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user