返回提示词目录第 1503 页

设计多语言区域路由方案

为产品规划语言、地区与市场设置,制定解析顺序、网址策略及跨平台实现方案

完整提示词

<context>
Teams often treat "locale" as one setting and get stuck: a Swiss user wants French text but Swiss francs; an expat in Germany wants English with German shipping; a geo-IP redirect sends a traveller to the wrong site and hides the one they wanted from search engines; and an app store build ignores the per-app language the phone already lets users set. A sound design separates language (for text), region (for formats and legal content) and market (for currency, catalogue and prices); resolves them in a clear order with the user's explicit choice always winning; uses BCP 47 tags; and gives every language its own crawlable URL on the web.
</context>

<task>
Design locale detection and routing for this {{platform}} product:

<product_description>
{{product_description}}
</product_description>

Locales: {{locales}}

1. Locale model: define the separate settings (UI language, formatting region, market or storefront, time zone) and which ones the user can change independently. Map the requested locales to BCP 47 tags and say which are language-only, which are language-region, and which share translations (for example es-419 for Latin America).
2. Resolution order, first match wins. On the web, a URL that carries a locale always renders that locale, so shared links and crawlers get what the URL promises; a saved choice that differs triggers a suggestion banner, never a redirect away. For URLs without a locale (the root, app start, emails and other server channels) resolve in this order: explicit choice saved in the account; explicit choice in a cookie or local storage; the OS or browser preference list (`Accept-Language` with quality values, `navigator.languages`, the per-app language on iOS and Android 13+); then the default. Use a real BCP 47 lookup or best-fit matcher (the framework's built-in matcher or a maintained library such as `@formatjs/intl-localematcher`), not string prefix matching. Geo-IP may suggest a market but never switch language silently.
3. Fallback chain: for each supported locale, its chain (for example `de-CH` to `de` to `en`), and how missing strings, formats and content fall back separately.
4. Web URL strategy: compare subpath (`/de/`), subdomain and country-code domains for this product, recommend one, and give the routing rules: the root URL behaviour (a language chooser or a non-redirecting default, plus a suggestion banner rather than a forced redirect), `hreflang` alternates including `x-default`, canonical tags, sitemaps, and `lang` on `html`. Never vary the content of one URL by `Accept-Language` without `Vary` and alternates.
5. Mobile: follow the system and per-app language settings, offer an in-app picker only if users need a language different from the system, and handle the store listing languages separately.
6. Language switcher: names each language in its own language ("Deutsch", "Français"), not flags; keeps the user on the equivalent page; remembers the choice.
7. Server and other channels: emails, push notifications, PDFs and support use the saved language, not the request headers of whoever triggered them.
8. Give implementation sketches for the stack described (middleware, routing config, the negotiation function), and list edge cases with expected behaviour.
</task>

<constraints>
- Recommend one approach with reasons; mention the main alternative and when it would win.
- Do not state SEO outcomes or legal requirements as certain; say what to verify (for example country-specific legal pages).
- If the locale list is vague ("all of them"), or the stack, how users arrive, or whether prices and catalogue differ by country is missing, ask for those first and do not design for every language.
{{> guardrails/scope-discipline}}
</constraints>

<output_format>
## Decision summary
Five to eight bullets in decision-record style: the choice and why.

## Locale model
Table: Setting | Values | Source | User can change?

## Resolution order
Numbered list, and the fallback chain per locale as a table.

## URL and SEO
URL pattern, redirect rules, hreflang example for one page. "Not applicable" for mobile-only.

## Implementation
Code or config sketches for the stated stack.

## Edge cases
Table: Situation | Expected behaviour (traveller, VPN, shared device, logged-out user with saved cookie, a shared link in a language other than the saved choice, unsupported language, crawler without Accept-Language).
</output_format>

可替换内容

  • {{platform}}
  • {{product_description}}
  • {{locales}}
  • {{> guardrails/scope-discipline}}

分类与标签

编程开发、国际化架构、语言路由、多语言网站、本地化开发

前往 AI 图片创作