Skip to content

feat: add contentsByLocale to update inputPlaceholder per locale#3220

Open
pepalonsocosta wants to merge 2 commits into
masterfrom
locale-detection/contents-by-locale
Open

feat: add contentsByLocale to update inputPlaceholder per locale#3220
pepalonsocosta wants to merge 2 commits into
masterfrom
locale-detection/contents-by-locale

Conversation

@pepalonsocosta
Copy link
Copy Markdown
Contributor

@pepalonsocosta pepalonsocosta commented May 22, 2026

Description

Add a contentsByLocale prop to the webchat that allows bots to provide locale-specific
content overrides. The inputPlaceholder is the first supported field — it updates
automatically whenever the user's system_locale changes.

Context

The input placeholder was set once at module load time inside the static theme object, so unlike other locale-driven contents it never reacted to system_locale changes.

Approach taken / Explain the design

  • Add WebchatLocaleContents type and contentsByLocale: Record<string, WebchatLocaleContents> wired through WebchatArgs, WebchatProps, WebchatApp, and DevApp down to the Webchat component
  • updateSessionWithUser resolves contentsByLocale[system_locale].inputPlaceholder and calls updateTheme whenever system_locale is set, falling back to WEBCHAT_DEFAULT_CONTENTS.INPUT_PLACEHOLDER
  • Extract the default placeholder string into WEBCHAT_DEFAULT_CONTENTS to avoid duplication

To document / Usage example

new WebchatApp({
  contentsByLocale: {
    en: { inputPlaceholder: 'Write a reply...' },
    es: { inputPlaceholder: 'Escribe tu pregunta...' },
    pt: { inputPlaceholder: 'Digite sua pergunta...' },
  },
})

Testing

The pull request...

  • has unit tests
  • has integration tests
  • doesn't need tests because... [provide a description]

@pepalonsocosta pepalonsocosta self-assigned this May 22, 2026
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@pepalonsocosta pepalonsocosta force-pushed the locale-detection/contents-by-locale branch from d36852c to 1fdf15d Compare May 22, 2026 14:32
@Iru89
Copy link
Copy Markdown
Contributor

Iru89 commented May 22, 2026

Add an entry in packages/botonic-react/CHANGELOG.md

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants