Comments (17)
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.
Follow-up: It works if I rename the files to *.loca. Any idea how to make it work with *.json?
from vue-i18n-loader.
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.
I am using Webpack 4.6.0 without json-loader
, and it works fine for me.
from vue-i18n-loader.
Are you using it with JSON files? As in <i18n src="locale.en.json"/>
?
from vue-i18n-loader.
{
resourceQuery: /\bblockType=i18n\b/,
loader: '@kazupon/vue-i18n-loader',
type: 'javascript/auto'
}
This works. π
from vue-i18n-loader.
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.
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.
@mekeor It's an regexp-metacharacter called word boundary.
from vue-i18n-loader.
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
@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.
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.
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.
@mekeor Sorry that I was on a trip in the past week, have you solved your problem?
from vue-i18n-loader.
Yes, I solved my problem (β by moving away from vue-i18n, sorry β) but thank you :)
from vue-i18n-loader.
@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.
My project is tiny, so I just wrote my own few lines of code for that little internationalization I need. π€·ββοΈ
from vue-i18n-loader.
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)
- update install instructions HOT 5
- Scoping of i18n blocks in components HOT 2
- Warning is not logged for HTML in i18n custom block HOT 1
- Support JSON and YAML Files at the same time HOT 1
- Element i18n doesn't have required attribute path HOT 1
- can this HOT 1
- Not translate from tag <i18n> HOT 3
- Action Required: Fix Renovate Configuration
- Doesn't work with "pluralizationRules" HOT 1
- Failed to load .yaml using webpack (filetype not detected) HOT 4
- Not working with `v-t` directive HOT 2
- I18n cannot respond to language changed in children components HOT 1
- Empty .yml files throw a warnings HOT 5
- Dependency Dashboard
- A translation that has the '@' symbol in the JSON translation file an error will occur HOT 1
- Single File Component doesn't work anymore HOT 2
- NPM & Github releases totally out-of-sync, releases after 1.1.0 not working with SFC's HOT 1
- Trailing commas are breaking the json inside the i18n element
- Fail compilation when strings are missing
- Message function not supported
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-i18n-loader.