Localisation (i18n)
Vectis UI uses English messages and the en-US locale by default. Register the supplied French dictionary or add your own translations.
Dictionaries provide interface text. The locale also controls regional formats through Intl. If no dictionary is registered for a language, messages fall back to English while formatting uses the selected locale.
Change language
Import and register the French dictionary, then select a locale with setLocale:
import { fr, registerMessages, setLocale } from 'vectis-ui'
registerMessages('fr', fr)
setLocale('fr-FR')Register dictionaries when your application starts, in main.ts or a universal Nuxt plugin. Call setLocale to update component messages and default formats without reloading the page.
The locale is shared across the process. For concurrent SSR requests in different languages, pass explicit text and locale props to components. For static generation, render routes sequentially and set the locale before rendering each route.
Add a language
Register a dictionary under its language code, such as de. Partial dictionaries keep previously registered values for omitted keys, then fall back to English.
import { registerMessages, setLocale, type MessagesInput } from 'vectis-ui'
// Omitted keys use the English messages for this new dictionary.
const de: MessagesInput = {
common: { clear: 'Leeren', close: 'Schließen' },
dataTable: { empty: 'Keine Daten' },
}
registerMessages('de', de)
setLocale('de-DE')Use MessagesInput to check namespace names, keys and message parameters. Dictionaries have two levels: namespace and key.
en-GB and en-US share the en dictionary but use different regional formats. Component text props, such as loadingText, override the corresponding dictionary messages.
Language and formats
Use setLocale for the global language and default formats. On components that accept it, the locale prop overrides formats without changing dictionary messages. In this example, choose the language and date/time formats separately.
Translation keys
The table lists the English messages by namespace. Register only the keys you want to translate or override.
Parameterised messages are TypeScript functions, shown with their arguments below. Implement plural rules in these functions.
| Key | English value |
|---|---|
common.loading | Loading… |
common.clear | Clear |
common.close | Close |
common.dismiss | Remove |
common.remove | (name) => `Remove ${name}` |
common.cancel | Cancel |
common.confirm | OK |
pagination.label | Pagination |
pagination.first | First page |
pagination.previous | Previous page |
pagination.next | Next page |
pagination.last | Last page |
pagination.page | (page) => `Page ${page}` |
tabs.label | Tabs |
tabs.previous | Previous tabs |
tabs.next | Next tabs |
breadcrumb.label | Breadcrumb |
breadcrumb.ellipsis | Show intermediate pages |
sideNavigation.label | Navigation |
link.newTab | , opens in a new tab |
combobox.empty | No results |
combobox.clear | Clear selection |
combobox.create | (query) => `Create "${query}"` |
select.clear | Clear selection |
commandPalette.label | Command palette |
commandPalette.searchLabel | Search commands |
commandPalette.placeholder | Type a command or search… |
commandPalette.empty | No results |
commandPalette.navigate | Navigate |
commandPalette.choose | Select |
dataTable.empty | No data |
dataTable.noResults | No results |
dataTable.loading | Loading data… |
dataTable.searchLabel | Search the table |
dataTable.searchPlaceholder | Search… |
dataTable.perPage | Rows per page |
dataTable.perPageValue | (label, value) => `${label}: ${value}` |
dataTable.selectAll | Select all |
dataTable.selectRow | (index) => `Select row ${index}` |
dataTable.selection | (count) => `${count} item${count === 1 ? '' : 's'} selected` |
dataTable.range | ({ start, end, total }) => `${start}–${end} of ${total}` |
dataTable.pagination | Table pagination |
toaster.label | Notifications |
snackbar.label | Confirmation |
snackbar.action | Undo |
inputOTP.label | Verification code |
inputOTP.slot | (index, total) => `Character ${index} of ${total}` |
slider.value | Value |
slider.start | Start |
slider.end | End |
slider.rangeStart | (label) => `${label} (start)` |
slider.rangeEnd | (label) => `${label} (end)` |
field.limitExceeded | (max) => `Exceeds the limit of ${max} characters` |
progress.percent | (percent) => `${percent}%` |
progress.label | Progress |
meter.label | Meter |
meterGroup.label | Breakdown |
hotkeys.command | Command |
hotkeys.ctrl | Ctrl |
hotkeys.alt | Alt |
hotkeys.shift | Shift |
hotkeys.windows | Win |
hotkeys.super | Super |
hotkeys.enter | Enter |
hotkeys.escape | Esc |
hotkeys.space | Space |
hotkeys.backspace | Backspace |
hotkeys.delete | Del |
hotkeys.tab | Tab |
hotkeys.up | Up arrow |
hotkeys.down | Down arrow |
hotkeys.left | Left arrow |
hotkeys.right | Right arrow |
hotkeys.label | (keys) => `Keyboard shortcut: ${keys}` |
colorPicker.label | Colour picker |
colorPicker.saturation | Saturation |
colorPicker.brightness | Brightness |
colorPicker.areaValue | (saturation, brightness) => `Saturation ${saturation}, brightness ${brightness}` |
colorPicker.hue | Hue |
colorPicker.alpha | Opacity |
colorPicker.value | Colour value |
colorPicker.format | Colour format |
colorPicker.eyeDropper | Pick a colour from the screen |
colorPicker.swatches | Preset colours |
colorInput.clear | Clear colour |
colorInput.openPicker | Open colour picker |
colorInput.pickerLabel | Choose a colour |
datePicker.label | Date picker |
datePicker.previousMonth | Previous month |
datePicker.nextMonth | Next month |
datePicker.previousYear | Previous year |
datePicker.nextYear | Next year |
datePicker.monthPicker | Choose month |
datePicker.yearPicker | Choose year |
dateInput.clear | Clear date |
dateInput.openPicker | Open calendar |
dateInput.pickerLabel | Choose a date |
numberInput.increment | Increase |
numberInput.decrement | Decrease |
splitButton.menu | More options |
rating.label | Rating |
rating.empty | No rating |
rating.value | (value, max) => `${value} out of ${max}` |
resizable.panel | (position) => `Panel ${position}` |
stepper.label | Progress |
stepper.completed | Completed |
stepper.error | Error |
treeView.label | Tree |
treeView.loadFailed | Could not load |
treeView.loadError | (label) => `Could not load the contents of ${label}` |
timePicker.label | Time picker |
timePicker.meridiem | AM or PM |
timePicker.am | AM |
timePicker.pm | PM |
timePicker.selectHour | Select hour |
timePicker.selectMinutes | Select minutes |
timePicker.choosingHour | Selecting the hour |
timePicker.choosingMinutes | Selecting the minutes |
timePicker.hour | Hour |
timePicker.minutes | Minutes |
timePicker.hourValue | (hour) => `${hour} o'clock` |
timePicker.minutesValue | (minute) => `${minute} minutes` |
timeInput.clear | Clear time |
timeInput.openPicker | Open time picker |
timeInput.pickerLabel | Choose a time |
timeInput.meridiemValue | (value) => `AM or PM: ${value}` |
timeInput.maskPlaceholder | hh:mm |
timeInput.unavailable | This time is not available. |
fileInput.openPicker | Choose files |
fileInput.clear | Clear files |
fileInput.files | (count) => `${count} file${count === 1 ? '' : 's'}` |
fileInput.placeholder | No file selected |
filePicker.browse | Browse files |
filePicker.or | or |
filePicker.list | Selected files |
carousel.label | Carousel |
carousel.roleDescription | carousel |
carousel.slideRoleDescription | slide |
carousel.slides | Slides |
carousel.slide | (index, total) => `${index} of ${total}` |
carousel.previous | Previous slide |
carousel.next | Next slide |
carousel.indicators | Choose slide to display |
calendar.label | Calendar |
calendar.roleDescription | calendar |
calendar.today | Today |
calendar.view | View |
calendar.viewDay | Day |
calendar.view4Days | 4 days |
calendar.viewWeek | Week |
calendar.viewMonth | Month |
calendar.viewYear | Year |
calendar.viewCustom | (days) => `${days} days` |
calendar.previousDay | Previous day |
calendar.nextDay | Next day |
calendar.previousWeek | Previous week |
calendar.nextWeek | Next week |
calendar.previousMonth | Previous month |
calendar.nextMonth | Next month |
calendar.previousYear | Previous year |
calendar.nextYear | Next year |
calendar.previousPeriod | Previous period |
calendar.nextPeriod | Next period |
calendar.allDay | All day |
calendar.moreEvents | (count) => `+${count} more` |
calendar.openDay | (day) => `Open ${day}` |
calendar.untitled | (No title) |
calendar.eventRoleDescription | event |
calendar.eventHint | Press Enter to open this event. Press Space to take hold of it, then the arrow keys to move it and Shift with the arrow keys to change when it ends. |
calendar.grabbed | Event held. Use the arrow keys to move it, Enter or Space to place it, Escape to cancel. |
calendar.dropped | Event placed. |
calendar.reverted | Move cancelled. The event is back where it was. |
calendar.movedTo | (title, when) => `${title} moved to ${when}.` |