Skip to content

Commit 168655c

Browse files
committed
first commit
0 parents  commit 168655c

14 files changed

+3063
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.DS_Store
3+
dist

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020 kazuya kawaguchi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# :zap: Vite Vue I18n Starter
2+
3+
:warning: *EXPERIMENTAL* Starter for [Vite](https://github.com/vuejs/vite) + [vue-i18n-next](https://github.com/intlify/vue-i18n-next) + [TypeScript](https://www.typescriptlang.org/)
4+
5+
## :cd: Installation
6+
7+
1. Clone this repository
8+
2. `yarn`
9+
3. `yarn dev`
10+
4. open http://localshot:3000 in your browser
11+
12+
## :warning: Notice
13+
In vite current version, custom blocks is not supported yet.
14+
15+
## :copyright: License
16+
17+
[MIT](http://opensource.org/licenses/MIT)

assets/logo.png

10.3 KB
Loading

index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Starter for Vite + vue-i18n-next + TypeScript</title>
6+
</head>
7+
<body>
8+
<div id="app"></div>
9+
<script type="module" src="./src/main.ts"></script>
10+
</body>
11+
</html>

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "vite-vue-i18n-starter",
3+
"version": "0.0.0",
4+
"dependencies": {
5+
"vue": "^3.0.0-beta.14",
6+
"vue-i18n": "^9.0.0-alpha.8"
7+
},
8+
"devDependencies": {
9+
"@vue/compiler-sfc": "^3.0.0-beta.14",
10+
"typescript": "^3.9.3",
11+
"vite": "^0.16.6"
12+
},
13+
"private": true,
14+
"scripts": {
15+
"build": "vite build",
16+
"dev": "vite"
17+
}
18+
}

src/App.vue

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<img alt="Vue I18n logo" src="../assets/logo.png" />
3+
<form>
4+
<label>{{ t('language') }}</label>
5+
<select v-model="locale">
6+
<option value="en">en</option>
7+
<option value="ja">ja</option>
8+
</select>
9+
</form>
10+
<HelloI18n />
11+
</template>
12+
13+
<script lang="ts">
14+
import { useI18n } from 'vue-i18n'
15+
import HelloI18n from './components/HelloI18n.vue'
16+
17+
export default {
18+
name: 'App',
19+
components: {
20+
HelloI18n
21+
},
22+
setup() {
23+
// use global composer
24+
const { t, locale } = useI18n()
25+
return { t, locale }
26+
}
27+
}
28+
</script>
29+
30+
<style scoped>
31+
form {
32+
margin-top: 48px;
33+
}
34+
35+
label {
36+
margin-right: 8px;
37+
}
38+
</style>

src/components/HelloI18n.vue

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<template>
2+
<h1>{{ t('hello') }}</h1>
3+
<button @click="count++">{{ t('count', { count }) }}</button>
4+
</template>
5+
6+
<script lang="ts">
7+
import { ref } from 'vue'
8+
import { useI18n } from 'vue-i18n'
9+
10+
export default {
11+
name: 'HelloI18n',
12+
setup() {
13+
const count = ref(0)
14+
15+
// use local composer
16+
const { t } = useI18n({
17+
// `locale` inherit from global composer
18+
inheritLocale: true,
19+
// locale messages for local composer
20+
messages: {
21+
en: {
22+
hello: 'Hello Vue I18n 9.0 🌏!',
23+
count: 'count is: {count}'
24+
},
25+
ja: {
26+
hello: 'こんにちは Vue I18n 9.0 🌏!',
27+
count: 'カウントは{count}です'
28+
}
29+
}
30+
})
31+
32+
return { count, t }
33+
}
34+
}
35+
</script>
36+
37+
<!-- NOTE: vite doesn't support custom blocks ... -->
38+
<i18n>
39+
{
40+
"en": {
41+
"hello": "Hello Vue I18n 9.0 🌏!",
42+
"count": "count is: {count}"
43+
},
44+
"ja": {
45+
"hello": "こんにちは Vue I18n 9.0 🌏!",
46+
"count": "カウントは{count}です"
47+
}
48+
}
49+
</i18n>

src/index.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#app {
2+
font-family: Avenir, Helvetica, Arial, sans-serif;
3+
-webkit-font-smoothing: antialiased;
4+
-moz-osx-font-smoothing: grayscale;
5+
text-align: center;
6+
color: #2c3e50;
7+
margin-top: 60px;
8+
}

src/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"language": "Languages"
3+
}

src/locales/ja.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"language": "言語"
3+
}

src/main.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { createApp } from 'vue'
2+
import { createI18n } from 'vue-i18n'
3+
import App from './App.vue'
4+
import './index.css'
5+
import en from './locales/en.json'
6+
import ja from './locales/ja.json'
7+
8+
const i18n = createI18n({
9+
locale: 'en',
10+
messages: {
11+
en,
12+
ja
13+
}
14+
})
15+
16+
createApp(App).use(i18n).mount('#app')

tsconfig.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
5+
/* Basic Options */
6+
// "incremental": true, /* Enable incremental compilation */
7+
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8+
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9+
"lib": ["dom", "esnext"], /* Specify library files to be included in the compilation. */
10+
// "allowJs": true, /* Allow javascript files to be compiled. */
11+
// "checkJs": true, /* Report errors in .js files. */
12+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
13+
// "declaration": true, /* Generates corresponding '.d.ts' file. */
14+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15+
// "sourceMap": true, /* Generates corresponding '.map' file. */
16+
// "outFile": "./", /* Concatenate and emit output to single file. */
17+
// "outDir": "./", /* Redirect output structure to the directory. */
18+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19+
// "composite": true, /* Enable project compilation */
20+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
21+
// "removeComments": true, /* Do not emit comments to output. */
22+
// "noEmit": true, /* Do not emit outputs. */
23+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
24+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26+
27+
/* Strict Type-Checking Options */
28+
"strict": true, /* Enable all strict type-checking options. */
29+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
30+
// "strictNullChecks": true, /* Enable strict null checks. */
31+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
32+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
33+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
34+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
35+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
36+
37+
/* Additional Checks */
38+
// "noUnusedLocals": true, /* Report errors on unused locals. */
39+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
40+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
41+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42+
43+
/* Module Resolution Options */
44+
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
45+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
46+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
47+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
48+
// "typeRoots": [], /* List of folders to include type definitions from. */
49+
"types": [
50+
"./node_modules/@types",
51+
"./node_modules/vue-i18n/dist"
52+
], /* Type declaration files to be included in compilation. */
53+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
54+
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
55+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
56+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
57+
58+
/* Source Map Options */
59+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
60+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
61+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
62+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
63+
64+
/* Experimental Options */
65+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
66+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
67+
68+
/* Advanced Options */
69+
"skipLibCheck": true, /* Skip type checking of declaration files. */
70+
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
71+
},
72+
"exclude": ["node_modules", "dist"]
73+
}

0 commit comments

Comments
 (0)