-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(loader): add webpack fluent-vue-loader
Loader allows using <i18n> section in Vue single file components to colocate localization messages with rest of component Another benefit of loader is that localization messages can be loaded asynchroniosly if component is loaded asynchroniosly
- Loading branch information
Showing
17 changed files
with
6,063 additions
and
96 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "fluent-vue-loader-example", | ||
"scripts": { | ||
"build": "webpack", | ||
"dev": "webpack-dev-server" | ||
}, | ||
"devDependencies": { | ||
"babel-loader": "^8.1.0", | ||
"html-webpack-plugin": "^4.3.0", | ||
"vue-loader": "^15.9.1", | ||
"webpack": "^4.42.1", | ||
"webpack-cli": "^3.3.11", | ||
"webpack-dev-server": "^3.11.0" | ||
}, | ||
"dependencies": { | ||
"vue": "^2.6.11" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<form> | ||
<label>{{ $t('language') }}</label> | ||
<select v-model="locale"> | ||
<option value="en">en</option> | ||
<option value="ja">ja</option> | ||
</select> | ||
|
||
<p>{{ $t('hello') }}</p> | ||
</form> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'App', | ||
data () { | ||
return { | ||
locale: 'en' | ||
} | ||
}, | ||
created () { | ||
console.log(this) | ||
} | ||
} | ||
</script> | ||
|
||
<i18n locale="en"> | ||
language = English | ||
hello = Hello | ||
</i18n> | ||
|
||
<i18n locale="uk"> | ||
language = Ukraininan | ||
hello = Hello | ||
</i18n> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title><%= htmlWebpackPlugin.options.title %></title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Vue from 'vue' | ||
import FluentVue from '../../../fluent-vue' | ||
import App from './App.vue' | ||
|
||
const fluent = new FluentVue({ | ||
locale: 'en', | ||
bundles: [], | ||
}) | ||
|
||
Vue.use(FluentVue) | ||
|
||
const app = new Vue({ | ||
fluent, | ||
render(h) { | ||
return h(App) | ||
}, | ||
}) | ||
|
||
app.$mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const path = require('path') | ||
const { VueLoaderPlugin } = require('vue-loader') | ||
const HtmlWebpackPlugin = require('html-webpack-plugin') | ||
|
||
module.exports = { | ||
mode: 'development', | ||
entry: { | ||
main: path.resolve(__dirname, './src/index.js'), | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: '[name].js', | ||
publicPath: '/dist/', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.vue$/, | ||
loader: 'vue-loader', | ||
}, | ||
{ | ||
test: /\.js$/, | ||
loader: 'babel-loader', | ||
}, | ||
{ | ||
resourceQuery: /blockType=i18n/, | ||
type: 'javascript/auto', | ||
use: [path.resolve(__dirname, '../dist/fluent-vue-loader.cjs.js')], | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new VueLoaderPlugin(), | ||
new HtmlWebpackPlugin({ | ||
template: 'src/index.html', | ||
}), | ||
], | ||
} |
Oops, something went wrong.