New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@intlify/vue-i18n-extensions

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@intlify/vue-i18n-extensions

vue-i18n extensions

  • 2.0.0-alpha.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
106K
decreased by-36.2%
Maintainers
1
Weekly downloads
 
Created
Source

:globe_with_meridians: @intlify/vue-i18n-extensions

CircleCI npm vue-i18n-extensions Dev Token

Extensions for vue-i18n

NOTE: :warning: This next branch is development branch for Vue 3! The stable version is now in master branch!

Status: Alpha Test

This library exports the following extensions:

:star: Features

  • module: v-t custom directive compiler module for the following:
    • @vue/compiler-core (options at baseCompile function)
    • @vue/compiler-dom (options at compile function)
    • @vue/compiler-sfc (compilerOptions at compileTemplate function)
    • vue-loader (compilerOptions at options)

:cd: Installation

$ npm i --save-dev @intlify/vue-i18n-extensions@alpha

:rocket: Extensions

module: v-t custom directive compiler module

This module is v-t custom directive module for vue compilers. You can specify it.

The following example that use compile function of @vue/compiler-dom:

import { compile } from '@vue/compiler-dom'
import { createI18n } from 'vue-i18n'
import { defineTransformVT } from '@intlify/vue-i18n-extensions'

const i18n = createI18n({
  locale: 'ja',
  messages: {
    en: {
      hello: 'hello'
    },
    ja: {
      hello: 'こんにちは'
    }
  }
})
const transformVT = defineTransformVT(i18n)

const { code } = compile(`<p v-t="'hello'"></p>`, {
  mode: 'function',
  hoistStatic: true,
  prefixIdentifiers: true,
  directiveTransforms: { t: transformVT }
})
console.log(codel)
/* output -> 'hello'
  const { createVNode: _createVNode, openBlock: _openBlock, createBlock: _createBlock } = Vue

  const _hoisted_1 = { textContent: "こんにちは" }

  return function render(_ctx, _cache) {
    return (_openBlock(), _createBlock("p", _hoisted_1))
  }
*/

The following configration example of vue-loader:

const { VueLoaderPlugin } = require('vue-loader')
const { createI18n } = require('vue-i18n')
const { defineTransformVT } = require('@intlify/vue-i18n-extensions')

const i18n = createI18n({
  locale: 'ja',
  messages: {
    en: {
      hello: 'hello'
    },
    ja: {
      hello: 'こんにちは'
    }
  }
})
const transformVT = defineTransformVT(i18n)

module.exports = {
  module: {
    // ...
    rules: [
      {
        test: /\.vue$/,
        use: [
          {
            loader: 'vue-loader',
            options: {
              compilerOptions: {
                directiveTransforms: { t: transformVT }
              }
            }
          }
        ]
      },
      // ...
    ]
  },
  plugins: [new VueLoaderPlugin()]
}

MIT

Keywords

FAQs

Package last updated on 09 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc