Skip to content

Add script for handling translations #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Oct 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Forbid initializing existent po
  • Loading branch information
rffontenelle committed Aug 2, 2024
commit adf715c41dec595f51de89d752c21511f5ad7a6d
8 changes: 6 additions & 2 deletions babel_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_project_info() -> dict:


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


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

Expand Down