feat: add statements and phrase mode for i18n-extend plugin; 🌟

新增:i18n-extend 插件增加语句模式和词组模式;
master
iczer 4 years ago
parent fa3fa22f3c
commit 2cb54136b5
  1. 4
      src/pages/form/advancedForm/i18n-repository.js
  2. 4
      src/pages/form/advancedForm/i18n-task.js
  3. 19
      src/plugins/i18n-extend.js

@ -21,8 +21,8 @@ module.exports = {
type: '倉庫類型',
},
US: {
input: 'Please enter ',
select: 'Please select ',
input: 'Please enter',
select: 'Please select',
name: 'Repository Name',
domain: 'Repository Domain',
manager: 'Repository Manager',

@ -21,8 +21,8 @@ module.exports = {
type: '任務類型',
},
US: {
input: 'Please enter ',
select: 'Please select ',
input: 'Please enter',
select: 'Please select',
name: 'Task Name',
describe: 'Task Describe',
executor: 'Executor',

@ -1,15 +1,26 @@
// 语句模式
const MODE = {
STATEMENTS: 's', //语句模式
PHRASAL: 'p', //词组模式
}
const VueI18nPlugin = {
install: function (Vue) {
Vue.mixin({
methods: {
$ta(syntaxKey) {
$ta(syntaxKey, mode) {
let _mode = mode || MODE.STATEMENTS
let keys = syntaxKey.split('|')
let message = ''
let _this = this
let locale = this.$i18n.locale
let message = ''
let splitter = locale == 'US' ? ' ' : ''
// 拼接 message
keys.forEach(key => {
message += _this.$t(key)
message += _this.$t(key) + splitter
})
if (keys.length > 0) {
// 英文环境语句模式下,转换单词大小写
if (keys.length > 0 && _mode == MODE.STATEMENTS && locale == 'US') {
message = message.charAt(0).toUpperCase() + message.toLowerCase().substring(1)
}
return message

Loading…
Cancel
Save