@vuecs/locale

Browser-language-aware, resettable locale source for vuecs — bridges into @vuecs/core's config.
5,222 4
Install
npm install @vuecs/locale
Latest Version:1.1.2
Vue:3
License:Apache-2.0
Last Updated:Oct 16, 2026
Links: GitHub  ·  npm
Maintainer: tada5hi

@vuecs/locale

npm version CI license

Browser-language-aware, resettable locale source for vuecs. Detects the navigator language, accepts an explicit override (e.g. a backend-saved user preference), resets back to 'auto' — and bridges the resolved BCP-47 tag into @vuecs/core's config so useLocale() and every locale-aware component pick it up reactively.

✨ What's inside

  • 🌍 'auto' sentinel — the locale analog of color mode's 'system': defers to the browser language (via @vueuse/core's useNavigatorLanguage), with a configurable fallback.
  • 🔁 useLocaleManager() — set(locale) applies an override, reset() hands resolution back to the browser; source / resolved / isAuto expose the state reactively.
  • 💾 Persistence — the chosen source survives reloads via localStorage (vc-locale by default).
  • 🏷️ <html lang> sync — the resolved tag is mirrored onto the document automatically.
  • 🧩 Single source of truth — bridges into Config['locale'], so read-side consumers (useLocale() from @vuecs/core, <VCTimeago>, …) need zero wiring and work even without this package installed.
  • 🛠️ bindLocale() — the lower-level building block (parallels bindColorMode) for custom sources; @vuecs/nuxt uses it with a cookie-backed ref for SSR.

📦 Installation

npm install @vuecs/locale

⚡ Usage

import { createApp } from 'vue';
import vuecs from '@vuecs/core';
import locale from '@vuecs/locale';

const app = createApp(App);
app.use(vuecs);
app.use(locale, { initial: 'auto', fallback: 'en-US' });
// after login — apply the backend-saved preference
import { useLocaleManager } from '@vuecs/locale';

const { set, reset, resolved, isAuto } = useLocaleManager();
set(user.preferences.locale);   // e.g. 'de-DE'
reset();                        // back to 'auto' → browser language
// read-only consumption — works with or without this plugin
import { useLocale } from '@vuecs/core';

const locale = useLocale();     // ComputedRef<string>

Using vue-i18n or another i18n library? Let it own the locale and feed its ref into app.use(vuecs, { config: { locale } }) instead — vuecs resolves the locale value; your i18n library owns the translations. Both directions compose; see the docs for recipes.

📚 Documentation

Full reference + i18n composition recipes: vuecs.dev/components/locale

For SSR (cookie transport + Accept-Language resolution), use @vuecs/nuxt.

License

Made with 💚

Published under Apache 2.0 License.

Related Packages

@i18n-micro/utils

Framework-agnostic utilities for Nuxt I18n Micro (granular subpath imports).

66,657 251
nuxt-i18n-preferred

Add preferred locale

550 0
@i18n-micro/core

Core utilities for translations, formatting, and locale routing in Nuxt I18n Mic...

199,259 251
@dialpad/i18n-goblin-core

Core i18n functionality - LocaleManager, BundleSource, Storage

6,029
@application-kit/i18n

Локали, словари и плагин vue-i18n для SSR-приложений на Vue и серверный резолв л...

866

Version History

Version Released Vue License
1.1.2 ^3.x Apache-2.0
1.1.1 ^3.x Apache-2.0
1.1.0 ^3.x Apache-2.0
1.0.4 ^3.x Apache-2.0
1.0.3 ^3.x Apache-2.0