Vitepress Theme Akari Docsv1.0.0GitHubSettingsMore

Internationalization: API ​

Language config ​

FieldTypeDefaultDescription
rootLanguagestringThe first language folder in alphabetical orderOnly valid in the shared config: the language served at the site root
langstringThe language folder's nameLanguage code, used for <html lang> and to choose the language pack
labelstringThe language's own nameName in the language menu; ja-JP, for example, defaults to "日本語"
dir"ltr" | "rtl" | "auto"The language pack'sText direction. Used when the text direction setting is Follow language
markdownMarkdownLocaleOptionsThe language pack'sThis language's strings in Markdown, laid over the language pack's, such as codeCopyButton: { tooltipText, copiedText }
messagesPartial<AkariMessages>NoneOverrides or fills in interface strings
languagesAkariLanguage[]NoneLanguage packs besides the built-in ones, or changes to them; usually in the shared config

The other fields (title, description, appBar, footer, search and so on) can also go in a language config; see Configuration.

AkariLanguage ​

The shape of a language pack, written with defineAkariLanguage (imported from docs/.vitepress/theme/define.ts):

FieldTypeDescription
codestringRequired. 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)
messagesPartial<AkariMessages>Interface strings. Missing entries are English
markdownMarkdownLocaleOptionsStrings 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.

messages ​

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.

KeyEnglish default
navigationToggleToggle navigation
navigationLabelDocumentation
railLabelDocumentation sections
categoryNavigation{category} navigation
categoryPages{category} pages
homeLink{title} home
moreActionsMore
backToTopBack to top
tocButtonContents
languageLabelChange language
languageDialogTitleChoose a language
languageDialogCloseClose
loadingLabelLoading page
KeyEnglish default
tocOverlineOn this page
pagerLabelPagination
previousPagePrevious
nextPageNext
footerMessageBuilt with VitePress and M3E
footerLinksFooter
notFoundTitlePage not found
notFoundTextThe page you are looking for may have been moved or deleted.
notFoundLinkBack to home

Settings ​

KeyEnglish default
settingsTitleSettings
settingsCloseClose settings
settingsColorColor
settingsVariantVariant
settingsContrastContrast
settingsMotionMotion
settingsDirectionText direction
settingsTextSizeText size
contrastStandardDefault
contrastMediumMedium
contrastHighHigh
motionStandardStandard
motionExpressiveExpressive
directionAutoFollow language
directionLtrLeft to right
directionRtlRight to left

Appearance ​

KeyEnglish default
schemeToggleAppearance:
schemeLightLight
schemeAutoSystem
schemeDarkDark
schemeTimeTime of day
schemeChangedTheme switched to:
schemeChangedFollowingTheme switched to: {mode} ({scheme})
KeyEnglish default
searchPlaceholderSearch docs
searchLabelSearch documentation
searchShortcutLabel{label}, shortcut
searchCloseClose search
searchIntroTitleSearch the docs
searchIntroTextType a page title, a component name or words from the text.
searchIntroShortcutPress {keys} to open it anytime
searchLoadingSearching…
searchErrorTitleSearch is unavailable
searchRetryRetry
searchEmptyTitleNo results
searchEmptyTextTry a shorter keyword, or check the search backend configuration.
searchResultCountOne{count} result
searchResultCount{count} results
searchResultsLabelSearch results
searchResultPagePage
searchHintSelectSelect
searchHintOpenOpen
searchHintCloseClose
searchFailedSearch failed. Please try again later.
searchIndexUnavailableCouldn't load the local search index.
searchIndexInvalidThe local search index is not valid.
searchRequestFailedThe search request failed (HTTP {status}).
searchBackendMissingNo 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.

useAkariI18n ​

ts
import { useAkariI18n } from "@theme";

const { lang, messages, t } = useAkariI18n();
t("homeLink", { title: "Vitepress Theme Akari Docs" }); // "Vitepress Theme Akari Docs home"
ReturnsDescription
langCurrent language code
messagesAll interface strings of the current language, with the messages config merged in
t(key, params?)Gets one string and fills in its placeholders

useAkariLocales ​

ts
import { useAkariLocales } from "@theme";

const { locales, homeHref } = useAkariLocales();
ReturnsDescription
localesList 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
homeHrefURL of the current language's home page, with base added

Call both functions only in components inside the layout.

Language pack functions ​

All are exported from the theme entry (import { … } from "@theme") and can be called anywhere.

ExportDescription
AKARI_LANGUAGESThe 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
defineAkariLanguage(language)Type helper for writing a language pack

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.

GitHub Settings

Search the docs

Type a page title, a component name or words from the text.

Press ⌘/Ctrl + K to open it anytime

Choose a language

EnglishEnglish (United States)العربيةArabic (Saudi Arabia)FrançaisFrench (France)日本語Japanese (Japan)한국어Korean (South Korea)简体中文Chinese (China)

Settings

Color
VariantTonal SpotVibrantFidelityExpressiveMonochromeNeutralRainbowFruit Salad
ContrastDefaultMediumHigh
MotionStandardExpressive
Text directionFollow languageLeft to rightRight to left
Text size100%150%200%