Skip to content

feat(i18n): support word-count stats localization - #1781

Merged
yanglbme merged 1 commit into
mainfrom
feat/i18n-word-count-localization
Jul 10, 2026
Merged

yanglbme merged 1 commit into
mainfrom
feat/i18n-word-count-localization

Conversation

@YangFong

Copy link
Copy Markdown
Member

支持「字数统计」国际化

Copilot AI review requested due to automatic review settings July 10, 2026 18:34
@github-actions

Copy link
Copy Markdown

🚀 Cloudflare Workers Preview has been successfully deployed!

Preview URL: https://md-pr-1781.doocs.workers.dev

Built with commit 0d22641

@github-actions

Copy link
Copy Markdown

🚀 Surge Preview has been successfully deployed!

Preview URL: https://doocs-md-preview-pr-1781.surge.sh

Built with commit 0d22641

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) with countMessages.summary to 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.

Comment on lines +241 to +248
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))
}
Comment on lines +241 to +243
function formatCountSummary(words: number, minutes: number): string {
const template = opts.countMessages?.summary || DEFAULT_COUNT_SUMMARY
return template
@yanglbme
yanglbme merged commit 723a542 into main Jul 10, 2026
6 checks passed
@yanglbme
yanglbme deleted the feat/i18n-word-count-localization branch July 10, 2026 23:54
@github-actions

Copy link
Copy Markdown

🗑️ Cloudflare Workers preview deployment has been cleaned up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants