-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7,363 changed files
with
228,596 additions
and
72,181 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from bs4 import BeautifulSoup | ||
import glob | ||
import os | ||
import sys | ||
|
||
def extract_includes(file_path): | ||
includes = set() | ||
with open(file_path, 'r') as f: | ||
soup = BeautifulSoup(f, 'html.parser') | ||
includes_elements = soup.find_all(string=lambda text: '[[texts/' in text) | ||
for include in includes_elements: | ||
includes.add(include.strip()) | ||
return includes | ||
|
||
def main(): | ||
# Get list of English HTML files | ||
en_files = glob.glob('lang/en/texts/**/*.html', recursive=True) | ||
|
||
all_good = True | ||
|
||
# Get list of all language directories | ||
lang_dirs = glob.glob('lang/*/') | ||
|
||
for en_file_path in en_files: | ||
# Extract the original includes from the English version | ||
original_includes = extract_includes(en_file_path) | ||
|
||
for lang_dir in lang_dirs: | ||
lang = os.path.basename(os.path.normpath(lang_dir)) | ||
|
||
# Skip the English directory | ||
if lang == 'en': | ||
continue | ||
|
||
# Generate the corresponding path for the translated version | ||
translated_file_path = en_file_path.replace('lang/en/', f'lang/{lang}/') | ||
|
||
# Skip if the translated file does not exist | ||
if not os.path.exists(translated_file_path): | ||
print(f"Warning: Translated file does not exist for language '{lang}' - {translated_file_path}") | ||
continue | ||
|
||
# Extract includes from the translated version | ||
translated_includes = extract_includes(translated_file_path) | ||
|
||
# Check if original includes are preserved in the translated version | ||
for original_include in original_includes: | ||
if original_include not in translated_includes: | ||
print(f"Error: Missing include in language '{lang}', file {translated_file_path}: {original_include}") | ||
all_good = False | ||
|
||
if not all_good: | ||
print("Error: Missing includes found in one or more files across languages.") | ||
sys.exit(1) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Check Includes in HTML Templates | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'impossiblecondition**.html' | ||
pull_request: | ||
paths: | ||
- 'impossiblecondition**.html' | ||
|
||
jobs: | ||
check-includes: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install Dependencies | ||
run: pip install beautifulsoup4 | ||
|
||
- name: Check for Translated Includes | ||
run: python .github/scripts/check_includes.py |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Check Forbidden Strings in index.html | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'lang/**/texts/index.html' | ||
pull_request: | ||
paths: | ||
- 'lang/**/texts/index.html' | ||
|
||
jobs: | ||
check_strings: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install prerequisites | ||
run: sudo apt-get install -y grep | ||
|
||
- name: Check for forbidden strings | ||
run: | | ||
FORBIDDEN_STRINGS=("Open Pet Food Facts" "Open Beauty Facts" "Open Products Facts") | ||
FILES=$(find ./lang/ -name 'index.html' -path '*/texts/*') | ||
for file in $FILES; do | ||
for string in "${FORBIDDEN_STRINGS[@]}"; do | ||
if grep -q "$string" "$file"; then | ||
echo "Error: '$string' found in $file" | ||
exit 1 | ||
fi | ||
done | ||
done | ||
echo "No forbidden strings found." |
This file contains 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
This file contains 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
Oops, something went wrong.