-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: preview compatibility i18n is null #910
Conversation
WalkthroughThe changes introduce a new function Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
packages/design-core/src/preview/src/preview/generate.js (1)
137-142
: Consider enhancing i18n error handling architectureWhile the current fix addresses the immediate null value issue, consider these architectural improvements:
- Add runtime validation for i18n access
- Implement error boundaries for i18n failures
- Consider adding a development-time warning when accessing undefined translations
Would you like me to propose a more comprehensive i18n handling architecture?
Also applies to: 155-155
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
packages/design-core/src/preview/src/preview/generate.js
(2 hunks)
🔇 Additional comments (1)
packages/design-core/src/preview/src/preview/generate.js (1)
155-155
: Verify complete coverage of i18n compatibility fix
The fix looks good but let's ensure it covers all preview scenarios.
Let's check for other i18n processing locations:
✅ Verification successful
The i18n compatibility fix is correctly implemented and complete
The verification shows that the i18n handling is comprehensive and well-structured:
- The
compatibleI18n
function ingenerate.js
ensures default objects for bothen_US
andzh_CN
locales - The i18n integration is properly handled in the preview system:
- App.vue initializes i18n with proper locale management
- lowcode.js correctly injects and provides i18n functionality
- The generated locales are properly exported through
generateDefaultExport
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other i18n related code in preview functionality
rg -l "i18n" packages/design-core/src/preview/
# Search for potential preview rendering code that might access i18n
ast-grep --pattern 'i18n.$$$' packages/design-core/src/preview/
Length of output: 755
Script:
#!/bin/bash
# Let's examine the content of these files to understand i18n usage
echo "=== lowcode.js ==="
cat packages/design-core/src/preview/src/preview/srcFiles/lowcode.js
echo -e "\n=== injectGlobal.js ==="
cat packages/design-core/src/preview/src/preview/srcFiles/injectGlobal.js
echo -e "\n=== App.vue ==="
cat packages/design-core/src/preview/src/preview/srcFiles/App.vue
# Check if compatibleI18n is used consistently
ast-grep --pattern 'compatibleI18n($$$)'
Length of output: 5056
Script:
#!/bin/bash
# Let's check the implementation of compatibleI18n and generateDefaultExport
echo "=== generate.js relevant sections ==="
rg -A 10 "function compatibleI18n|function generateDefaultExport" packages/design-core/src/preview/src/preview/generate.js
# Check how i18n is initialized and used in the preview
echo -e "\n=== constant.js I18N mappings ==="
cat packages/design-core/src/preview/src/preview/constant.js
Length of output: 444
Script:
#!/bin/bash
# Let's try to find and examine the generate.js file content
echo "=== generate.js content ==="
cat packages/design-core/src/preview/src/preview/generate.js
# Also check for any constants file with different extensions
echo -e "\n=== Looking for constants file ==="
fd "constant" packages/design-core/src/preview/
Length of output: 4978
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
Bug Fixes
i18n
object to prevent issues with undefined properties.