Repository navigation
feat(i18n): support word-count stats localization - #1781
Conversation
|
🚀 Cloudflare Workers Preview has been successfully deployed! Preview URL: https://md-pr-1781.doocs.workers.dev Built with commit 0d22641 |
|
🚀 Surge Preview has been successfully deployed! Preview URL: https://doocs-md-preview-pr-1781.surge.sh Built with commit 0d22641 |
There was a problem hiding this comment.
Pull request overview
This PR adds localization support for the “word count / estimated reading time” summary by letting the Web app inject locale-specific message templates into the core renderer, and ensuring the editor preview re-renders when the locale changes.
Changes:
- Extend shared renderer options (
IOpts) withcountMessages.summaryto carry localized templates. - Update the core renderer to format the reading-time block using the injected template (with
{words}/{minutes}placeholders). - Add i18n message keys for zh-CN and en-US and ensure the editor refreshes on locale changes so the preview updates.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/shared/src/types/common.ts | Adds CountMessages and exposes countMessages on renderer options for localization injection. |
| packages/core/src/renderer/renderer-impl.ts | Uses countMessages.summary to format the word-count/reading-time block (placeholder substitution). |
| apps/web/src/stores/render.ts | Injects localized countMessages.summary from i18n into the core renderer options. |
| apps/web/src/i18n/messages/zh-CN/store.ts | Adds zh-CN translation for the count summary template. |
| apps/web/src/i18n/messages/en-US/store.ts | Adds en-US translation for the count summary template. |
| apps/web/src/components/editor/EditorPanel.vue | Refreshes the editor/preview on locale changes so localized output is reflected immediately. |
| function formatCountSummary(words: number, minutes: number): string { | ||
| const template = opts.countMessages?.summary || DEFAULT_COUNT_SUMMARY | ||
| return template | ||
| .split(`{words}`) | ||
| .join(String(words)) | ||
| .split(`{minutes}`) | ||
| .join(String(minutes)) | ||
| } |
| function formatCountSummary(words: number, minutes: number): string { | ||
| const template = opts.countMessages?.summary || DEFAULT_COUNT_SUMMARY | ||
| return template |
|
🗑️ Cloudflare Workers preview deployment has been cleaned up. |
支持「字数统计」国际化