Skip to content

Commit 7a97988

Browse files
committed
i18n: match and merge po translations: remove use of python datargs lib
1 parent 221699c commit 7a97988

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

i18n/match_and_merge_po_translations.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
"""Parse .pot and .po files with different string splits and matches already
22
translated strings."""
3+
import argparse
34
from dataclasses import dataclass
45
from enum import Enum
56
import os
67
import re
7-
from datargs import parse, arg
8-
from typing import Sequence
98

109

11-
@dataclass
12-
class Args:
13-
"""Command-line arguments."""
1410

15-
files: Sequence[str] = arg(
16-
positional=True,
17-
default=tuple(),
11+
def get_args():
12+
"""Parse command-line arguments."""
13+
parser = argparse.ArgumentParser(
14+
description="Parse .pot and .po files with different string splits and matches already translated strings."
15+
)
16+
parser.add_argument(
17+
"files",
18+
nargs="*",
19+
default=[],
1820
help="List of paths to .po or .pot files to parse.",
1921
)
20-
output_directory: str = arg(
22+
parser.add_argument(
23+
"--output-directory",
2124
default="dist",
2225
help="Directory to write .po files to.",
2326
)
27+
return parser.parse_args()
2428

2529

2630
class PropertyType(Enum):
@@ -167,7 +171,7 @@ def split_translations(po_files: list[PoFile]):
167171

168172

169173
def main():
170-
args = parse(Args)
174+
args = get_args()
171175
for f in args.files:
172176
assert os.path.exists(f)
173177

0 commit comments

Comments
 (0)