INNER CODE UNIT · Python
process_file
OpenChemistry/avogadrolibs · scripts/copy-default.py:334
def process_file(filepath, locale_override=None, dry_run=False):
"""Fill empty msgstr entries and respell the untouched copies."""
path = Path(filepath)
if not path.exists():
print(f"Error: File '{filepath}' not found.", file=sys.stderr)
return False
# wrapwidth=0 saves unwrapped; msgcat then rewraps the gettext way
po = polib.pofile(str(path), wrapwidth=0)
locale = detect_locale(path, po, locale_override)
if locale not in SUPPORTED_LOCALES:
print(f"Notice: locale '{locale or 'unknown'}' has no spelling "
f"rules; copying msgid without respelling.", file=sys.stderr)
print(f"Processed: {path.name}")
print(f"Locale: {locale or 'unknown'}")