File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""Parse .pot and .po files with different string splits and matches already
22translated strings."""
3+ import argparse
34from dataclasses import dataclass
45from enum import Enum
56import os
67import 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
2630class PropertyType (Enum ):
@@ -167,7 +171,7 @@ def split_translations(po_files: list[PoFile]):
167171
168172
169173def main ():
170- args = parse ( Args )
174+ args = get_args ( )
171175 for f in args .files :
172176 assert os .path .exists (f )
173177
You can’t perform that action at this time.
0 commit comments