nofx icon indicating copy to clipboard operation
nofx copied to clipboard

[FEATURE] Generate AI shot details using same language as user's FE language

Open xqliu opened this issue 1 year ago • 1 comments

[FEATURE] Generate AI shot details using same language as user's FE language

📋 Feature Description

When generating AI shot details (titles, descriptions, tags, etc.), the system should automatically detect and match the user's front-end display language instead of always generating in Chinese. This ensures a consistent and localized user experience across the entire application.

🎯 Problem to Solve

Currently, AI-generated shot details (titles, descriptions, tags, etc.) are always in Chinese, even when the user's front-end interface language is set to other languages (e.g., English, Japanese, etc.). This creates an inconsistent user experience where interface and generated content languages don't match.

Specific issues:

  • User interface is in English, but generated content is in Chinese
  • Users have to manually translate or edit generated content
  • Reduces the practical value of AI features for non-Chinese users
  • Creates cognitive load when switching between languages

💡 Proposed Solution

Implement language detection and matching mechanism:

  1. FE Language Detection: Get current language from user's FE language settings (e.g., zh-CN, ja-JP, en-US)
  2. Prompt Injection: Pass target language as part of system/user prompt when calling AI generation API
  3. Response Validation: Ensure AI returns content in the target language
  4. Fallback Strategy: If AI cannot generate in target language, fallback to English with user notification

Example prompt template:

Please generate shot details in {language_name} (language code: {language_code}). 
The user's interface language is {language_code}, so all generated content 
including title, description, and tags should be in {language_name}.

🔧 Technical Details

Implementation Points

  1. Language Code Mapping

    • Create mapping table from FE language codes to natural language names
    • Example: zh-CN → "Simplified Chinese", ja-JP → "Japanese", en-US → "English"
  2. API Modification Location

    • Locate current AI shot generation API call code
    • Modify prompt construction logic to inject language instruction
    • Potentially affected files: API route handlers, AI service wrappers, prompt templates
  3. State Management

    • Get current language setting from user context/settings
    • Ensure language setting is properly passed through API call chain
  4. Test Coverage

    • Write test cases for major supported languages (at least en, zh-CN, ja-JP)
    • Verify language correctness of generated content
    • Test fallback mechanism

Potential Challenges

  • AI model support quality may vary across languages
  • Need to consider mixed language scenarios (e.g., technical terms remain in English)
  • Token usage may vary by language

✅ Acceptance Criteria

  • [ ] System correctly detects user's FE language setting
  • [ ] AI-generated shot titles use user's FE language
  • [ ] AI-generated shot descriptions use user's FE language
  • [ ] AI-generated tags use user's FE language
  • [ ] Support at least: English, Simplified Chinese, Japanese
  • [ ] Clear fallback mechanism when AI cannot generate in target language
  • [ ] Unit tests and integration tests added
  • [ ] Related documentation updated
  • [ ] Manual testing passed under different language settings

📚 Additional Context

Related User Stories

  • As an English user, I want AI-generated content in English so I can use it directly without translation
  • As a Japanese user, I want the system to understand my language preference and generate content accordingly

Reference Implementations

Can reference how other AI applications handle multi-language generation, such as ChatGPT, Midjourney, etc.

Priority Recommendation

Suggest High Priority as this directly impacts core user experience for non-Chinese users.

xqliu avatar Nov 02 '25 01:11 xqliu

+1

x1Seven avatar Nov 02 '25 14:11 x1Seven