LocaleProvider
Set the language of built-in SnowUI interface messages for an application or subtree, with custom overrides.
How LocaleProvider works
LocaleProvider supplies language context to descendant components. It adds no HTML wrapper, visual style, or layout of its own. Place it around the part of your application that should share a language.
It translates supported built-in messages, such as dialog close labels and color-scheme controls. Your page titles, content, and application messages remain owned by your application.
Import
Import LocaleProvider from the Components package as shown below.
import { LocaleProvider } from '@snowui-design-system/components';Use SnowUI to build the interface described by my requirements or design below.Choose your preferred access method. MCP: connect <https://snowui.dev/mcp> using Streamable HTTP, then use snowui_search, snowui_component, snowui_examples and snowui_setup. CLI: download <https://snowui.dev/snowui.mjs> as snowui.mjs and run node snowui.mjs help (Node.js 22+). Use node snowui.mjs search Button, docs Button, examples Button or setup; init --project PATH --entry ENTRY previews dependency/style edits, --apply writes them, and --install also installs dependencies. doctor checks declared dependencies and the selected entry. For a stdio-only MCP host, configure command node with args ["/absolute/path/snowui.mjs", "mcp"]. Installed npm packages include component-catalog.json and AGENTS.md in node_modules/@snowui-design-system/components (not src/ or docs/), while full component manuals live on MCP, CLI, and the HTTPS links below. These tools share the same current documentation; use --version for an exact component baseline and do not silently substitute unavailable versions. Only connect or execute when the host supports it and the user permits it; if unavailable, use the HTTPS documents below. Re-read guidance when the project version changes; copied prompts do not update themselves. Do not claim host compatibility or in-chat rendering from a successful connection.The linked AI documents are reviewed English translations of the current public component and design guidance. Check the installed package version and revisit the linked pages when source or product scope changes.Prepare downloads, installation, materials, and the environment using <https://snowui.dev/llms/en/setup.md> and machine setup <https://snowui.dev/llms/setup.json>. Detect actual file, terminal, Svelte build, and resource-loading capabilities first. In an authorized Svelte 5 environment, reuse compatible dependencies or use pnpm add --save-exact @snowui-design-system/components@1.2.4 @snowui-design-system/resource-svelte@1.0.33 (or the existing package manager), resolve resource-base transitively, load @snowui-design-system/components/styles once, and run the component/material interaction checks. Select real named materials from <https://snowui.dev/llms/resources.json>. Never use a maintainer's disk path or load the full library into each message.Report the actual installation, build and asset-loading results. Do not invent endpoints, bypass host permissions, or claim unexecuted work.Read the design guide: <https://snowui.dev/llms/en/design-system.md>. Break the page into regions and implement them with public components and semantic HTML.Read the styling order once: <https://snowui.dev/llms/en/styling.md>. Match public Props such as variant and size first and preserve the original styles where possible. If customization is necessary, use your own class (including existing Tailwind), then instance style. Same-category Tokens are recommended; use only public roots, parts and documented overrides.Select components as needed: <https://snowui.dev/llms/en/component-selection.md>. Use <https://snowui.dev/llms-en.txt> to discover them, then read only the relevant API, composition rules and examples. For SnowUI Figma input, also read <https://snowui.dev/llms/en/figma.md>.The official package is for Svelte 5. Confirm the target framework; explain any necessary port instead of pretending a changed import provides another framework.License: <https://snowui.dev/LICENSE> (proprietary SnowUI-Commercial-2.4.0: free without signup for in-chat UI, pure demos, and 1-dev/1-project local dev; before >1-dev, live deploy, client delivery, or component/token extraction, read <https://snowui.dev/LICENSE> and stop if required authorization is missing).Apply my requirements below. Do not invent APIs, addresses or authorization.Use LocaleProvider guide section import. Read the actual code in this section: <https://snowui.dev/components/locale-provider#import>.Complete public manual: <https://snowui.dev/llms/en/components/locale-provider/reference.md>Component guide: <https://snowui.dev/llms/en/components/locale-provider.md>Public API: <https://snowui.dev/llms/en/components/locale-provider/api.md>Dependency: @snowui-design-system/components; read the example's actual imports and load the package stylesheet once. Preserve its behavior and adapt only what my requirements need.Choose a language
The default language is zh-CN. Set locale="en-US" for the built-in English catalog. The following color-scheme control receives its accessible label from the surrounding provider.
<script lang="ts"> import { ColorSchemeButton, LocaleProvider } from "@snowui-design-system/components";</script> <LocaleProvider locale="en-US"> <ColorSchemeButton /></LocaleProvider>Use SnowUI to build the interface described by my requirements or design below.Choose your preferred access method. MCP: connect <https://snowui.dev/mcp> using Streamable HTTP, then use snowui_search, snowui_component, snowui_examples and snowui_setup. CLI: download <https://snowui.dev/snowui.mjs> as snowui.mjs and run node snowui.mjs help (Node.js 22+). Use node snowui.mjs search Button, docs Button, examples Button or setup; init --project PATH --entry ENTRY previews dependency/style edits, --apply writes them, and --install also installs dependencies. doctor checks declared dependencies and the selected entry. For a stdio-only MCP host, configure command node with args ["/absolute/path/snowui.mjs", "mcp"]. Installed npm packages include component-catalog.json and AGENTS.md in node_modules/@snowui-design-system/components (not src/ or docs/), while full component manuals live on MCP, CLI, and the HTTPS links below. These tools share the same current documentation; use --version for an exact component baseline and do not silently substitute unavailable versions. Only connect or execute when the host supports it and the user permits it; if unavailable, use the HTTPS documents below. Re-read guidance when the project version changes; copied prompts do not update themselves. Do not claim host compatibility or in-chat rendering from a successful connection.The linked AI documents are reviewed English translations of the current public component and design guidance. Check the installed package version and revisit the linked pages when source or product scope changes.Prepare downloads, installation, materials, and the environment using <https://snowui.dev/llms/en/setup.md> and machine setup <https://snowui.dev/llms/setup.json>. Detect actual file, terminal, Svelte build, and resource-loading capabilities first. In an authorized Svelte 5 environment, reuse compatible dependencies or use pnpm add --save-exact @snowui-design-system/components@1.2.4 @snowui-design-system/resource-svelte@1.0.33 (or the existing package manager), resolve resource-base transitively, load @snowui-design-system/components/styles once, and run the component/material interaction checks. Select real named materials from <https://snowui.dev/llms/resources.json>. Never use a maintainer's disk path or load the full library into each message.Report the actual installation, build and asset-loading results. Do not invent endpoints, bypass host permissions, or claim unexecuted work.Read the design guide: <https://snowui.dev/llms/en/design-system.md>. Break the page into regions and implement them with public components and semantic HTML.Read the styling order once: <https://snowui.dev/llms/en/styling.md>. Match public Props such as variant and size first and preserve the original styles where possible. If customization is necessary, use your own class (including existing Tailwind), then instance style. Same-category Tokens are recommended; use only public roots, parts and documented overrides.Select components as needed: <https://snowui.dev/llms/en/component-selection.md>. Use <https://snowui.dev/llms-en.txt> to discover them, then read only the relevant API, composition rules and examples. For SnowUI Figma input, also read <https://snowui.dev/llms/en/figma.md>.The official package is for Svelte 5. Confirm the target framework; explain any necessary port instead of pretending a changed import provides another framework.License: <https://snowui.dev/LICENSE> (proprietary SnowUI-Commercial-2.4.0: free without signup for in-chat UI, pure demos, and 1-dev/1-project local dev; before >1-dev, live deploy, client delivery, or component/token extraction, read <https://snowui.dev/LICENSE> and stop if required authorization is missing).Apply my requirements below. Do not invent APIs, addresses or authorization.Use LocaleProvider guide section locale. Read the actual code in this section: <https://snowui.dev/components/locale-provider#locale>.Complete public manual: <https://snowui.dev/llms/en/components/locale-provider/reference.md>Component guide: <https://snowui.dev/llms/en/components/locale-provider.md>Public API: <https://snowui.dev/llms/en/components/locale-provider/api.md>Dependency: @snowui-design-system/components; read the example's actual imports and load the package stylesheet once. Preserve its behavior and adapt only what my requirements need.Change language at runtime
Pass reactive state to locale to update supported built-in messages without recreating the provider. Store the selected language in your application if it should persist between visits.
<script lang="ts"> import { ColorSchemeButton, LocaleProvider } from "@snowui-design-system/components"; let locale = $state("en-US");</script> <label> Interface language <select bind:value={locale}> <option value="en-US">English</option> <option value="zh-CN">简体中文</option> </select></label> <LocaleProvider {locale}> <ColorSchemeButton /></LocaleProvider>Use SnowUI to build the interface described by my requirements or design below.Choose your preferred access method. MCP: connect <https://snowui.dev/mcp> using Streamable HTTP, then use snowui_search, snowui_component, snowui_examples and snowui_setup. CLI: download <https://snowui.dev/snowui.mjs> as snowui.mjs and run node snowui.mjs help (Node.js 22+). Use node snowui.mjs search Button, docs Button, examples Button or setup; init --project PATH --entry ENTRY previews dependency/style edits, --apply writes them, and --install also installs dependencies. doctor checks declared dependencies and the selected entry. For a stdio-only MCP host, configure command node with args ["/absolute/path/snowui.mjs", "mcp"]. Installed npm packages include component-catalog.json and AGENTS.md in node_modules/@snowui-design-system/components (not src/ or docs/), while full component manuals live on MCP, CLI, and the HTTPS links below. These tools share the same current documentation; use --version for an exact component baseline and do not silently substitute unavailable versions. Only connect or execute when the host supports it and the user permits it; if unavailable, use the HTTPS documents below. Re-read guidance when the project version changes; copied prompts do not update themselves. Do not claim host compatibility or in-chat rendering from a successful connection.The linked AI documents are reviewed English translations of the current public component and design guidance. Check the installed package version and revisit the linked pages when source or product scope changes.Prepare downloads, installation, materials, and the environment using <https://snowui.dev/llms/en/setup.md> and machine setup <https://snowui.dev/llms/setup.json>. Detect actual file, terminal, Svelte build, and resource-loading capabilities first. In an authorized Svelte 5 environment, reuse compatible dependencies or use pnpm add --save-exact @snowui-design-system/components@1.2.4 @snowui-design-system/resource-svelte@1.0.33 (or the existing package manager), resolve resource-base transitively, load @snowui-design-system/components/styles once, and run the component/material interaction checks. Select real named materials from <https://snowui.dev/llms/resources.json>. Never use a maintainer's disk path or load the full library into each message.Report the actual installation, build and asset-loading results. Do not invent endpoints, bypass host permissions, or claim unexecuted work.Read the design guide: <https://snowui.dev/llms/en/design-system.md>. Break the page into regions and implement them with public components and semantic HTML.Read the styling order once: <https://snowui.dev/llms/en/styling.md>. Match public Props such as variant and size first and preserve the original styles where possible. If customization is necessary, use your own class (including existing Tailwind), then instance style. Same-category Tokens are recommended; use only public roots, parts and documented overrides.Select components as needed: <https://snowui.dev/llms/en/component-selection.md>. Use <https://snowui.dev/llms-en.txt> to discover them, then read only the relevant API, composition rules and examples. For SnowUI Figma input, also read <https://snowui.dev/llms/en/figma.md>.The official package is for Svelte 5. Confirm the target framework; explain any necessary port instead of pretending a changed import provides another framework.License: <https://snowui.dev/LICENSE> (proprietary SnowUI-Commercial-2.4.0: free without signup for in-chat UI, pure demos, and 1-dev/1-project local dev; before >1-dev, live deploy, client delivery, or component/token extraction, read <https://snowui.dev/LICENSE> and stop if required authorization is missing).Apply my requirements below. Do not invent APIs, addresses or authorization.Use LocaleProvider guide section switch-language. Read the actual code in this section: <https://snowui.dev/components/locale-provider#switch-language>.Complete public manual: <https://snowui.dev/llms/en/components/locale-provider/reference.md>Component guide: <https://snowui.dev/llms/en/components/locale-provider.md>Public API: <https://snowui.dev/llms/en/components/locale-provider/api.md>Dependency: @snowui-design-system/components; read the example's actual imports and load the package stylesheet once. Preserve its behavior and adapt only what my requirements need.Customize built-in messages
Use messages to override specific catalog keys inside the provider. Omitted keys continue to use the selected language. Use the component’s explicit label property when the wording belongs to just one instance.
This example changes the two accessible labels used by ColorSchemeButton. Message keys are specific to the component; arbitrary application translation keys are not part of this catalog.
<script lang="ts"> import { ColorSchemeButton, LocaleProvider } from "@snowui-design-system/components";</script> <LocaleProvider locale="en-US" messages={{ "colorSchemeButton.toLight": "Use light appearance", "colorSchemeButton.toDark": "Use dark appearance"}}> <ColorSchemeButton /></LocaleProvider>Use SnowUI to build the interface described by my requirements or design below.Choose your preferred access method. MCP: connect <https://snowui.dev/mcp> using Streamable HTTP, then use snowui_search, snowui_component, snowui_examples and snowui_setup. CLI: download <https://snowui.dev/snowui.mjs> as snowui.mjs and run node snowui.mjs help (Node.js 22+). Use node snowui.mjs search Button, docs Button, examples Button or setup; init --project PATH --entry ENTRY previews dependency/style edits, --apply writes them, and --install also installs dependencies. doctor checks declared dependencies and the selected entry. For a stdio-only MCP host, configure command node with args ["/absolute/path/snowui.mjs", "mcp"]. Installed npm packages include component-catalog.json and AGENTS.md in node_modules/@snowui-design-system/components (not src/ or docs/), while full component manuals live on MCP, CLI, and the HTTPS links below. These tools share the same current documentation; use --version for an exact component baseline and do not silently substitute unavailable versions. Only connect or execute when the host supports it and the user permits it; if unavailable, use the HTTPS documents below. Re-read guidance when the project version changes; copied prompts do not update themselves. Do not claim host compatibility or in-chat rendering from a successful connection.The linked AI documents are reviewed English translations of the current public component and design guidance. Check the installed package version and revisit the linked pages when source or product scope changes.Prepare downloads, installation, materials, and the environment using <https://snowui.dev/llms/en/setup.md> and machine setup <https://snowui.dev/llms/setup.json>. Detect actual file, terminal, Svelte build, and resource-loading capabilities first. In an authorized Svelte 5 environment, reuse compatible dependencies or use pnpm add --save-exact @snowui-design-system/components@1.2.4 @snowui-design-system/resource-svelte@1.0.33 (or the existing package manager), resolve resource-base transitively, load @snowui-design-system/components/styles once, and run the component/material interaction checks. Select real named materials from <https://snowui.dev/llms/resources.json>. Never use a maintainer's disk path or load the full library into each message.Report the actual installation, build and asset-loading results. Do not invent endpoints, bypass host permissions, or claim unexecuted work.Read the design guide: <https://snowui.dev/llms/en/design-system.md>. Break the page into regions and implement them with public components and semantic HTML.Read the styling order once: <https://snowui.dev/llms/en/styling.md>. Match public Props such as variant and size first and preserve the original styles where possible. If customization is necessary, use your own class (including existing Tailwind), then instance style. Same-category Tokens are recommended; use only public roots, parts and documented overrides.Select components as needed: <https://snowui.dev/llms/en/component-selection.md>. Use <https://snowui.dev/llms-en.txt> to discover them, then read only the relevant API, composition rules and examples. For SnowUI Figma input, also read <https://snowui.dev/llms/en/figma.md>.The official package is for Svelte 5. Confirm the target framework; explain any necessary port instead of pretending a changed import provides another framework.License: <https://snowui.dev/LICENSE> (proprietary SnowUI-Commercial-2.4.0: free without signup for in-chat UI, pure demos, and 1-dev/1-project local dev; before >1-dev, live deploy, client delivery, or component/token extraction, read <https://snowui.dev/LICENSE> and stop if required authorization is missing).Apply my requirements below. Do not invent APIs, addresses or authorization.Use LocaleProvider guide section messages. Read the actual code in this section: <https://snowui.dev/components/locale-provider#messages>.Complete public manual: <https://snowui.dev/llms/en/components/locale-provider/reference.md>Component guide: <https://snowui.dev/llms/en/components/locale-provider.md>Public API: <https://snowui.dev/llms/en/components/locale-provider/api.md>Dependency: @snowui-design-system/components; read the example's actual imports and load the package stylesheet once. Preserve its behavior and adapt only what my requirements need.Scope and nested providers
Each component reads the nearest LocaleProvider. A nested provider establishes its own locale and messages; it does not merge overrides from its parent. Declare the nested locale explicitly to make that boundary clear.
Here, the first control uses English and the second uses Chinese. Neither setting changes components outside its provider.
<script lang="ts"> import { ColorSchemeButton, LocaleProvider } from "@snowui-design-system/components";</script> <LocaleProvider locale="en-US"> <ColorSchemeButton /> <LocaleProvider locale="zh-CN"> <ColorSchemeButton /> </LocaleProvider></LocaleProvider>Use SnowUI to build the interface described by my requirements or design below.Choose your preferred access method. MCP: connect <https://snowui.dev/mcp> using Streamable HTTP, then use snowui_search, snowui_component, snowui_examples and snowui_setup. CLI: download <https://snowui.dev/snowui.mjs> as snowui.mjs and run node snowui.mjs help (Node.js 22+). Use node snowui.mjs search Button, docs Button, examples Button or setup; init --project PATH --entry ENTRY previews dependency/style edits, --apply writes them, and --install also installs dependencies. doctor checks declared dependencies and the selected entry. For a stdio-only MCP host, configure command node with args ["/absolute/path/snowui.mjs", "mcp"]. Installed npm packages include component-catalog.json and AGENTS.md in node_modules/@snowui-design-system/components (not src/ or docs/), while full component manuals live on MCP, CLI, and the HTTPS links below. These tools share the same current documentation; use --version for an exact component baseline and do not silently substitute unavailable versions. Only connect or execute when the host supports it and the user permits it; if unavailable, use the HTTPS documents below. Re-read guidance when the project version changes; copied prompts do not update themselves. Do not claim host compatibility or in-chat rendering from a successful connection.The linked AI documents are reviewed English translations of the current public component and design guidance. Check the installed package version and revisit the linked pages when source or product scope changes.Prepare downloads, installation, materials, and the environment using <https://snowui.dev/llms/en/setup.md> and machine setup <https://snowui.dev/llms/setup.json>. Detect actual file, terminal, Svelte build, and resource-loading capabilities first. In an authorized Svelte 5 environment, reuse compatible dependencies or use pnpm add --save-exact @snowui-design-system/components@1.2.4 @snowui-design-system/resource-svelte@1.0.33 (or the existing package manager), resolve resource-base transitively, load @snowui-design-system/components/styles once, and run the component/material interaction checks. Select real named materials from <https://snowui.dev/llms/resources.json>. Never use a maintainer's disk path or load the full library into each message.Report the actual installation, build and asset-loading results. Do not invent endpoints, bypass host permissions, or claim unexecuted work.Read the design guide: <https://snowui.dev/llms/en/design-system.md>. Break the page into regions and implement them with public components and semantic HTML.Read the styling order once: <https://snowui.dev/llms/en/styling.md>. Match public Props such as variant and size first and preserve the original styles where possible. If customization is necessary, use your own class (including existing Tailwind), then instance style. Same-category Tokens are recommended; use only public roots, parts and documented overrides.Select components as needed: <https://snowui.dev/llms/en/component-selection.md>. Use <https://snowui.dev/llms-en.txt> to discover them, then read only the relevant API, composition rules and examples. For SnowUI Figma input, also read <https://snowui.dev/llms/en/figma.md>.The official package is for Svelte 5. Confirm the target framework; explain any necessary port instead of pretending a changed import provides another framework.License: <https://snowui.dev/LICENSE> (proprietary SnowUI-Commercial-2.4.0: free without signup for in-chat UI, pure demos, and 1-dev/1-project local dev; before >1-dev, live deploy, client delivery, or component/token extraction, read <https://snowui.dev/LICENSE> and stop if required authorization is missing).Apply my requirements below. Do not invent APIs, addresses or authorization.Use LocaleProvider guide section scope. Read the actual code in this section: <https://snowui.dev/components/locale-provider#scope>.Complete public manual: <https://snowui.dev/llms/en/components/locale-provider/reference.md>Component guide: <https://snowui.dev/llms/en/components/locale-provider.md>Public API: <https://snowui.dev/llms/en/components/locale-provider/api.md>Dependency: @snowui-design-system/components; read the example's actual imports and load the package stylesheet once. Preserve its behavior and adapt only what my requirements need.Overrides and fallbacks
Messages resolve in this order: an explicit component label, provider messages, the selected language catalog, the default zh-CN catalog, and finally the message key.
The current built-in catalogs are zh-CN and en-US. Resolution tries the exact locale, then a registered language-only catalog, then zh-CN. No language-only catalogs are currently registered: use en-US rather than assuming en or en-GB will resolve to English.
Application content and formatting
LocaleProvider does not translate arbitrary children or change the document’s lang or dir attributes. Keep those attributes and your application translations in sync with the language selected by your application.
Use the documented locale and formatting options of date and number components for formatted values. This provider’s public contract covers built-in UI messages; it does not promise to reformat every date or number in the application.
API Reference
| Property | Type | Default | Example | Description |
|---|---|---|---|---|
locale | string | "zh-CN" | locale="Example" | Current locale identifier. Built-in locales are zh-CN and en-US. An unknown locale falls back by language subtag, then to zh-CN. |
messages | SnowUIMessageOverrides | {} | messages={value} | Override built-in message keys only within this LocaleProvider subtree. |
children | Snippet | — | <LocaleProvider>Content</LocaleProvider> | Subtree receiving the locale and message overrides. Takes no arguments; LocaleProvider adds no DOM wrapper. |
| No data | ||||