The shape of a language pack, written with defineAkariLanguage (imported from docs/.vitepress/theme/define.ts):
Field
Type
Description
code
string
Required. The language code. A page first looks for a pack with its full code (pt-BR), then for one with its primary language (pt)
dir
"ltr" | "rtl"
Text direction. Defaults to "ltr"
fonts
{ google: string[]; family: string[] }
Fonts; both fields are written as in fonts. Defaults to the theme's fonts (Roboto and Noto Sans SC)
messages
Partial<AkariMessages>
Interface strings. Missing entries are English
markdown
MarkdownLocaleOptions
Strings in Markdown: codeCopyButton is the code block copy button's tooltip, and container holds the containers' default titles (tipLabel, warningLabel, dangerLabel, infoLabel, detailsLabel and so on)
The built-in packs are in docs/.vitepress/theme/i18n/languages/, one file per language, listed by the index.ts in the same folder. To give the theme itself another built-in language, add a file there and list it in AKARI_LANGUAGES.
The six built-in language packs, Simplified Chinese (zh), English (en), Japanese (ja), Korean (ko), French (fr) and Arabic (ar), all have every interface string. Entries you write in the language config's messages replace the pack's strings; entries you leave out keep the pack's. Entries with {name} get the matching value filled in at runtime.
Type a page title, a component name or words from the text.
searchIntroShortcut
Press {keys} to open it anytime
searchLoading
Searching…
searchErrorTitle
Search is unavailable
searchRetry
Retry
searchEmptyTitle
No results
searchEmptyText
Try a shorter keyword, or check the search backend configuration.
searchResultCountOne
{count} result
searchResultCount
{count} results
searchResultsLabel
Search results
searchResultPage
Page
searchHintSelect
Select
searchHintOpen
Open
searchHintClose
Close
searchFailed
Search failed. Please try again later.
searchIndexUnavailable
Couldn't load the local search index.
searchIndexInvalid
The local search index is not valid.
searchRequestFailed
The search request failed (HTTP {status}).
searchBackendMissing
No search backend is registered as "{id}".
searchResultCountOne is used for counts whose plural category is one ("1 result" in English); other counts use searchResultCount. Intl.PluralRules decides the category for the language. {keys} is rendered as keycaps when shown.
List of languages, each { key, label, lang, href, current }; href is the URL to open when switching to that language. An empty array when the site has only one language
homeHref
URL of the current language's home page, with base added
Call both functions only in components inside the layout.
All are exported from the theme entry (import { … } from "@theme") and can be called anywhere.
Export
Description
AKARI_LANGUAGES
The built-in language packs
resolveLanguage(lang, languages?)
The pack a language ends up with: returns { code, dir, fonts, messages, markdown }, with the gaps filled by the rules above. languages are the site's own packs
A registered search backend receives lang (such as zh-CN) and locale (the VitePress locale key, root for the root language) in its second argument; see Search.