Locale V0 Adapter (Vuetify0LocaleAdapter)
TheVuetify0LocaleAdapter is the default locale adapter for Vuetify Zero, providing translation and number formatting using the Intl API.
Import
Basic Usage
The
Vuetify0LocaleAdapter is the default adapter when no adapter is specified:Using in Components
Translation
Basic Translation
Named Placeholders
Numbered Placeholders
Fallback Messages
Number Formatting
Basic Formatting
Currency Formatting
Percentage Formatting
Custom Formatting Options
Placeholder Types
The adapter supports two placeholder formats:Named Placeholders
Numbered Placeholders
Mixed Placeholders
SSR Support
The adapter is SSR-safe and handles server/client environments:TypeScript
Custom Locale Adapter
You can create a custom adapter by implementing theLocaleAdapter interface:
Integration with i18n Libraries
While the built-in adapter works well for simple cases, you can create adapters for libraries likevue-i18n:
API Reference
Constructor
Methods
t(message, ...params)
Translate a message with variable substitution.
Parameters:
message: string- The message templateparams: unknown[]- Variables for substitution
string - Translated message
Named Variables:
n(value, locale, ...params)
Format a number according to locale.
Parameters:
value: number- Number to formatlocale: ID | undefined- Locale identifierparams: unknown[]- Intl.NumberFormatOptions
string - Formatted number
Example:
Intl API Support
The adapter uses the native Intl API for number formatting:Features
- Named placeholders -
{name}syntax - Numbered placeholders -
{0},{1}syntax - Mixed placeholders - Combine named and numbered
- Number formatting - Locale-aware via Intl API
- Currency formatting - Built-in currency support
- Percentage formatting - Built-in percent support
- SSR-safe - Works in Node.js and browser
- Zero dependencies - Uses native JavaScript APIs
Limitations
See Also
- useLocale - Locale composable
- createTokens - Token system for nested messages
- Intl.NumberFormat - MDN documentation