import os import sys # Add parent directory to path to import shared modules sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from visual_qc_apps.flask_app_template import FlaskAppTemplate class LanguageConsistencyApp(FlaskAppTemplate): """ Language Consistency Check - Detects mixed languages in marketing materials """ def __init__(self): # Define the hardcoded prompt prompt = """You are performing a visual quality control check on a marketing material or advertisement. Your task is to verify that all MARKETING TEXT uses a single, consistent language throughout the creative. CRITICAL: Focus on MARKETING/ADVERTISING TEXT (headlines, slogans, body copy). Text on product packaging, labels, or bottles shown in product photography is NOT evaluated - this is part of the product itself and may naturally be in different languages. EVALUATION STEPS: 1. Identify all readable MARKETING text in the image: a. Headlines and main copy b. Body text and descriptions c. Call-to-action text d. Promotional messaging e. Slogans and taglines (EXCLUDE: Brand names, product names, legal disclaimers, trademarked terms, AND text on product packaging/labels) 2. Analyze the language of each marketing text element: a. Identify the primary language used in the marketing message b. Check for any marketing text elements in different languages c. Pay special attention to: - Mixed language headings (e.g., German header with English subtext) - Overlapping text in multiple languages - Language switches within the same sentence or paragraph in marketing copy d. IGNORE: Text printed on product packaging, bottles, or labels (this is part of the product photography) 3. Determine language consistency: a. "PASS" if all MARKETING text uses a single language consistently b. "FAIL" if multiple languages are detected in the MARKETING/ADVERTISING copy c. If there is NO marketing text (only product photography with packaging text), state "No marketing text found" 4. Special cases to EXCLUDE from evaluation: a. Brand names and product names (e.g., "L'Oréal", "Schwarzkopf") b. Legal text and disclaimers c. Trademarked terms d. Text on product packaging, bottles, or labels visible in product photos e. Regional variations of the same language (e.g., US English vs UK English) count as consistent DECISION CRITERIA: • Pass: All user-facing MARKETING text is in one language (excluding brand names, legal text, and product packaging text) • Fail: Two or more languages are mixed in headlines, body copy, or key marketing messaging • The goal is to ensure market-appropriate, single-language marketing messages for each region YOUR OUTPUT MUST INCLUDE: • Detailed explanation of what marketing text was found and analyzed • Clear identification of which languages were detected WHERE • Distinction between marketing text and product packaging text • Specific examples of mixed language if found Format your response as JSON: { "language_consistency": "Pass" or "Fail", "primary_language": "Name of primary language used in marketing text", "languages_detected": ["Language 1", "Language 2", ...], "analysis_details": "Detailed explanation: What marketing text was checked, what languages were found, and where they appear. If no marketing text exists, state that clearly.", "marketing_text_found": ["List the actual marketing text you analyzed, e.g., 'Headline: Get Soft Hair', 'CTA: Buy Now'"], "mixed_language_locations": ["Specific locations where different languages appear, e.g., 'Headline in German, body text in English'"] (only if multiple languages), "recommendation": "Brief recommendation if failed, or 'None' if passed" } CRITICAL: 1. Always provide detailed analysis_details explaining what was checked and found 2. Focus ONLY on marketing text, NOT product packaging text 3. List specific examples of the marketing text you analyzed 4. If no marketing text exists in the image, clearly state this 5. Never return just "Pass" or "Fail" without comprehensive explanation""" # Initialize the Flask app with the prompt super().__init__(__name__, prompt) # Run the app if executed directly if __name__ == "__main__": app_instance = LanguageConsistencyApp() app_instance.run()