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
i18ninstarter.config.ts(Licensees only) lists the languages. The kit'snuxt.config.ts(Licensees only) passes the list to @nuxtjs/i18n with theprefix_except_defaultstrategy.- 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 ini18n/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 callt('key')fromuseI18n(). - 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; andui, Nuxt UI's own strings such as aria-labels and "No data".uiis merged over the Nuxt UI locale named by the entry'slanguage, or else by itscode, or over Nuxt UI's English where it ships neither.mailandunsubscribehold 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. - On a visitor's first request to
/, the browser's language picks the locale, and thei18n_redirectedcookie remembers it. The server reads the same cookie to choose the language of mail and redirects. - 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' },
],
},
codeis the URL prefix and ends the names of the language's content collections,blog_<code>andlegal_<code>, so it is letters and digits only, such asptbr. The region goes inlanguage.languageis a BCP 47 tag. It is the hreflang value, the name of the language's child sitemap, thelangevery mail in the language declares, and the locale everyIntlcall gets, plural rules included. Pick the tag for the script you write in:srformats dates in Cyrillic,sr-Latn-RSin 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 aspt-BRorfa-IR, else the one named bycode, else Nuxt UI's English.nameis what the language switcher shows, written in the language it names.filenames the catalogue.
Then:
- Write
i18n/locales/de.json: translate every value of the kit'slayers/kit/i18n/locales/en.json(Licensees only),mailandunsubscribeincluded. Leaveuiout unless you want other words than Nuxt UI's: it ships German. For a language Nuxt UI lacks, translate its strings underui, as the kit'ssr.jsondoes for Serbian. - Add
detolocalesinblog.config.mjs(Licensees only), if the AI blog workflow should write German too. - 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 asauth.title; a literal"auth.title"key is not. - Write a literal
@as{'@'}. An unescaped@breaks the whole file, and everyt()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.PluralRulesfor the entry'slanguage, not itscode, andpluralCategories('de-DE')inlayers/kit/shared/i18n/plural.ts(Licensees only) names the categories for alanguage:"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/dashboardreturns/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()orswitchLocalePath()goes toULinkor a menu item withlocale: false, asuseLanguageSwitcher(Licensees only) does. Otherwise it is localised twice and the English link points at/sr. - Format dates and numbers with
useLocaleTag(), which returns thelanguagetag rather than the code:new Intl.NumberFormat(useLocaleTag().value). - Query content by a path rebuilt from the route's
slugparam, never byroute.path, which carries the prefix. GiveuseAsyncDataa 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:
- Add the reason to
REFUSAL_REASONSinlayers/kit/shared/refusals/reasons.ts(Licensees only). - 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 }, }) - Map it to a key in
REFUSAL_COPY_KEYSinlayers/kit/app/utils/refusal-copy.ts(Licensees only), for example'report-too-large': 'refusals.reportTooLarge'. - Add
refusals.reportTooLargeto 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.
Build a localised link on the server
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?)prefixespathwith the visitor's locale, or withlocale. 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 thelanguagethe config givescode, forIntland alangattribute, 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
| Key | Where | Default | What it does |
|---|---|---|---|
i18n.defaultLocale | starter.config.ts | 'en' | Served at /. Fills missing keys and untranslated documents |
i18n.locales | starter.config.ts | en (en-US), sr (sr-Latn-RS) | The languages. One entry turns prefixes, detection and the switcher off |
i18n.locales[].file | starter.config.ts | en.json, sr.json | The catalogue: yours in i18n/locales/, the kit's, or both merged |
locales | blog.config.mjs | en, sr | Languages 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()inlayers/kit/build/locales.ts(Licensees only); a rule of yours in yournuxt.config.tsnames 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 ownapp/pages/legal/[...slug].vuewithout its fallback query. brand.name,blog.titleandblog.descriptionare printed by the RSS feed without vue-i18n. Keep them plain text: a{,},@or|fails the build (Blog).nuxtSiteConfig.nameis@:brand.name, the one linked message. It names the site in the structured data on every page, so rename the product inbrand.nameand leave the link alone.- The browser's language is only consulted at
/. A visitor who opens/pricingdirectly gets English, whatever their browser prefers, because the URL names the language. - A page the route rules cache, such as
/blogor/legal/terms, renders from a copy of the request that carries no cookies, and a cookie set during that render is dropped. The browser setsi18n_redirectedonce such a page loads.
A link with a lock opens the kit’s private repository, which every licensee can read.