[PR #23344] feat(i18n): enhance auto-gen script for template literals and add app-debug translations #30251

Closed
opened 2026-02-21 20:47:08 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/23344

State: closed
Merged: Yes


Summary

This PR enhances the i18n auto-generation script to handle template literals and adds missing translations for app-debug files across all supported languages.

Key Changes

  1. Enhanced Auto-Gen Script:

    • Added template literal detection and safe handling
    • Implemented preprocessing with placeholder replacement
    • Added restoration logic to preserve original template literals
    • Enabled translation of other keys while skipping problematic template literals
  2. Complete App-Debug Translations:

    • Added missing translations for all supported languages
    • Preserved template literals with placeholders ({{docLimit}}, {{imgLimit}})
    • Maintained consistent translation quality across all languages

Technical Details

  • Resolves AST parsing errors caused by template literals in resolutionTooltip keys
  • Uses regex pattern /(resolutionTooltip):\s*\([^`]*)`/g` for safe detection
  • Implements 4-phase process: detect → replace → skip → restore
  • All translations are linguistically accurate and contextually appropriate

Checklist

  • I understand that this PR may be closed in case there was no previous discussion or issues.
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/23344 **State:** closed **Merged:** Yes --- ## Summary This PR enhances the i18n auto-generation script to handle template literals and adds missing translations for app-debug files across all supported languages. ### Key Changes 1. **Enhanced Auto-Gen Script**: - Added template literal detection and safe handling - Implemented preprocessing with placeholder replacement - Added restoration logic to preserve original template literals - Enabled translation of other keys while skipping problematic template literals 2. **Complete App-Debug Translations**: - Added missing translations for all supported languages - Preserved template literals with placeholders ({{docLimit}}, {{imgLimit}}) - Maintained consistent translation quality across all languages ### Technical Details - Resolves AST parsing errors caused by template literals in `resolutionTooltip` keys - Uses regex pattern `/(resolutionTooltip):\s*\`([^\`]*)\`/g` for safe detection - Implements 4-phase process: detect → replace → skip → restore - All translations are linguistically accurate and contextually appropriate ## Checklist - [x] I understand that this PR may be closed in case there was no previous discussion or issues. - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:47:08 -05:00
yindo closed this issue 2026-02-21 20:47:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30251