diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 4b8ce6e..3e90c67 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -34,6 +34,13 @@ language: python require_serial: true +- id: add_translations + name: add_translations + description: "Get untranslated strings in app and translate them to the language specified" + entry: add_translations + language: python + require_serial: true + - id: update_pre_commit_config name: update_pre_commit_config description: "Update test_utils pre-commit config to latest" @@ -62,4 +69,4 @@ description: "Get untranslated strings in app and translate them to the language specified" entry: add_translations language: python - require_serial: true \ No newline at end of file + require_serial: true diff --git a/pyproject.toml b/pyproject.toml index 21951c9..3ca5881 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ validate_copyright = "test_utils.pre_commit.validate_copyright:main" validate_customizations = "test_utils.pre_commit.validate_customizations:main" validate_javascript_dependencies = "test_utils.pre_commit.validate_javascript_dependencies:main" validate_python_dependencies = "test_utils.pre_commit.validate_python_dependencies:main" +validate_customizations = "test_utils.pre_commit.validate_customizations:main" add_translations = "test_utils.pre_commit.add_translations:main" [build-system] @@ -38,4 +39,4 @@ skip = "CHANGELOG.md" [tool.semantic_release] version_toml = ["pyproject.toml:tool.poetry.version"] -version_variable = ["__init__.py:__version__"] \ No newline at end of file +version_variable = ["__init__.py:__version__"] diff --git a/test_utils/pre_commit/add_translations.py b/test_utils/pre_commit/add_translations.py index 953356b..3bc41f7 100644 --- a/test_utils/pre_commit/add_translations.py +++ b/test_utils/pre_commit/add_translations.py @@ -1,23 +1,16 @@ import argparse import sys +from typing import Sequence from collections.abc import Sequence def is_frappe_environment(): - """ - Check if the current environment is a Frappe environment. - - Returns: - bool: True if Frappe is available, False otherwise - """ try: import frappe - return True except ImportError: return False - def add_translations(lang, app): try: from frappe.translate import get_untranslated, update_translations @@ -36,7 +29,6 @@ def add_translations(lang, app): print(f"An error occurred while translating for lang '{lang}' and app '{app}': {e}") sys.exit(1) - def main(argv: Sequence[str] = None): parser = argparse.ArgumentParser() parser.add_argument("filenames", nargs="*")