Celestia

Форк
0
/
merge.py 
44 строки · 1.3 Кб
1
"""Handle the merge command."""
2

3
# Copyright © 2023, the Celestia Development Team
4
# Original version by Andrew Tribick, December 2023
5
#
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.
10

11
from __future__ import annotations
12

13
import glob
14
import os
15
import re
16
import subprocess  # nosec B404
17
from typing import Union
18

19
from .utilities import exe_path
20

21
_LOCALE_PATTERN = re.compile(r"^[a-z]{2}(?:_[A-Z]{2})?$")
22

23

24
def merge_po(
25
    gettext_dir: Union[str, os.PathLike], po_dir: Union[str, os.PathLike]
26
) -> None:
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]):
33
            continue
34
        print(f"Processing {basename}")
35
        subprocess.run(  # nosec B603
36
            [
37
                msgmerge,
38
                "--update",
39
                "--quiet",
40
                po_file,
41
                pot_file,
42
            ],
43
            check=True,
44
        )
45

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.