Coder Social home page Coder Social logo

Comments (17)

Lanfei avatar Lanfei commented on June 10, 2024 4

You can add following rule in your webpack.conf.js:

{
  module: {
    rules: [
      {
        resourceQuery: /\bblockType=i18n\b/,
        loader: '@kazupon/vue-i18n-loader'
      }
      //, Other rules
    ]
  }
}

from vue-i18n-loader.

smares avatar smares commented on June 10, 2024 1

Follow-up: It works if I rename the files to *.loca. Any idea how to make it work with *.json?

from vue-i18n-loader.

smares avatar smares commented on June 10, 2024

Any idea how to then make it work with Webpack 4 which throws Module parse failed: Unexpected token i in JSON at position 0? With vue-loader 14, the hint from #13 helped, but using your snippet from above no longers does the trick.

from vue-i18n-loader.

Lanfei avatar Lanfei commented on June 10, 2024

I am using Webpack 4.6.0 without json-loader, and it works fine for me.

from vue-i18n-loader.

smares avatar smares commented on June 10, 2024

Are you using it with JSON files? As in <i18n src="locale.en.json"/>?

from vue-i18n-loader.

smares avatar smares commented on June 10, 2024
{
  resourceQuery: /\bblockType=i18n\b/,
  loader: '@kazupon/vue-i18n-loader',
  type: 'javascript/auto'
}

This works. πŸ‘

from vue-i18n-loader.

Lanfei avatar Lanfei commented on June 10, 2024

No, I was using i18n custom block like this, not with JSON files:

<i18n>
{
  "en": {
    "hello": "hello world!"
  },
  "ja": {
    "hello": "γ“γ‚“γ«γ‘γ―γ€δΈ–η•ŒοΌ"
  }
}
</i18n>

from vue-i18n-loader.

 avatar commented on June 10, 2024

The documentation of vue-loader suggests to use resourceQuery: /blockType=i18n/. Why do you use resourceQuery: /\bblockType=i18n\b/? I.e. what does the \b do?

from vue-i18n-loader.

 avatar commented on June 10, 2024

@mekeor It's an regexp-metacharacter called word boundary.

from vue-i18n-loader.

 avatar commented on June 10, 2024

I still couldn't get vue@2, vue-loader@15, vue-i18n, vue-i18n-loader and webpack@4 work together in single-file-components. I created a very minimal bare-bones repository here: https://github.com/mekeor/webpack4-vue2-vueLoader15-vueI18n-vueI18nLoader-singleFileComponent

I'm gettings this error:
2018-05-02-005258_1138x141_scrot

@Lanfei Would you mind telling me what I'm doing wrong? You seem to have working exactly what I'm trying to achieve.

from vue-i18n-loader.

smares avatar smares commented on June 10, 2024

You ask about the blockType rule that parses the i18n blocks but then your Webpack configuration doesn't even include it and instead you are telling Webpack to pass .i18n files to vue-i18n-loader.

Also, the loader is @kazupon/vue-i18n-loader

from vue-i18n-loader.

Edza avatar Edza commented on June 10, 2024

The workaround has a heavy performance impact on compilation. I also can not exclude node_modules folder (vue-loader complains it can not find it's own folder for some reason).

Please make fixing this a priority, I'll see if I can contribute. Can't we use the generic i18n-loader and take the working parts and insert into vue?

from vue-i18n-loader.

Lanfei avatar Lanfei commented on June 10, 2024

@mekeor Sorry that I was on a trip in the past week, have you solved your problem?

from vue-i18n-loader.

 avatar commented on June 10, 2024

Yes, I solved my problem (– by moving away from vue-i18n, sorry –) but thank you :)

from vue-i18n-loader.

Edza avatar Edza commented on June 10, 2024

@mekeor Where did you move? Just using the regular webpack i18n loader? I'm using the workaround and it works fine more or less.

from vue-i18n-loader.

 avatar commented on June 10, 2024

My project is tiny, so I just wrote my own few lines of code for that little internationalization I need. πŸ€·β€β™€οΈ

from vue-i18n-loader.

Edza avatar Edza commented on June 10, 2024

Ah well, I work with many other programmers on the vue components, so we really need this thing to work. But yeah, the workarond is ok, the performance impact is not bad if you set json-loader to use only your .json files in your specific i18n .json file folder.

from vue-i18n-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.