Add a backup of po files

This commit is contained in:
Guðni Már Gilbert 2023-02-18 10:13:34 +00:00
parent 280a904799
commit b6ef8ea32c
1 changed files with 4 additions and 0 deletions

View File

@ -6,6 +6,7 @@ Portable script to update po files on most platforms
import argparse
from sys import stderr, exit
import shutil
from pathlib import Path
import polib
from polib import POFile
@ -34,6 +35,9 @@ def main():
return 1
for po_file in PO_FILE_LIST:
# Start by creating a back-up of the .po file
po_file_bak = po_file.with_suffix(".bak")
shutil.copy(PO_DIR / po_file, PO_DIR / po_file_bak)
po = polib.pofile(po_file)
po.merge(POT_REFERENCE)
po.save(po_file)