Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
require_serial: true
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -38,4 +39,4 @@ skip = "CHANGELOG.md"

[tool.semantic_release]
version_toml = ["pyproject.toml:tool.poetry.version"]
version_variable = ["__init__.py:__version__"]
version_variable = ["__init__.py:__version__"]
10 changes: 1 addition & 9 deletions test_utils/pre_commit/add_translations.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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="*")
Expand Down
Loading