Go to file
Kruglov Kirill 7a14a31cc8
Merge pull request #3 from cmath10/master
ci: Tests pipeline
2021-11-24 14:29:49 +03:00
.github/workflows ci: Tests pipeline 2021-11-24 14:19:05 +03:00
lib feat: Loader + plugin to load & transform translations from i18n custom block 2021-11-17 15:08:47 +03:00
tests feat: Loader + plugin to load & transform translations from i18n custom block 2021-11-17 15:08:47 +03:00
.babelrc feat: Loader + plugin to load & transform translations from i18n custom block 2021-11-17 15:08:47 +03:00
.gitignore feat: Loader + plugin to load & transform translations from i18n custom block 2021-11-17 15:08:47 +03:00
.npmignore feat: Loader + plugin to load & transform translations from i18n custom block 2021-11-17 15:08:47 +03:00
.versionrc.json chore: Added standart-release tool 2021-11-17 15:46:02 +03:00
CHANGELOG.md chore(release): 0.0.2 2021-11-18 18:26:20 +03:00
docker-compose.yml ci: Tests pipeline 2021-11-24 14:19:05 +03:00
jest.conf.js feat: Loader + plugin to load & transform translations from i18n custom block 2021-11-17 15:08:47 +03:00
package.json chore(release): 0.0.2 2021-11-18 18:26:20 +03:00
README.md docs: Updated README.md 2021-11-18 11:15:46 +03:00
yarn.lock chore: Added standart-release tool 2021-11-17 15:46:02 +03:00

vue-i18n-loader

This is an experimental webpack tool for vue-i18n. The package provides webpack loader and plugin to load translations from <i18n> custom blocks.

If the plugin added to a webpack.config.js, it will add prefix to translation messages paths & their usages in <template>/script blocks. Currently, not all variants of vue-i18n syntax are covered with prefix, in particular, renamings are not supported:

const t = this.$i18n.t

t('some.translation.path') // will not be prefixed

Supported syntax:

  • methods $t, $tc in templates;
  • methods t, tc in this.$i18n.%methodName% calls;
  • directive v-t;
  • interpolation component <i18n>.

Restrictions:

  • renamings;
  • usage as map method like paths.map(this.$i18n.t) or similar;
  • computed dynamic paths.

Webpack config example:

const VueLoaderPlugin = require('vue-loader/lib/plugin')
const VueI18NLoaderPlugin = require('@retailcrm/vue-i18n-loader/lib/plugin')

module.exports = {
  mode: 'development',

  devtool: 'source-map',

  context: __dirname,

  entry: './__fixtures__/entry.js',

  resolve: {
    alias: {
      '~target': path.resolve(__dirname, fixture),
    },
  },

  output: {
    path: '/',
    filename: 'bundle.js'
  },

  module: {
    rules: [{
      test: /\.vue$/,
      loader: 'vue-loader',
    }, {
      resourceQuery: /blockType=i18n/,
      type: 'javascript/auto',
      loader: '@retailcrm/vue-i18n-loader',
    }],
  },

  plugins: [
    new VueLoaderPlugin(),
    new VueI18NLoaderPlugin(),
  ],
}