forked from TencentBlueKing/ci-CodeCCCheckAtom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
154 additions
and
40 deletions.
There are no files selected for viewing
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
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
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
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,46 @@ | ||
import Vue from 'vue'; | ||
import VueI18n from 'vue-i18n'; | ||
import Cookies from 'js-cookie'; | ||
import langMessages from './lang/messages'; | ||
import { locale, lang } from 'bk-magic-vue'; | ||
|
||
Vue.use(VueI18n); | ||
|
||
const languageMaps = { | ||
zh_cn: 'zh-CN', | ||
'zh-cn': 'zh-CN', | ||
zh: 'zh-CN', | ||
}; | ||
|
||
const messages = { | ||
'zh-CN': Object.assign(lang.zhCN, langMessages['zh-CN']), | ||
en: Object.assign(lang.enUS, langMessages.en), | ||
}; | ||
|
||
let curLocale = Cookies.get('blueking_language') || 'zh-CN'; | ||
curLocale = Object.prototype.hasOwnProperty.call(languageMaps, curLocale) ? languageMaps[curLocale] : curLocale; | ||
|
||
// console.log(locale, messages) | ||
|
||
const i18n = new VueI18n({ | ||
locale: curLocale, | ||
fallbackLocale: 'zh-CN', | ||
messages, | ||
silentTranslationWarn: true, // 取消本地化失败时输出的警告 | ||
missing(locale, path) { | ||
const parsedPath = i18n._path.parsePath(path) // eslint-disable-line | ||
return parsedPath[parsedPath.length - 1]; | ||
}, | ||
}); | ||
|
||
locale.i18n((key, value) => i18n.t(key, value)); | ||
|
||
export const toggleLang = () => { | ||
i18n.locale = i18n.locale === 'zh-CN' ? 'en' : 'zh-CN'; | ||
|
||
Cookies.set('blueking_language', i18n.locale); | ||
}; | ||
|
||
export const language = i18n.locale; | ||
|
||
export default 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,4 @@ | ||
{ | ||
"共x条规则": "共{sum}条规则", | ||
"由x发布": "由{name}发布" | ||
} |
Oops, something went wrong.