Skip to content

Content and look

Languages

The app ships in English and Serbian (Latin script). The default language is served at /, and every other language gets a path prefix: /sr, /sr/blog, /sr/dashboard. You work here when you add or remove a language, or write copy and code that has to follow the reader's language.

How it works

  1. i18n in starter.config.ts(Licensees only) lists the languages. The kit's nuxt.config.ts(Licensees only) passes the list to @nuxtjs/i18n with the prefix_except_default strategy.
  2. Each language is one catalogue, a JSON file named in its entry. The kit's are in layers/kit/i18n/locales/(Licensees only); yours go in i18n/locales/ at your root. Where both have a catalogue of the same name, yours is merged over the kit's key by key, and your keys win. Templates call $t('key'), scripts call t('key') from useI18n().
  3. A catalogue also holds what renders outside vue-i18n: mail, each mail's subject, body, button and closing line; unsubscribe, the page an unsubscribe link opens; and ui, Nuxt UI's own strings such as aria-labels and "No data". ui is merged over the Nuxt UI locale named by the entry's language, or else by its code, or over Nuxt UI's English where it ships neither. mail and unsubscribe hold text and {name} placeholders, and the server prints them without vue-i18n: write a | or @ meant as text as {'|'} or {'@'}. The build refuses, naming the key, a linked message, any other |, braces around anything but a placeholder's name, and a brace or backslash inside a literal there, so that copy cannot print a brace.
  4. On a visitor's first request to /, the browser's language picks the locale, and the i18n_redirected cookie remembers it. The server reads the same cookie to choose the language of mail and redirects.
  5. A missing key renders the default language's string, and mail falls back to the default language's copy, then to the kit's English. An untranslated blog post or legal page is served from the default language's content at the prefixed URL.

Change a string

Put only the keys you change in your catalogue of the same name. To retitle the home page in English, i18n/locales/en.json holds:

{ "home": { "heading": "Menus your guests can read" } }

Every other English string, and every one the kit adds later, still comes from the kit's en.json. A full copy of the kit's file would hide all of them.

Add a language

Add the entry to starter.config.ts:

i18n: {
  defaultLocale: 'en',
  locales: [
    { code: 'en', language: 'en-US', name: 'English', file: 'en.json' },
    { code: 'sr', language: 'sr-Latn-RS', name: 'Srpski', file: 'sr.json' },
    { code: 'de', language: 'de-DE', name: 'Deutsch', file: 'de.json' },
  ],
},
  • code is the URL prefix and ends the names of the language's content collections, blog_<code> and legal_<code>, so it is letters and digits only, such as ptbr. The region goes in language.
  • language is a BCP 47 tag. It is the hreflang value, the name of the language's child sitemap, the lang every mail in the language declares, and the locale every Intl call gets, plural rules included. Pick the tag for the script you write in: sr formats dates in Cyrillic, sr-Latn-RS in Latin. It also picks Nuxt UI's strings and the text direction of the pages and the mail: the Nuxt UI locale of that tag, such as pt-BR or fa-IR, else the one named by code, else Nuxt UI's English.
  • name is what the language switcher shows, written in the language it names.
  • file names the catalogue.

Then:

  1. Write i18n/locales/de.json: translate every value of the kit's layers/kit/i18n/locales/en.json(Licensees only), mail and unsubscribe included. Leave ui out unless you want other words than Nuxt UI's: it ships German. For a language Nuxt UI lacks, translate its strings under ui, as the kit's sr.json does for Serbian.
  2. Add de to locales in blog.config.mjs(Licensees only), if the AI blog workflow should write German too.
  3. Translate the legal pages into content/de/legal/.

The build refuses a code that is not letters and digits, such as pt-BR or pt_BR; a language that is not a BCP 47 tag, such as pt_BR, or that Intl has no plural rules for, such as jp or Maori (mi), which Intl formats but cannot pluralise; a declared language that has no catalogue, yours or the kit's; and a catalogue of yours that no entry declares. With pnpm dev running, write the catalogue before the entry: the dev server logs why the new file waits, and saving starter.config.ts with the entry restarts it. An entry saved first restarts into the refusal, and then only restarting pnpm dev yourself brings it back. layers/kit/test/unit/i18n-locales.test.ts(Licensees only) names every key the new language still lacks. The blog's locales is not checked. Route rules, sitemap exclusions, analytics path folding, the switcher, the feeds and the content collections all read i18n.locales, so they need no edit. Restart pnpm dev after changing a catalogue's mail, unsubscribe or ui: the build reads them once.

Remove a language

Delete its entry in i18n.locales and its content/<code>/, and your own catalogue for it if you wrote one. A language the kit ships keeps its catalogue in layers/kit/i18n/locales/, where nothing reads it. The kit's suites follow i18n.locales, so none needs an edit.

With one language left, the app switches itself to no_prefix: no browser language redirect, no hreflang alternates, one flat /sitemap.xml, and a switcher that renders nothing. layers/kit/vitest.config.ts(Licensees only) skips the component suites that need a second language, and the Playwright specs skip their second-language cases. $t() keeps working, so adding a language back is the config entry above.

The Playwright specs need no edit when you remove a language or replace the second one. They follow i18n.locales and test the first entry that is not the default, reading its seo.login.title, errors.status.notFound.title, common.language.label and brand.name from its catalogue, so it must carry those keys. The cases about the Serbian sample post and legal pages skip once Serbian is gone, but only in an app that has taken an update (Testing).

Write copy

  • Keys are nested objects. "auth": { "title": … } is reachable as auth.title; a literal "auth.title" key is not.
  • Write a literal @ as {'@'}. An unescaped @ breaks the whole file, and every t() in the app then renders its key path.
  • Write plurals with one branch per plural category the language reaches with whole counts, in the order zero, one, two, few, many, other. English has two; Serbian has three. The plural rule comes from Intl.PluralRules for the entry's language, not its code, and pluralCategories('de-DE') in layers/kit/shared/i18n/plural.ts(Licensees only) names the categories for a language:
    "locked": "Pokušajte ponovo za {minutes} minut. | Pokušajte ponovo za {minutes} minuta. | Pokušajte ponovo za {minutes} minuta."
    
  • An empty string is a value. Fallback doesn't replace it, and the tests refuse it.

layers/kit/test/unit/i18n-locales.test.ts(Licensees only) holds every catalogue, yours merged over the kit's, to the default language's: the same keys, the same interpolations, the right number of plural branches, no unescaped @ and nothing blank. ui is left out of that comparison. It also checks that every declared language has a catalogue, that every catalogue of yours is declared, that the default language carries every key of the kit's English, and that every ui key names a Nuxt UI message.

Write code that follows the language

Anything holding a translated string is a computed or a getter. t() resolves once, when it is called, so a module-scope schema or a plain string in useSeoMeta stays in the language the page first loaded in:

const { t } = useI18n()

const schema = computed(() => z.object({ email: emailSchema(t) }))

useSeoMeta({
  title: () => t('seo.dashboard.settings.activity.title'),
})
  • Build internal links with useLocalePath(). It is idempotent, so passing /sr/dashboard returns /sr/dashboard. It returns an empty string for a route that doesn't exist, so a link to a page you may delete needs a fallback: localePath('/pricing') || '/pricing'.
  • A path already produced by localePath() or switchLocalePath() goes to ULink or a menu item with locale: false, as useLanguageSwitcher(Licensees only) does. Otherwise it is localised twice and the English link points at /sr.
  • Format dates and numbers with useLocaleTag(), which returns the language tag rather than the code: new Intl.NumberFormat(useLocaleTag().value).
  • Query content by a path rebuilt from the route's slug param, never by route.path, which carries the prefix. Give useAsyncData a getter key that includes the locale, because switching language reuses the page component.

Word a server refusal

A route's statusMessage stays English: it is what logs and API clients read. Every refusal a person can see also carries a data.reason, and the browser words it from the catalogues. The reasons are the kit's, so adding one is a change to the kit, in four edits:

  1. Add the reason to REFUSAL_REASONS in layers/kit/shared/refusals/reasons.ts(Licensees only).
  2. Throw it:
    import type { RefusalReason } from '#layers/kit/shared/refusals/reasons'
    
    throw createError({
      statusCode: 413,
      statusMessage: 'The report is too large to export.',
      data: { reason: 'report-too-large' satisfies RefusalReason },
    })
    
  3. Map it to a key in REFUSAL_COPY_KEYS in layers/kit/app/utils/refusal-copy.ts(Licensees only), for example 'report-too-large': 'refusals.reportTooLarge'.
  4. Add refusals.reportTooLarge to every catalogue.

useAuthErrorToast() then shows the translated copy under your own title:

const addAuthError = useAuthErrorToast()

addAuthError(error, { title: t('dashboard.settings.privacy.saveFailed') })

A description you pass wins over the reason's copy. A refusal whose reason the catalogue doesn't know is worded by its status code, never with the server's English. layers/kit/test/unit/refusal-copy.test.ts(Licensees only) fails on a reason without copy, on copy no reason uses, and on a declared reason nothing on the server sends.

The server has no useLocalePath(). layers/kit/server/utils/i18n.ts(Licensees only) stands in for it:

  • requestLocale(event) is the cookie's locale when it names a configured language, and the default otherwise.
  • localeRedirect(event, path, locale?) prefixes path with the visitor's locale, or with locale. The default language stays unprefixed, and a locale segment already on the path is replaced rather than doubled.
  • localeCodes(event) lists the configured codes. Check a path segment against it before using it as a locale.
  • localeLanguage(event, code) is the language the config gives code, for Intl and a lang attribute, and the code itself where an entry gives none.

This is how the password reset mail builds its link:

return `${base}${localeRedirect(event, '/auth/reset-password', locale)}?token=${token}`

base there is requireLinkBase(event), the site's origin, which also works on the event a job, listener or task receives (Email).

Configuration

KeyWhereDefaultWhat it does
i18n.defaultLocalestarter.config.ts'en'Served at /. Fills missing keys and untranslated documents
i18n.localesstarter.config.tsen (en-US), sr (sr-Latn-RS)The languages. One entry turns prefixes, detection and the switcher off
i18n.locales[].filestarter.config.tsen.json, sr.jsonThe catalogue: yours in i18n/locales/, the kit's, or both merged
localesblog.config.mjsen, srLanguages the AI blog workflow writes and translates

There are no environment variables.

Good to know

  • Nitro matches route rules against the raw path, which knows nothing of the prefixes. The kit's rules go through perLocale() in layers/kit/build/locales.ts(Licensees only); a rule of yours in your nuxt.config.ts names each language's path itself, as '/sr/reports/**' beside '/reports/**', or the prefixed page misses it.
  • An untranslated legal page is served under the other language as that language's terms. To answer 404 instead, replace layers/kit/app/pages/legal/[...slug].vue(Licensees only) with your own app/pages/legal/[...slug].vue without its fallback query.
  • brand.name, blog.title and blog.description are printed by the RSS feed without vue-i18n. Keep them plain text: a {, }, @ or | fails the build (Blog).
  • nuxtSiteConfig.name is @:brand.name, the one linked message. It names the site in the structured data on every page, so rename the product in brand.name and leave the link alone.
  • The browser's language is only consulted at /. A visitor who opens /pricing directly gets English, whatever their browser prefers, because the URL names the language.
  • A page the route rules cache, such as /blog or /legal/terms, renders from a copy of the request that carries no cookies, and a cookie set during that render is dropped. The browser sets i18n_redirected once such a page loads.

A link with a lock opens the kit’s private repository, which every licensee can read.