Skip to content

Commit 4d88b7e

Browse files
committed
added docstring in po to json converter
1 parent 13b94b9 commit 4d88b7e

File tree

3 files changed

+12
-14952
lines changed

3 files changed

+12
-14952
lines changed

convert_po_to_json.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
"""
2+
This script converts GNU gettext .po translation files into JSON format.
3+
It extracts only `msgid` and `msgstr` pairs, skipping metadata and comments,
4+
and writes them to language-specific .json files for use in localization.
5+
6+
Usage:
7+
- Place .po files inside a directory (e.g., ./po)
8+
- The script will convert all .po files in that directory into .json
9+
and save them to the specified output directory (e.g., ./locales)
10+
"""
11+
112
import os
213
import json
314
import re
@@ -39,4 +50,4 @@ def convert_all_po_files(po_dir, output_dir):
3950
if file.endswith(".po"):
4051
convert_po_to_json(os.path.join(root, file), output_dir)
4152

42-
convert_all_po_files("./po_old", "./locales")
53+
convert_all_po_files("./po", "./locales")

0 commit comments

Comments
 (0)