Skip to content

Commit adf715c

Browse files
committed
Forbid initializing existent po
1 parent a809821 commit adf715c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

babel_runner.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_project_info() -> dict:
2929

3030

3131
def extract_messages():
32-
"""Extract messages from all source files into template file"""
32+
"""Extract messages from all source files into message catalog template"""
3333
os.makedirs(LOCALES_DIR, exist_ok=True)
3434
project_data = get_project_info()
3535
subprocess.run(
@@ -55,7 +55,11 @@ def extract_messages():
5555

5656

5757
def init_locale(locale: str):
58-
"""Initialize a new locale based on existing"""
58+
"""Initialize a new locale based on existing message catalog template"""
59+
pofile = os.path.join(LOCALES_DIR, locale, "LC_MESSAGES", f"{DOMAIN}.po")
60+
if os.path.exists(pofile):
61+
print(f"There is already a message catalog for locale {locale}, skipping.")
62+
return
5963
cmd = ["pybabel", "init", "-i", POT_FILE, "-d", LOCALES_DIR, "-l", locale]
6064
subprocess.run(cmd, check=True)
6165

0 commit comments

Comments
 (0)