From ea59d128bfd627c8b248eecb77ebb70eaa75e330 Mon Sep 17 00:00:00 2001 From: Benjamin Lu Date: Wed, 14 Oct 2026 17:35:29 -0700 Subject: [PATCH] refactor(website): render link sentences and hero highlights as complete messages Sentences that wrapped a link or a styled count were translated as a prefix and a suffix around it, so each locale had to break where English did. Each is now one message with a {link}, {email}, {models} or {highlight} placeholder rendered through I18nT slots: the get-started step, the HubSpot load error, the CLI and MCP setup requirements, the CLI key, docs and skills lines, the sign-in free-runs prompt and the router coverage footer. The CLI and MCP requirement footnotes fold into their sentence instead of being appended with a leading space. HeroSplit01 takes its title as a slot instead of a titleHighlight prop, and the affiliate and cloud-nodes heroes render the I18nT there. zh-CN and ja copy is joined from the old fragments under new keys, and the README convention now covers links. --- apps/website/README.md | 9 +- apps/website/e2e/affiliates.spec.ts | 6 +- .../src/components/auth/AuthSignIn.test.ts | 11 ++- .../src/components/auth/AuthSignInPanel.vue | 33 ++++--- .../components/blocks/HeroSplit01.stories.ts | 18 +++- .../src/components/blocks/HeroSplit01.vue | 10 +- .../common/HubspotFormEmbed.test.ts | 9 +- .../components/common/HubspotFormEmbed.vue | 21 ++-- .../src/components/home/GetStartedSection.vue | 19 ++-- .../components/interpolatedHeadings.test.ts | 39 +++++++- .../src/components/interpolatedLinks.test.ts | 97 +++++++++++++++++++ apps/website/src/locales/en/main.json | 42 +++----- apps/website/src/locales/ja/main.json | 40 +++----- apps/website/src/locales/zh-CN/main.json | 40 +++----- .../src/templates/affiliate/HeroSection.vue | 15 ++- .../src/templates/cli/SetupSection.test.ts | 29 +++++- .../src/templates/cli/SetupSection.vue | 81 ++++++++++------ .../src/templates/cli/SkillsSection.vue | 20 ++-- .../src/templates/cloud-nodes/HeroSection.vue | 18 +++- .../src/templates/cloud-nodes/copy.test.ts | 2 +- .../src/templates/mcp/SetupSection.vue | 42 +++++--- .../RouterProviderCoverageSection.test.ts | 13 +++ .../RouterProviderCoverageSection.vue | 15 ++- apps/website/src/test/wholeText.ts | 7 ++ 24 files changed, 445 insertions(+), 191 deletions(-) create mode 100644 apps/website/src/components/interpolatedLinks.test.ts create mode 100644 apps/website/src/test/wholeText.ts diff --git a/apps/website/README.md b/apps/website/README.md index 88b37921778..8354c83b717 100644 --- a/apps/website/README.md +++ b/apps/website/README.md @@ -46,10 +46,11 @@ as the application's `src/locales/` at the repository root: `t('workshop.search.show', { n }, { locale })`. - Plural forms separated by `|`: `"{count} node | {count} nodes"`, picked with `t('cloudNodesLaunch.models.nodeCount', { count }, { locale, plural: count })`. -- Styled words inside a sentence are a named placeholder, never a message - split around them: `"Built for {highlight} who need quality."`, rendered with - `` and a `#highlight` - slot, so each locale decides where the styled word sits. +- Styled words or links inside a sentence are a named placeholder, never a + message split around them: `"Built for {highlight} who need quality."` or + `"Start from {link} or build your own."`, rendered with + `` and a `#highlight` or + `#link` slot, so each locale decides where the styled word or link sits. - The characters `{`, `}`, `@` and `|` are message syntax, so literal ones are written as `{'{'}`, `{'}'}`, `{'@'}` and `{'|'}`. diff --git a/apps/website/e2e/affiliates.spec.ts b/apps/website/e2e/affiliates.spec.ts index 119911b09a5..2b8d0316098 100644 --- a/apps/website/e2e/affiliates.spec.ts +++ b/apps/website/e2e/affiliates.spec.ts @@ -10,7 +10,11 @@ const APPLY_URL = 'https://forms.gle/RS8L2ttcuGap4Q1v6' const TERMS_PATH = '/affiliates/terms/' const FAQ_COUNT = affiliateFaqs.length const FIRST_FAQ = affiliateFaqs[0] -const HERO_HEADING_TEXT = `${t('affiliate.hero.headingHighlight', {}, { locale: 'en' })} ${t('affiliate.hero.headingMuted', {}, { locale: 'en' })}` +const HERO_HEADING_TEXT = t( + 'affiliate.hero.headline', + { highlight: t('affiliate.hero.headingHighlight', {}, { locale: 'en' }) }, + { locale: 'en' } +) const CTA_HEADING_TEXT = t('affiliate.cta.heading', {}, { locale: 'en' }) const CTA_APPLY_LABEL = t('affiliate.cta.apply', {}, { locale: 'en' }) const CTA_TERMS_LABEL = t('affiliate.cta.termsLabel', {}, { locale: 'en' }) diff --git a/apps/website/src/components/auth/AuthSignIn.test.ts b/apps/website/src/components/auth/AuthSignIn.test.ts index 6cf16c6fc67..895e06dc2e8 100644 --- a/apps/website/src/components/auth/AuthSignIn.test.ts +++ b/apps/website/src/components/auth/AuthSignIn.test.ts @@ -1,4 +1,4 @@ -import { render, screen, waitFor } from '@testing-library/vue' +import { render, screen, waitFor, within } from '@testing-library/vue' import userEvent from '@testing-library/user-event' import { beforeEach, describe, expect, it, vi } from 'vitest' import { computed, readonly, ref } from 'vue' @@ -41,6 +41,7 @@ import { useWorkshopAuthFlag, useWorkshopTurnstileMode } from '@/scripts/posthog' +import { wholeText } from '@/test/wholeText' import AuthSignIn from './AuthSignIn.vue' import AuthToast from './AuthToast.vue' @@ -737,7 +738,13 @@ describe('AuthSignIn', () => { it('advertises the free runs on the login page, as the cloud app does', () => { render(AuthSignIn) - expect(screen.getByText('to get 5 free runs.')).toBeTruthy() + const prompt = screen.getByText( + wholeText('New to Comfy? Sign up here to get 5 free runs.'), + { selector: 'p' } + ) + expect( + within(prompt).getByRole('link', { name: 'Sign up here' }) + ).toBeInTheDocument() }) it('holds the form until Firebase has settled, then shows it to a signed-out visitor', async () => { diff --git a/apps/website/src/components/auth/AuthSignInPanel.vue b/apps/website/src/components/auth/AuthSignInPanel.vue index aa5dde5c977..b0e8f10e4e8 100644 --- a/apps/website/src/components/auth/AuthSignInPanel.vue +++ b/apps/website/src/components/auth/AuthSignInPanel.vue @@ -6,6 +6,7 @@ import { cn } from '@comfyorg/tailwind-utils' import type { Locale } from '@/i18n/translations' import { translationsFor } from '@/i18n/translations' +import { I18nT } from 'vue-i18n' import AuthEmailForm from './AuthEmailForm.vue' import AuthFlagTimeout from './AuthFlagTimeout.vue' import AuthSpinnerIcon from './AuthSpinnerIcon.vue' @@ -88,20 +89,26 @@ const {

diff --git a/apps/website/src/components/blocks/HeroSplit01.stories.ts b/apps/website/src/components/blocks/HeroSplit01.stories.ts index 8f6e3813bc2..549a065e5cc 100644 --- a/apps/website/src/components/blocks/HeroSplit01.stories.ts +++ b/apps/website/src/components/blocks/HeroSplit01.stories.ts @@ -38,8 +38,7 @@ const meta: Meta = { }, args: { badgeText: 'DESKTOP', - titleHighlight: 'Professional control.', - title: ' Run ComfyUI on your own machine.', + title: 'Professional control. Run ComfyUI on your own machine.', subtitle: 'Build, iterate, and run visual AI workflows with complete local control.', features: [ @@ -72,6 +71,21 @@ export const ImageLeft: Story = { } } +export const HighlightedTitle: Story = { + render: (args) => ({ + components: { HeroSplit01 }, + setup: () => ({ args }), + template: ` + + + + ` + }) +} + export const Mobile: Story = { globals: { viewport: { value: 'mobile1', isRotated: false } diff --git a/apps/website/src/components/blocks/HeroSplit01.vue b/apps/website/src/components/blocks/HeroSplit01.vue index 086b722a142..6a11fec5d46 100644 --- a/apps/website/src/components/blocks/HeroSplit01.vue +++ b/apps/website/src/components/blocks/HeroSplit01.vue @@ -32,7 +32,6 @@ const { badgeShowLogo = true, title, titleClass, - titleHighlight, subtitle, subtitleClass, mediaWrapperClass, @@ -64,9 +63,8 @@ const { badgeLogoSrc?: string badgeLogoAlt?: string badgeShowLogo?: boolean - title: string + title?: string titleClass?: HTMLAttributes['class'] - titleHighlight?: string subtitle?: string subtitleClass?: HTMLAttributes['class'] mediaWrapperClass?: HTMLAttributes['class'] @@ -130,11 +128,7 @@ const { t } = translationsFor(locale) ) " > - - + {{ title }}

{ await nextTick() expect(screen.queryByTestId('hubspot-form-embed')).toBeNull() - expect(screen.getByRole('status').textContent).toContain( - 'Unable to load the form' + const status = screen.getByRole('status') + expect(status).toHaveTextContent( + "Unable to load the form. Email us at hello@comfy.org and we'll route your request." ) - expect(screen.getByRole('link').getAttribute('href')).toBe( + expect(within(status).getByRole('link').getAttribute('href')).toBe( 'mailto:hello@comfy.org' ) }) diff --git a/apps/website/src/components/common/HubspotFormEmbed.vue b/apps/website/src/components/common/HubspotFormEmbed.vue index 686179fcfd7..68b2a062d57 100644 --- a/apps/website/src/components/common/HubspotFormEmbed.vue +++ b/apps/website/src/components/common/HubspotFormEmbed.vue @@ -4,12 +4,12 @@ import { onMounted, ref } from 'vue' import type { Locale } from '@/i18n/translations' import { translationsFor } from '@/i18n/translations' +import { I18nT } from 'vue-i18n' const { formId, locale = 'en' } = defineProps<{ formId: string locale?: Locale }>() -const { t } = translationsFor(locale) const HUBSPOT_PORTAL_ID = '244637579' const HUBSPOT_REGION = 'na2' @@ -132,14 +132,19 @@ onMounted(() => { class="text-sm/6 text-primary-comfy-canvas" role="status" > - {{ t('hubspotForm.embedLoadErrorPrefix') }} - - hello@comfy.org - - {{ t('hubspotForm.embedLoadErrorSuffix') }} + +

() const { t } = translationsFor(locale) @@ -80,12 +81,18 @@ const steps = [ v-else-if="step.number === '2'" class="flex-1 text-sm text-primary-comfy-canvas" > - {{ t('getStarted.step2.descriptionPrefix') - }}{{ t('getStarted.step2.descriptionLink') }}{{ t('getStarted.step2.descriptionSuffix') }} + + +

@@ -337,14 +349,20 @@ const copiedLabel = t('ui.copied') v-if="activeClientFor(connId).shell?.showKeyLink" class="mt-6 text-sm text-smoke-700" > - {{ t('cli.setup.shell.ci.keyLinkPrefix') - }}{{ t('cli.setup.shell.ci.keyLinkLabel') }} + +

@@ -358,14 +376,17 @@ const copiedLabel = t('ui.copied') {{ t('cli.setup.betaNote') }}

- {{ t('cli.setup.docsPrefix') - }}{{ t('cli.setup.docsLinkLabel') }}{{ t('cli.setup.docsSuffix') }} + + +

diff --git a/apps/website/src/templates/cli/SkillsSection.vue b/apps/website/src/templates/cli/SkillsSection.vue index ce4676e8d87..f0d35022819 100644 --- a/apps/website/src/templates/cli/SkillsSection.vue +++ b/apps/website/src/templates/cli/SkillsSection.vue @@ -4,6 +4,7 @@ import CopyableField from '@/components/ui/copyable-field/CopyableField.vue' import { externalLinks } from '@/config/routes' import type { Locale, TranslationKey } from '@/i18n/translations' import { translationsFor } from '@/i18n/translations' +import { I18nT } from 'vue-i18n' const { locale = 'en' } = defineProps<{ locale?: Locale }>() const { t } = translationsFor(locale) @@ -135,14 +136,17 @@ const copiedLabel = t('ui.copied')

- {{ t('cli.skills.moreSkillsPrefix') - }}{{ t('cli.skills.moreSkillsLinkLabel') }}{{ t('cli.skills.moreSkillsSuffix') }} + + +

diff --git a/apps/website/src/templates/cloud-nodes/HeroSection.vue b/apps/website/src/templates/cloud-nodes/HeroSection.vue index 0fcd5cbd9a9..22055540cea 100644 --- a/apps/website/src/templates/cloud-nodes/HeroSection.vue +++ b/apps/website/src/templates/cloud-nodes/HeroSection.vue @@ -2,6 +2,7 @@ import HeroSplit01 from '@/components/blocks/HeroSplit01.vue' import type { Locale } from '@/i18n/translations' import { translationsFor } from '@/i18n/translations' +import { I18nT } from 'vue-i18n' import { cloudNodesCtas } from './ctas' const { locale = 'en' } = defineProps<{ locale?: Locale }>() @@ -25,8 +26,6 @@ const features = featureNumbers.map((n) => class="min-h-[calc(100svh-5rem)] lg:min-h-[calc(100svh-6.75rem)]" badge-text="CLOUD NODES" beta - :title="t('cloudNodesLaunch.hero.title')" - :title-highlight="t('cloudNodesLaunch.hero.titleHighlight')" :subtitle="t('cloudNodesLaunch.hero.subtitle')" :features="features" :primary-cta="ctas.getStarted" @@ -37,5 +36,18 @@ const features = featureNumbers.map((n) => video-autoplay video-loop video-minimal - /> + > + + diff --git a/apps/website/src/templates/cloud-nodes/copy.test.ts b/apps/website/src/templates/cloud-nodes/copy.test.ts index 0aed2d2b5ec..b3c791275b3 100644 --- a/apps/website/src/templates/cloud-nodes/copy.test.ts +++ b/apps/website/src/templates/cloud-nodes/copy.test.ts @@ -26,7 +26,7 @@ const dynamicKeys: string[] = [ const staticKeys: TranslationKey[] = [ 'cloudNodesLaunch.meta.title', 'cloudNodesLaunch.meta.description', - 'cloudNodesLaunch.hero.title', + 'cloudNodesLaunch.hero.headline', 'cloudNodesLaunch.hero.titleHighlight', 'cloudNodesLaunch.hero.subtitle', 'cloudNodesLaunch.hero.videoAlt', diff --git a/apps/website/src/templates/mcp/SetupSection.vue b/apps/website/src/templates/mcp/SetupSection.vue index 2f735b853d7..acaabdee469 100644 --- a/apps/website/src/templates/mcp/SetupSection.vue +++ b/apps/website/src/templates/mcp/SetupSection.vue @@ -21,6 +21,7 @@ import { import { externalLinks, getRoutes } from '@/config/routes' import type { Locale } from '@/i18n/translations' import { translationsFor } from '@/i18n/translations' +import { I18nT } from 'vue-i18n' import { captureMcpClientTabClick, captureMcpConnectionTabClick @@ -95,23 +96,34 @@ const copiedLabel = t('ui.copied') v-if="activeConnectionId === 'cloud'" class="mt-4 max-w-xl text-xs text-primary-warm-gray" > - {{ t('mcp.setup.requirementPrefix') - }}{{ t('mcp.setup.requirementLinkLabel') }}{{ t('mcp.setup.requirementSuffix') - }}{{ t('mcp.setup.requirementFootnote') }} + + +

- {{ t('mcp.setup.local.requirementPrefix') - }}{{ t('mcp.setup.local.requirementLinkLabel') }}{{ t('mcp.setup.local.requirementSuffix') }} + + +

diff --git a/apps/website/src/templates/platform/RouterProviderCoverageSection.test.ts b/apps/website/src/templates/platform/RouterProviderCoverageSection.test.ts index 951bd2764e8..eefc4996646 100644 --- a/apps/website/src/templates/platform/RouterProviderCoverageSection.test.ts +++ b/apps/website/src/templates/platform/RouterProviderCoverageSection.test.ts @@ -6,6 +6,7 @@ import { ROUTER_COMFY_ONLY_PREVIEW, ROUTER_PROVIDER_COVERAGE } from '@/config/router-providers' +import { wholeText } from '@/test/wholeText' import RouterProviderCoverageSection from './RouterProviderCoverageSection.vue' const remaining = @@ -108,4 +109,16 @@ describe('RouterProviderCoverageSection', () => { }) ).toHaveAttribute('href', '/hub/models/') }) + + it('styles the remaining model count inside the run-on-Comfy line', () => { + render(RouterProviderCoverageSection, { props: { locale: 'zh-CN' } }) + + const line = screen.getByText( + wholeText(`另有 ${remaining} 个模型 在 Comfy 上运行`), + { selector: 'p' } + ) + expect( + within(line).getByText(`另有 ${remaining} 个模型`) + ).toBeInTheDocument() + }) }) diff --git a/apps/website/src/templates/platform/RouterProviderCoverageSection.vue b/apps/website/src/templates/platform/RouterProviderCoverageSection.vue index d70df98eb60..657cafc6233 100644 --- a/apps/website/src/templates/platform/RouterProviderCoverageSection.vue +++ b/apps/website/src/templates/platform/RouterProviderCoverageSection.vue @@ -1,5 +1,6 @@