Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
2cc0fe63
Commit
2cc0fe63
authored
Apr 28, 2017
by
cinwell.li
Committed by
baiyaaaaa
Apr 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
i18n: update doc about vue-i18n@6.x (#4471)
* i18n: update doc about vue-i18n@6.x * i18n: fix typo
parent
f9894799
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
7 deletions
+79
-7
examples/docs/en-US/i18n.md
examples/docs/en-US/i18n.md
+39
-3
examples/docs/zh-CN/i18n.md
examples/docs/zh-CN/i18n.md
+39
-3
src/locale/index.js
src/locale/index.js
+1
-1
No files found.
examples/docs/en-US/i18n.md
View file @
2cc0fe63
...
...
@@ -37,9 +37,9 @@ webpack.config.js
}
```
## Compatible with `vue-i18n`
## Compatible with `vue-i18n
@5.x
`
Element is compatible with
[
vue-i18n
](
https://github.com/kazupon/vue-i18n
)
, which makes multilingual switching even easier.
Element is compatible with
[
vue-i18n
@5.x
](
https://github.com/kazupon/vue-i18n
)
, which makes multilingual switching even easier.
```
javascript
import
Vue
from
'
vue
'
...
...
@@ -56,7 +56,7 @@ Vue.locale('zh-cn', zhLocale)
Vue
.
locale
(
'
en
'
,
enLocale
)
```
## Compatib
ility
with other i18n plugins
## Compatib
le
with other i18n plugins
Element may not be compatible with i18n plugins other than vue-i18n, but you can customize how Element processes i18n.
```
javascript
...
...
@@ -72,6 +72,42 @@ Vue.use(Element, {
})
```
## Compatible with `vue-i18n@6.x`
You need to manually handle it for compatibility with
`6.x`
.
```
javascript
import
Vue
from
'
vue
'
import
Element
from
'
element-ui
'
import
VueI18n
from
'
vue-i18n
'
import
enLocale
from
'
element-ui/lib/locale/lang/en
'
import
zhLocale
from
'
element-ui/lib/locale/lang/zh-CN
'
Vue
.
use
(
VueI18n
)
const
messages
=
{
en
:
{
message
:
'
hello
'
,
...
enLocale
// Or use `Object.assign({ message: 'hello' }, enLocale)`
},
zh
:
{
message
:
'
你好
'
,
...
zhLocale
// Or use `Object.assign({ message: '你好' }, zhLocale)`
}
}
// Create VueI18n instance with options
const
i18n
=
new
VueI18n
({
locale
:
'
en
'
,
// set locale
messages
,
// set locale messages
})
Vue
.
use
(
Element
,
{
i18n
:
key
=>
i18n
.
vm
.
_t
(
key
)
})
new
Vue
({
i18n
}).
$mount
(
'
#app
'
)
```
## Import via CDN
```
html
...
...
examples/docs/zh-CN/i18n.md
View file @
2cc0fe63
...
...
@@ -49,9 +49,9 @@ Vue.component(Select.name, Select)
}
```
## 兼容 `vue-i18n`
## 兼容 `vue-i18n
@5.x
`
Element 兼容
[
vue-i18n
](
https://github.com/kazupon/vue-i18n
)
,搭配使用能更方便地实现多语言切换。
Element 兼容
[
vue-i18n
@5.x
](
https://github.com/kazupon/vue-i18n
)
,搭配使用能更方便地实现多语言切换。
```
javascript
import
Vue
from
'
vue
'
...
...
@@ -69,7 +69,7 @@ Vue.locale('en', enLocale)
```
## 兼容其他 i18n 插件
如果不使用
`vue-i18n`
,而是用其他的 i18n 插件,Element 将无法兼容,但是可以自定义 Element 的 i18n 的处理方法。
如果不使用
`vue-i18n
@5.x
`
,而是用其他的 i18n 插件,Element 将无法兼容,但是可以自定义 Element 的 i18n 的处理方法。
```
javascript
import
Vue
from
'
vue
'
...
...
@@ -84,6 +84,42 @@ Vue.use(Element, {
})
```
## 兼容 `vue-i18n@6.x`
默认不支持 6.x 的
`vue-i18n`
,你需要手动处理。
```
javascript
import
Vue
from
'
vue
'
import
Element
from
'
element-ui
'
import
VueI18n
from
'
vue-i18n
'
import
enLocale
from
'
element-ui/lib/locale/lang/en
'
import
zhLocale
from
'
element-ui/lib/locale/lang/zh-CN
'
Vue
.
use
(
VueI18n
)
const
messages
=
{
en
:
{
message
:
'
hello
'
,
...
enLocale
// 或者用 Object.assign({ message: 'hello' }, enLocale)
},
zh
:
{
message
:
'
你好
'
,
...
zhLocale
// 或者用 Object.assign({ message: '你好' }, zhLocale)
}
}
// Create VueI18n instance with options
const
i18n
=
new
VueI18n
({
locale
:
'
en
'
,
// set locale
messages
,
// set locale messages
})
Vue
.
use
(
Element
,
{
i18n
:
key
=>
i18n
.
vm
.
_t
(
key
)
})
new
Vue
({
i18n
}).
$mount
(
'
#app
'
)
```
## 通过 CDN 的方式加载语言文件
```
html
...
...
src/locale/index.js
View file @
2cc0fe63
...
...
@@ -8,7 +8,7 @@ let lang = defaultLang;
let
merged
=
false
;
let
i18nHandler
=
function
()
{
const
vuei18n
=
Object
.
getPrototypeOf
(
this
||
Vue
).
$t
;
if
(
typeof
vuei18n
===
'
function
'
)
{
if
(
typeof
vuei18n
===
'
function
'
&&
!!
Vue
.
locale
)
{
if
(
!
merged
)
{
merged
=
true
;
Vue
.
locale
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment