Skip to content

refactor: migrate locale/RTL to @vuetify/v0#22753

Open
johnleider wants to merge 16 commits intonextfrom
feat/v0-locale-integration
Open

refactor: migrate locale/RTL to @vuetify/v0#22753
johnleider wants to merge 16 commits intonextfrom
feat/v0-locale-integration

Conversation

@johnleider
Copy link
Copy Markdown
Member

@johnleider johnleider commented Mar 24, 2026

Summary

  • Replaces Vuetify's internal locale adapter with @vuetify/v0's createLocale() for message storage (tokens), translation (t()), number formatting (n()), and fallback resolution
  • Replaces Vuetify's internal RTL implementation with v0's createRtl(), bridged via per-locale RTL map
  • Deletes packages/vuetify/src/locale/adapters/vuetify.ts — v0's Vuetify0LocaleAdapter handles this
  • Vuetify remains a thin wrapper: $vuetify. prefix stripping, per-locale RTL map, CSS class generation, LocaleSymbol DI
  • Consumer-facing API (t, n, current, isRtl, rtlClasses, decimalSeparator) is unchanged

Breaking Changes

  • LocaleInstance.provide() and .name removed
  • LocaleInstance.fallback and .messages removed from public type
  • Nested contexts use provideLocale() or VLocaleProvider

Test plan

  • pnpm build:lib — 551 files compiled
  • tsgo -p tsconfig.checks.json --noEmit — clean
  • eslint src --max-warnings 0 — clean
  • pnpm test:unit -- --run — 661 passed (4 pre-existing failures in date.spec.ts unrelated)
  • Verify VLocaleProvider scoped locale override in browser

Design for migrating Vuetify's locale/RTL system to use @vuetify/v0
composables as the runtime baseline. Bumps v0 to ^0.1.7 for RTL support.
Updated spec to retain provideLocale() as thin wrapper.
Plan covers 4 tasks: core composable rewrite, vue-i18n adapter update,
type exports, and integration verification.
Vuetify's locale composable now delegates to @vuetify/v0 for:
- Message storage (tokens) and translation (t())
- Number formatting (n())
- Fallback locale resolution
- RTL boolean state

Vuetify remains responsible for:
- $vuetify. prefix stripping
- Per-locale RTL map (ar, fa, he → true)
- CSS class generation (v-locale--is-rtl/ltr)
- LocaleSymbol provide/inject contract

BREAKING CHANGE: LocaleInstance.provide() and .name removed.
LocaleInstance.fallback and .messages removed from public type.
Nested contexts use provideLocale() or VLocaleProvider.
Includes runtime locale/theme registration support via
register({ id, messages }) and exported flatten() utility.
@J-Sek

This comment was marked as resolved.

@johnleider
Copy link
Copy Markdown
Member Author

Fixed n() missing Intl.NumberFormatOptions support in 9707e4d

name: string
fallback: Ref<string>
messages: Ref<LocaleMessages>
provide: (props: LocaleOptions) => VueI18nLocaleInstance
Copy link
Copy Markdown
Member

@KaelWD KaelWD Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were name and provide removed on LocaleInstance but not here?


if (!parent) throw new Error('[Vuetify] Could not find injected locale instance')

if ('provide' in parent && isFunction(parent.provide)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially when you're still using provide.

export interface LocaleInstance {
name: string
decimalSeparator: ShallowRef<string>
messages: Ref<LocaleMessages>
Copy link
Copy Markdown
Member

@KaelWD KaelWD Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea if anyone actually did this but it used to be possible to add to messages at runtime, now they all have to be declared upfront.

const locale = createLocaleInstance(v0Locale, props)
const rtl = provideRtl(locale, parent.rtl, props)

const data = { ...locale, ...rtl, _messages: messages, _fallback: fallback } satisfies FullLocaleInstance
Copy link
Copy Markdown
Member

@KaelWD KaelWD Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to "remove" messages and fallback if they're just being renamed and made private?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

E: locale Locale composable E: rtl Rtl composable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants