fix: 🐛 修复部分国际化文本不正确的问题#970
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough该 PR 对翻译逻辑和分页文本格式进行了修改。在 Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as 调用者
participant Translate as translate()
Note over Translate: 检查 message 类型及定义情况
Caller->>Translate: 调用 translate(key, args)
alt message 为函数
Translate-->>Caller: 返回 message(args) 的结果
else message 非函数
Translate-->>Translate: 调用 isDef(message)
alt message 定义
Translate-->>Caller: 返回 message
else 未定义
Translate-->>Caller: 返回 `${prefix}${key}` 备选字符串
end
end
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🧰 Additional context used🧬 Code Definitions (1)src/uni_modules/wot-design-uni/components/composables/useTranslate.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (4)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 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 (
|
✅ Deploy Preview for wot-design-uni ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Walkthrough修复了部分国际化文本不正确的问题,主要涉及翻译功能的改进和国际化文本格式的调整。 Changes
|
| const currentMessages = Locale.messages() | ||
| const message = getPropByPath(currentMessages, prefix + key) | ||
| return isFunction(message) ? message(...args) : message | ||
| return isFunction(message) ? message(...args) : isDef(message) ? message : `${prefix}${key}` |
There was a problem hiding this comment.
The change in the useTranslate function introduces a fallback mechanism for undefined messages, which is a good improvement for handling missing translations. This ensures that the application does not break and provides a clear indication of missing keys.
Deploying wot-design-uni with
|
| Latest commit: |
0234e9c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ac84a0db.wot-design-uni.pages.dev |
| Branch Preview URL: | https://fix-locale-text-error.wot-design-uni.pages.dev |
🤔 这个 PR 的性质是?(至少选择一个)
🔗 相关 Issue
💡 需求背景和解决方案
修复部分国际化文本不正确的问题
☑️ 请求合并前的自查清单
Summary by CodeRabbit