1
"""Handle the merge command."""
3
# Copyright © 2023, the Celestia Development Team
4
# Original version by Andrew Tribick, December 2023
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
11
from __future__ import annotations
16
import subprocess # nosec B404
17
from typing import Union
19
from .utilities import exe_path
21
_LOCALE_PATTERN = re.compile(r"^[a-z]{2}(?:_[A-Z]{2})?$")
25
gettext_dir: Union[str, os.PathLike], po_dir: Union[str, os.PathLike]
27
"""Merges the po files"""
28
msgmerge = exe_path(gettext_dir, "msgmerge")
29
pot_file = os.path.join(po_dir, "celestia.pot")
30
for po_file in glob.glob(os.path.join(po_dir, "*.po")):
31
basename = os.path.basename(po_file)
32
if not _LOCALE_PATTERN.match(os.path.splitext(basename)[0]):
34
print(f"Processing {basename}")
35
subprocess.run( # nosec B603