Commit bff90818cf1cd1b89beda95aceb0d3b7edec5516
Committed by
GitHub
Merge pull request #2351 from SergioCrisostomo/i18n
use dist's locale
Showing
2 changed files
with
7 additions
and
38 deletions
Show diff stats
src/index.js
... | ... | @@ -50,7 +50,6 @@ import Upload from './components/upload'; |
50 | 50 | import {Row, Col} from './components/grid'; |
51 | 51 | import {Select, Option, OptionGroup} from './components/select'; |
52 | 52 | import locale from './locale/index'; |
53 | -import locales from './locale/locales'; | |
54 | 53 | |
55 | 54 | const iview = { |
56 | 55 | Affix, |
... | ... | @@ -155,7 +154,6 @@ module.exports = { // eslint-disable-line no-undef |
155 | 154 | locale: locale.use, |
156 | 155 | i18n: locale.i18n, |
157 | 156 | install, |
158 | - locales, | |
159 | 157 | Affix, |
160 | 158 | Alert, |
161 | 159 | AutoComplete, |
... | ... | @@ -223,4 +221,10 @@ module.exports = { // eslint-disable-line no-undef |
223 | 221 | Upload |
224 | 222 | }; |
225 | 223 | |
226 | -module.exports.default = module.exports; // eslint-disable-line no-undef | |
227 | 224 | \ No newline at end of file |
225 | +module.exports.lang = (code) => { // eslint-disable-line no-undef | |
226 | + const langObject = window['iview/locale'].default; | |
227 | + if (code === langObject.i.locale) locale.use(langObject); | |
228 | + else console.log(`The ${code} language pack is not loaded.`); // eslint-disable-line no-console | |
229 | +}; | |
230 | + | |
231 | +module.exports.default = module.exports; // eslint-disable-line no-undef | ... | ... |
src/locale/locales.js deleted
1 | -// export all locale files | |
2 | - | |
3 | -import deDE from './lang/de-DE.js'; | |
4 | -import enUS from './lang/en-US.js'; | |
5 | -import esES from './lang/es-ES.js'; | |
6 | -import frFR from './lang/fr-FR.js'; | |
7 | -import idID from './lang/id-ID.js'; | |
8 | -import jaJP from './lang/ja-JP.js'; | |
9 | -import koKR from './lang/ko-KR.js'; | |
10 | -import ptBR from './lang/pt-BR.js'; | |
11 | -import ptPT from './lang/pt-PT.js'; | |
12 | -import ruRU from './lang/ru-RU.js'; | |
13 | -import svSE from './lang/sv-SE.js'; | |
14 | -import trTR from './lang/tr-TR.js'; | |
15 | -import viVN from './lang/vi-VN.js'; | |
16 | -import zhCN from './lang/zh-CN.js'; | |
17 | -import zhTW from './lang/zh-TW.js'; | |
18 | - | |
19 | -export default { | |
20 | - 'de-DE': deDE, | |
21 | - 'en-US': enUS, | |
22 | - 'es-ES': esES, | |
23 | - 'fr-FR': frFR, | |
24 | - 'id-ID': idID, | |
25 | - 'ja-JP': jaJP, | |
26 | - 'ko-KR': koKR, | |
27 | - 'pt-BR': ptBR, | |
28 | - 'pt-PT': ptPT, | |
29 | - 'ru-RU': ruRU, | |
30 | - 'sv-SE': svSE, | |
31 | - 'tr-TR': trTR, | |
32 | - 'vi-VN': viVN, | |
33 | - 'zh-CN': zhCN, | |
34 | - 'zh-TW': zhTW | |
35 | -}; |