@intl-schematic/vue
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-rc.4 • Public • Published

@intl-schematic/vue

npm i -s intl-schematic @intl-schematic/vue

Basic usage

import { createLocaleResource } from '@intl-schematic/vue';

const getDocument = (locale: Intl.Locale) => import(`/locales/${locale.baseName}.json`);

const userLocale = ref(new Intl.Locale(navigator.language));

const createTranslator = createLocaleResource(
  userLocale,
  (getLocale: () => Intl.Locale) => [/* Array of custom plugins */]
)

export default defineComponent(() => {
  const t = createTranslator(getDocument);

  // Fully reactive,
  // triggers automatic re-renders when the locale changes
  // or a new translation document is downloaded.
  const someText = computed(() => t('some key'));

  return {
    // Freely use in template as a plain string
    someText
  };
});

Package Sidebar

Install

npm i @intl-schematic/vue

Weekly Downloads

0

Version

1.0.0-rc.4

License

MIT

Unpacked Size

8.55 kB

Total Files

9

Last publish

Collaborators

  • raiondesu