feat(translations): add hook to exclude translatable strings from dependencies #34544
+40
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for the
ignore_translatable_strings_fromhook that allows apps to exclude translatable strings from specified dependency apps when generating POT files. This prevents duplication of translations that already exist in parent/dependency apps.Problem
Custom apps frequently contain strings that already have translations in core apps (like Frappe or ERPNext). This creates unnecessary duplication in translation files and makes it harder to track which translations are actually needed for the custom app.
Impact:
Solution
This PR introduces a new hook that allows apps to specify which dependency apps' translations should be excluded from their POT generation:
Changes
Core functionality (
frappe/gettext/translate.py):_get_ignored_strings()helper function that builds a set of (message, context) tuples from specified apps' POT filesValueError)Developer experience (
frappe/utils/boilerplate.py):Technical Details
Testing
To test this feature:
ignore_translatable_strings_from = ["frappe"]to a custom app'shooks.pybench generate-pot-filefor the appDocumentation
Resolves #34541