# Fix: Handle whitespace-only translations properly#2382
Merged
sydseter merged 2 commits intoOWASP:masterfrom Feb 25, 2026
Merged
# Fix: Handle whitespace-only translations properly#2382sydseter merged 2 commits intoOWASP:masterfrom
sydseter merged 2 commits intoOWASP:masterfrom
Conversation
Fixes the translation checker to properly detect whitespace-only strings as empty translations. Changes: - Added .strip() check to properly detect whitespace-only strings - Added .strip() comparison to detect translations with extra spaces as untranslated - Added comprehensive unit tests for whitespace handling Fixes OWASP#2374
- Fix path calculation for test files in check_translations_utest.py - Tests now correctly locate test data in cornucopia/tests/test_files/source - No impact on production code, only test infrastructure
Contributor
Author
|
@sydseter i created a new PR now, because that was getting messy, :) |
sydseter
approved these changes
Feb 25, 2026
Collaborator
|
@khushal-winner Thank you for your contribution. |
Collaborator
|
@khushal-winner Add your name to the alphabetical https://github.com/OWASP/cornucopia/blob/master/cornucopia.owasp.org/data/website/pages/about/en/index.md#acknowledgements list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes the translation checker to properly detect whitespace-only strings as empty translations.
Fixes #2374
Problem
The
_check_translation_tags()method inscripts/check_translations.pywas not detecting whitespace-only translations (e.g.," ","\t \n") as empty because the checknot " "evaluates toFalsein Python.Current Behavior
Root Cause
Solution
Changes Made
1.
scripts/check_translations.pyAdded
.strip()check to properly detect whitespace-only strings:Before:
After:
2.
scripts/check_translations_utest.pyAdded
TestWhitespaceHandlingclass with 4 comprehensive unit tests:test_whitespace_only_detected_as_empty- Detects" "as emptytest_tabs_and_newlines_detected_as_empty- Detects"\t \n"as emptytest_extra_spaces_detected_as_untranslated- Detects" Login "as untranslatedtest_properly_translated_no_issues- Ensures valid translations still workTesting
New Test Suite
Results:
All Existing Tests Pass
All existing tests continue to pass without any modifications ✅
Test Coverage
The new tests cover:
"")" ")"\t \n ")" Login ")