Add extract configuration and enhance untranslated extraction functionality
This commit is contained in:
Binary file not shown.
@ -42,10 +42,15 @@ class POHandler:
|
||||
self.logger.error(f'PO 파일 로드 실패: {po_path} - {e}')
|
||||
return None
|
||||
|
||||
def extract_untranslated(self, po_path: Path, output_path: Path) -> int:
|
||||
def extract_untranslated(self, po_path: Path, output_path: Path, include_fuzzy: bool = False) -> int:
|
||||
"""
|
||||
미번역 항목 추출
|
||||
|
||||
Args:
|
||||
po_path: PO 파일 경로
|
||||
output_path: 출력 TSV 파일 경로
|
||||
include_fuzzy: fuzzy 플래그 항목 포함 여부 (원본 변경으로 리뷰 필요한 항목)
|
||||
|
||||
Returns:
|
||||
추출된 항목 개수
|
||||
"""
|
||||
@ -57,20 +62,37 @@ class POHandler:
|
||||
|
||||
# 전체 항목 및 미번역 항목 필터링
|
||||
total_entries = len([entry for entry in po if entry.msgid]) # msgid가 있는 항목만 카운트
|
||||
|
||||
# 미번역 항목: msgstr이 비어있는 항목
|
||||
untranslated = [entry for entry in po if not entry.msgstr.strip()]
|
||||
|
||||
if not untranslated:
|
||||
# fuzzy 항목: fuzzy 플래그가 있는 항목 (원본 변경으로 리뷰 필요)
|
||||
fuzzy_entries = []
|
||||
if include_fuzzy:
|
||||
fuzzy_entries = [entry for entry in po if 'fuzzy' in entry.flags and entry.msgstr.strip()]
|
||||
|
||||
# 통합 리스트
|
||||
all_entries = untranslated + fuzzy_entries
|
||||
|
||||
if not all_entries:
|
||||
translated_count = total_entries
|
||||
self.logger.info(f'전체 {total_entries}개 항목 중 {translated_count}개 번역 완료 (100%)')
|
||||
return 0
|
||||
|
||||
self.logger.info(f'전체 {total_entries}개 항목 중 미번역 {len(untranslated)}건 발견')
|
||||
# 통계 출력
|
||||
if include_fuzzy and fuzzy_entries:
|
||||
self.logger.info(f'전체 {total_entries}개 항목 중:')
|
||||
self.logger.info(f' - 미번역 항목: {len(untranslated)}건')
|
||||
self.logger.info(f' - 리뷰 필요 (fuzzy): {len(fuzzy_entries)}건')
|
||||
self.logger.info(f' - 총 추출 항목: {len(all_entries)}건')
|
||||
else:
|
||||
self.logger.info(f'전체 {total_entries}개 항목 중 미번역 {len(all_entries)}건 발견')
|
||||
|
||||
# TSV 파일로 저장
|
||||
self._save_to_tsv(untranslated, output_path)
|
||||
self._save_to_tsv(all_entries, output_path)
|
||||
|
||||
self.logger.success(f'미번역 항목 추출 완료: {output_path}')
|
||||
return len(untranslated)
|
||||
return len(all_entries)
|
||||
|
||||
def merge_to_csv(self, localization_root: Path, output_path: Path) -> int:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user