diff --git a/package.json b/package.json index b323524..716314e 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "author": "alan ", "license": "ISC", "devDependencies": { + "@types/node": "^12.0.2", "@typescript-eslint/eslint-plugin": "^1.6.0", "@typescript-eslint/parser": "^1.6.0", "copy-webpack-plugin": "^5.0.2", diff --git a/src/app/app.model.ts b/src/app/app.model.ts index 2b57da2..6294f1e 100644 --- a/src/app/app.model.ts +++ b/src/app/app.model.ts @@ -7,7 +7,7 @@ const Model: ModelType = { childContext: ['tab', 'linkList', 'linkSelected', 'linkUpdate', 'moreLinkSelected', 'statusSelected', 'connectionNameErr'], state () { return { - tab: '数据连接管理', + tab: BI.i18nText('BI-Data_Connection_Management'), linkList, linkSelected: {}, linkUpdate: {}, diff --git a/src/app/link_set/left/left.service.ts b/src/app/link_set/left/left.service.ts index 9a915a3..9c8350e 100644 --- a/src/app/link_set/left/left.service.ts +++ b/src/app/link_set/left/left.service.ts @@ -10,7 +10,7 @@ export const getLinks = (linkList: LinkType[]): any => { title: item.connectionName, id: item.connectionId, creator: item.creator, - text: item.text ? item.text : '默认', + text: item.text ? item.text : BI.i18nText('BI-Default'), }); }); diff --git a/src/app/link_set/left/left_item/left.item.component.ts b/src/app/link_set/left/left_item/left.item.component.ts index dab4019..49fd551 100644 --- a/src/app/link_set/left/left_item/left.item.component.ts +++ b/src/app/link_set/left/left_item/left.item.component.ts @@ -24,7 +24,7 @@ const Widget: WidgetType = { cls: 'link-font', height: 24, width: 26, - text: '连接', + text: BI.i18nText('BI-Connections'), title, }, { @@ -41,25 +41,25 @@ const Widget: WidgetType = { { type: ItemIcon, cls: 'link-text-font', - title: '测试连接', + title: BI.i18nText('BI-Test-Connection'), id, }, { type: ItemIcon, cls: 'copy-font', - title: '复制', + title: BI.i18nText('BI-Copy'), id, }, { type: ItemIcon, cls: 'info-font', - title: `类型:${text === 'DESIGNER' ? '其他' : text} \r\n创建者:${creator}`, + title: `${BI.i18nText('BI-Type')}:${text === 'DESIGNER' ? BI.i18nText('BI-Other') : text} \r\n${BI.i18nText('BI-Creator')}:${creator}`, id, }, { type: ItemIcon, cls: 'delete-font', - title: '删除', + title: BI.i18nText('BI-Delete'), id, }, ], diff --git a/src/app/link_set/left/left_item/left.item.icon.component.ts b/src/app/link_set/left/left_item/left.item.icon.component.ts index fa7354c..cded2ae 100644 --- a/src/app/link_set/left/left_item/left.item.icon.component.ts +++ b/src/app/link_set/left/left_item/left.item.icon.component.ts @@ -10,7 +10,7 @@ const Widget: WidgetType = { const that = this; let iconContent: any = null; let combo: any = null; - if (title === '删除') { + if (title === BI.i18nText('BI-Delete')) { return { type: BubbleCombo, direction: 'bottom', @@ -30,7 +30,7 @@ const Widget: WidgetType = { }, popup: { type: TextBubblePopupBarView, - text: '确定删除该数据连接?', + text: BI.i18nText('BI-Connection-Make-Sure-Delete'), listeners: [{ eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON, action (type: boolean) { @@ -70,7 +70,7 @@ const Widget: WidgetType = { }, mounted() { const {title, id} = this.options; - if (title !== '删除') { + if (title !== BI.i18nText('BI-Delete')) { this.element.on('click', (event: any) => { event.stopPropagation(); this.store.onIconClick(title, id); diff --git a/src/app/link_set/link-set.component.ts b/src/app/link_set/link-set.component.ts index 9597ea3..8b89d13 100644 --- a/src/app/link_set/link-set.component.ts +++ b/src/app/link_set/link-set.component.ts @@ -10,7 +10,7 @@ const Widget: WidgetType = { }, watch:{ tab(tab: string) { - this.setVisible(tab === '数据连接管理'); + this.setVisible(tab === BI.i18nText('BI-Data_Connection_Management')); }, }, render() { diff --git a/src/app/link_set/link-set.model.ts b/src/app/link_set/link-set.model.ts index f9761f0..45e1d2a 100644 --- a/src/app/link_set/link-set.model.ts +++ b/src/app/link_set/link-set.model.ts @@ -33,17 +33,17 @@ const Model: ModelType = { }, onIconClick(title: string, id: string) { switch (title) { - case '删除': + case BI.i18nText('BI-Delete'): deleteConnection(id, () => { this.model.linkList = [...this.model.linkList.filter((item: LinkType) => item.connectionId !== id)]; this.model.linkSelected = {}; this.model.linkUpdate = {}; }); break; - case '测试连接': + case BI.i18nText('BI-Test-Connection'): this._textLink(id); break; - case '复制': + case BI.i18nText('BI-Copy'): this.noSaveConfirm(() => { this.copyLink(id); }); @@ -53,16 +53,16 @@ const Model: ModelType = { } }, _textLink(id: string) { - const loadingId = dialog.loading('正在测试连接,请稍候...'); + const loadingId = dialog.loading(BI.i18nText('BI-Connection-Testing')); const link = this.model.linkList.find((item: LinkType) => item.connectionId === id); testConnection(link, (res: any) => { dialog.close(loadingId); if (res && res.errorCode) { - dialog.linkFail(`${link.connectionName}测试连接失败`, res.errorMsg, () => { + dialog.linkFail(`${link.connectionName}${BI.i18nText('BI-Connection-Test-Fail')}`, res.errorMsg, () => { this._textLink(id); }); } else { - dialog.success('连接成功'); + dialog.success(BI.i18nText('BI-Connection-Test-Success')); } }); }, @@ -125,7 +125,7 @@ const Model: ModelType = { }, setNewLink(value: string) { if (!databaseTyle.some(item => item.text === value) && !BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${value.toLowerCase()}.edit`)) { - dialog.error('找不到该连接的配置信息'); + dialog.error(BI.i18nText('BI-Connection-Option-Cannot-Find')); return; } @@ -167,7 +167,7 @@ const Model: ModelType = { }, noSaveConfirm(cb: Function) { if (this.model.linkSelected && this.model.linkSelected.isSelected) { - dialog.confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => { + dialog.confirm(BI.i18nText('BI-Connection-Config-No-Save'), (isConfirm: boolean) => { if (isConfirm) { this.saveLink(); } else { diff --git a/src/app/link_set/more/more.link.component.ts b/src/app/link_set/more/more.link.component.ts index 3c0eac4..163c5e0 100644 --- a/src/app/link_set/more/more.link.component.ts +++ b/src/app/link_set/more/more.link.component.ts @@ -15,7 +15,7 @@ const Widget: WidgetType = { items:[{ type: SearchEditor, width: 300, - watermark: '搜索', + watermark: BI.i18nText('BI-Search'), }], }, height: 30, diff --git a/src/app/link_set/more/more.link.service.ts b/src/app/link_set/more/more.link.service.ts index 1e4f9ca..247573d 100644 --- a/src/app/link_set/more/more.link.service.ts +++ b/src/app/link_set/more/more.link.service.ts @@ -7,7 +7,7 @@ export const moreLink = (onConfirm?: Function): void => { BI.Popovers.create(id, { type: 'bi.bar_popover', size: 'normal', - header: '更多数据连接', + header: BI.i18nText('BI-Connection-More-Title'), width: 550, height: 500, body: { @@ -27,7 +27,7 @@ export const moreLink = (onConfirm?: Function): void => { lgap: 10, items: [{ type: 'bi.button', - text: '取消', + text: BI.i18nText('BI-Basic_Cancel'), value: 1, level: 'ignore', handler (v: any) { @@ -35,7 +35,7 @@ export const moreLink = (onConfirm?: Function): void => { }, }, { type: 'bi.button', - text: '确定', + text: BI.i18nText('BI-Basic_Sure'), disabled: true, value: 0, ref(ref: any) { diff --git a/src/app/link_set/right/nothing.component.ts b/src/app/link_set/right/nothing.component.ts index ef4d938..e18db76 100644 --- a/src/app/link_set/right/nothing.component.ts +++ b/src/app/link_set/right/nothing.component.ts @@ -19,13 +19,7 @@ const Widget: WidgetType = { type:Label, cls: 'bi-tips', height: 20, - text:'请选择左侧数据连接或点击新建数据连接', - }, - { - type:Label, - cls: 'bi-tips', - height: 20, - text:'平台仅支持使用JDBC的数据连接的管理', + text: BI.i18nText('BI-Connection-Plase-Add-One'), }, ], diff --git a/src/app/link_set/right/right_edit/right.edit.component.ts b/src/app/link_set/right/right_edit/right.edit.component.ts index 52dc0a8..4fb5312 100644 --- a/src/app/link_set/right/right_edit/right.edit.component.ts +++ b/src/app/link_set/right/right_edit/right.edit.component.ts @@ -32,8 +32,8 @@ const Widget: WidgetType = { items: [ { type: FormItem, - text: '数据连接名', - hint: '*修改数据连接名会影响相关数据表和仪表板', + text: BI.i18nText('BI-Connection-Form-ConnectionName'), + hint: BI.i18nText('BI-Connection-Form-ConnectionName-Change-Confirm'), form:{ type: Editor, cls: 'bi-border', @@ -60,7 +60,7 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '第一步', + text: BI.i18nText('BI-First_Step'), height: 400, form:{ type: Vertical, @@ -68,7 +68,7 @@ const Widget: WidgetType = { items:[ { type: FormItem, - text: '驱动器', + text: BI.i18nText('BI-Connection-Form-Driver'), form:{ type: TextValueCombo, cls: 'bi-border', @@ -88,11 +88,11 @@ const Widget: WidgetType = { }, { type: FormItem, - text: 'URL', + text: BI.i18nText('BI-Connection-Form-URL'), form:{ type: Editor, cls: 'bi-border', - watermark:'请输入', + watermark:BI.i18nText('BI-Connection-Form-Place-Input'), width: 300, value: linkSelected.url, listeners: [{ @@ -108,12 +108,12 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '编码', + text: BI.i18nText('BI-Connection-Form-OriginalCharsetName'), form:{ type: TextValueCombo, cls: 'bi-border', width: 300, - text: linkSelected.originalCharsetName === '' ? '自动' : linkSelected.originalCharsetName, + text: linkSelected.originalCharsetName === '' ? BI.i18nText('BI-Connection-Form-Auto') : linkSelected.originalCharsetName, items: BI.Constants.getConstant(charset), listeners: [{ eventName: BI.TextValueCombo.EVENT_CHANGE, @@ -128,12 +128,12 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '用户名', + text: BI.i18nText('BI-Connection-Form-UserName'), form:{ type: Editor, cls: 'bi-border', allowBlank:true, - watermark:'请输入', + watermark:BI.i18nText('BI-Connection-Form-Place-Input'), width: 300, value: linkSelected.user, listeners: [{ @@ -149,13 +149,13 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '密码', + text: BI.i18nText('BI-Connection-Form-Password'), form:{ type: Editor, cls: 'bi-border', inputType:'password', allowBlank:true, - watermark:'请输入', + watermark:BI.i18nText('BI-Connection-Form-Place-Input'), width: 300, value: linkSelected.password, listeners: [{ @@ -171,17 +171,17 @@ const Widget: WidgetType = { }, { type: Title, - text: '连接池属性', + text: BI.i18nText('BI-Connection-Form-Pool-Properties'), }, { type: FormItem, - text: 'SQL验证查询', + text: BI.i18nText('BI-Connection-Form-SQL-Validation-Query'), height: 100, form:{ type: TextAreaEditor, cls: 'bi-border', allowBlank:true, - watermark:'请输入', + watermark:BI.i18nText('BI-Connection-Form-Place-Input'), width: 300, height:100, value: linkSelected.validationQuery, @@ -198,10 +198,10 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '获取连接前校验', + text: BI.i18nText('BI-Connection-Form-Connection-Check'), form:{ type: MultiSelectItem, - text: '是', + text: BI.i18nText('BI-Yes'), selected: linkSelected.testOnBorrow, width: 60, listeners: [{ @@ -217,15 +217,15 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '最大活动连接数', + text: BI.i18nText('BI-Connection-Form-Connection-Max-Number'), form:{ type: Editor, cls: 'bi-border', allowBlank:true, - watermark:'请输入', + watermark:BI.i18nText('BI-Connection-Form-Place-Input'), width: 60, value: linkSelected.maxActive, - errorText: '请输入有效的正整数', + errorText: BI.i18nText('BI-Connection-Form-Place-Input-Number'), validationChecker (v: string) { if (/^\+?[1-9][0-9]*$/.test(v)) { return true; @@ -249,19 +249,19 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '第二步', + text: BI.i18nText('BI-Second_Step'), form: { type: Button, - text: '测试连接', + text: BI.i18nText('BI-Test-Connection'), level: 'ignore', }, }, { type: FormItem, - text: '第三步', + text: BI.i18nText('BI-Third_Step'), form: { type: FormItem, - text: '模式', + text: BI.i18nText('BI-Connection-Form-Pattern'), form: { type: Editor, cls: 'bi-border', diff --git a/src/app/link_set/right/right_edit/right.edit.constant.ts b/src/app/link_set/right/right_edit/right.edit.constant.ts index 28a5dfe..d74d953 100644 --- a/src/app/link_set/right/right_edit/right.edit.constant.ts +++ b/src/app/link_set/right/right_edit/right.edit.constant.ts @@ -1,4 +1,5 @@ export const ConstantName = 'bi.constant.database.conf.charset.list'; + export const Constant = BI.constant(ConstantName, [ { text: '自动', diff --git a/src/app/link_set/right/right_edit/right.edit.mysql.component.ts b/src/app/link_set/right/right_edit/right.edit.mysql.component.ts index 7fba51b..2486c13 100644 --- a/src/app/link_set/right/right_edit/right.edit.mysql.component.ts +++ b/src/app/link_set/right/right_edit/right.edit.mysql.component.ts @@ -20,8 +20,8 @@ const Widget: WidgetType = { items: [ { type: FormItem, - text: '数据连接名', - hint: '*修改数据连接名会影响相关数据表和仪表板', + text: BI.i18nText('BI-Connection-Form-ConnectionName'), + hint: BI.i18nText('BI-Connection-Form-ConnectionName-Change-Confirm'), form:{ type: Editor, cls: 'bi-border', @@ -40,7 +40,7 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '驱动器', + text: BI.i18nText('BI-Connection-Form-Driver'), form:{ type: TextValueCombo, cls: 'bi-border', @@ -60,11 +60,11 @@ const Widget: WidgetType = { }, { type: FormItem, - text: 'URL', + text: BI.i18nText('BI-Connection-Form-URL'), form:{ type: Editor, cls: 'bi-border', - watermark:'请输入', + watermark:BI.i18nText('BI-Connection-Form-Place-Input'), width: 300, value: linkSelected.url, listeners: [{ @@ -80,12 +80,12 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '编码', + text: BI.i18nText('BI-Connection-Form-OriginalCharsetName'), form:{ type: TextValueCombo, cls: 'bi-border', width: 300, - text: linkSelected.originalCharsetName === '' ? '自动' : linkSelected.originalCharsetName, + text: linkSelected.originalCharsetName === '' ? BI.i18nText('BI-Connection-Form-Auto') : linkSelected.originalCharsetName, items: BI.Constants.getConstant(charset), listeners: [{ eventName: BI.TextValueCombo.EVENT_CHANGE, @@ -100,12 +100,12 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '用户名', + text: BI.i18nText('BI-Connection-Form-UserName'), form:{ type: Editor, cls: 'bi-border', allowBlank:true, - watermark:'请输入', + watermark:BI.i18nText('BI-Connection-Form-Place-Input'), width: 300, value: linkSelected.user, listeners: [{ @@ -121,13 +121,13 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '密码', + text: BI.i18nText('BI-Connection-Form-Password'), form:{ type: Editor, cls: 'bi-border', inputType:'password', allowBlank:true, - watermark:'请输入', + watermark:BI.i18nText('BI-Connection-Form-Place-Input'), width: 300, value: linkSelected.password, listeners: [{ @@ -143,17 +143,17 @@ const Widget: WidgetType = { }, { type: Title, - text: '连接池属性', + text: BI.i18nText('BI-Connection-Form-Pool-Properties'), }, { type: FormItem, - text: 'SQL验证查询', + text: BI.i18nText('BI-Connection-Form-SQL-Validation-Query'), height: 100, form:{ type: TextAreaEditor, cls: 'bi-border', allowBlank:true, - watermark:'请输入', + watermark:BI.i18nText('BI-Connection-Form-Place-Input'), width: 300, height:100, value: linkSelected.validationQuery, @@ -170,10 +170,10 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '获取连接前校验', + text: BI.i18nText('BI-Connection-Form-Connection-Check'), form:{ type: MultiSelectItem, - text: '是', + text: BI.i18nText('BI-Yes'), selected: linkSelected.testOnBorrow, width: 60, listeners: [{ @@ -189,15 +189,15 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '最大活动连接数', + text: BI.i18nText('BI-Connection-Form-Connection-Max-Number'), form:{ type: Editor, cls: 'bi-border', allowBlank:true, - watermark:'请输入', + watermark:BI.i18nText('BI-Connection-Form-Place-Input'), width: 60, value: linkSelected.maxActive, - errorText: '请输入有效的正整数', + errorText: BI.i18nText('BI-Connection-Form-Place-Input-Number'), validationChecker (v: string) { if (/^\+?[1-9][0-9]*$/.test(v)) { return true; @@ -218,10 +218,10 @@ const Widget: WidgetType = { }, { type: FormItem, - text: '测试连接', + text: BI.i18nText('BI-Test-Connection'), form: { type: Button, - text: '测试连接', + text: BI.i18nText('BI-Test-Connection'), level: 'ignore', }, }, diff --git a/src/app/link_set/right/right_show/right.show.component.ts b/src/app/link_set/right/right_show/right.show.component.ts index fa6b668..ca7b736 100644 --- a/src/app/link_set/right/right_show/right.show.component.ts +++ b/src/app/link_set/right/right_show/right.show.component.ts @@ -17,51 +17,51 @@ const Widget: WidgetType = { items: [ { type: BothSide, - leftText: '数据连接名', + leftText: BI.i18nText('BI-Connection-Form-ConnectionName'), rightText: linkSelected.connectionName, }, { type: BothSide, - leftText: '驱动器', + leftText: BI.i18nText('BI-Connection-Form-Driver'), rightText: linkSelected.driver, }, { type: BothSide, - leftText: 'URL', + leftText: BI.i18nText('BI-Connection-Form-URL'), rightText: linkSelected.url, }, { type: BothSide, - leftText: '编码', - rightText: linkSelected.originalCharsetName === '' ? '自动' : linkSelected.originalCharsetName, + leftText: BI.i18nText('BI-Connection-Form-OriginalCharsetName'), + rightText: linkSelected.originalCharsetName === '' ? BI.i18nText('BI-Connection-Form-Auto') : linkSelected.originalCharsetName, }, { type: BothSide, - leftText: '用户名', + leftText: BI.i18nText('BI-Connection-Form-UserName'), rightText: linkSelected.user, }, { type: BothSide, - leftText: '密码', + leftText: BI.i18nText('BI-Connection-Form-Password'), rightText: linkSelected.password, }, { type: Title, - text: '连接池属性', + text: BI.i18nText('BI-Connection-Form-Pool-Properties'), }, { type: BothSide, - leftText: 'SQL验证查询', + leftText: BI.i18nText('BI-Connection-Form-SQL-Validation-Query'), rightText: linkSelected.validationQuery, }, { type: BothSide, - leftText: '获取连接前校验', - rightText: linkSelected.testOnBorrow ? '是' : '否', + leftText: BI.i18nText('BI-Connection-Form-Connection-Check'), + rightText: linkSelected.testOnBorrow ? BI.i18nText('BI-Yes') : BI.i18nText('BI-No'), }, { type: BothSide, - leftText: '最大连接数量', + leftText: BI.i18nText('BI-Connection-Form-Connection-Max-Number'), rightText: linkSelected.maxActive, }, ], diff --git a/src/app/link_set/right/right_title/right.title.component.ts b/src/app/link_set/right/right_title/right.title.component.ts index 308ce12..95c4ca8 100644 --- a/src/app/link_set/right/right_title/right.title.component.ts +++ b/src/app/link_set/right/right_title/right.title.component.ts @@ -12,6 +12,7 @@ const Widget: WidgetType = { const linkList: LinkType[] = this.model.linkList; const that = this; const {isEdit} = this.options; + const title = linkSelected.text === 'other' ? BI.i18nText('BI-Connection-Other') : linkSelected.text; return { type: Left, @@ -21,13 +22,13 @@ const Widget: WidgetType = { { type: Label, cls: 'right-title-text', - text: `数据连接(${linkSelected.text ? linkSelected.text : '默认'})`, + text: `${BI.i18nText('BI-Data_Connections')}(${title ? title : BI.i18nText('BI-Default')})`, }, { type: Button, cls:'right-title-button', invisible: isEdit, - text: '编辑', + text: BI.i18nText('BI-Edit'), handler() { that.store.setEdit(true); }, @@ -36,11 +37,11 @@ const Widget: WidgetType = { type: Button, cls:'right-title-button', invisible: !isEdit, - text: '保存', + text: BI.i18nText('BI-Save'), handler() { const result = BI.find(linkList, (idx: number, value: LinkType) => that.model.linkUpdate.connectionName === value.connectionName && value.connectionId !== that.model.linkUpdate.connectionId); if (result) { - that.store.setConnectionNameErr('数据连接名已存在'); + that.store.setConnectionNameErr(BI.i18nText('BI-Connection-Is-Existence')); } else { that.store.saveLink(); } @@ -51,7 +52,7 @@ const Widget: WidgetType = { cls:'right-title-button', invisible: !isEdit, level: 'ignore', - text: '取消', + text: BI.i18nText('BI-Basic_Cancel'), handler() { that.store.setCancel(); }, diff --git a/src/app/link_set/select/select.component.ts b/src/app/link_set/select/select.component.ts index cdbe8e6..ec26689 100644 --- a/src/app/link_set/select/select.component.ts +++ b/src/app/link_set/select/select.component.ts @@ -17,7 +17,7 @@ const Widget: WidgetType = { adjustYOffset: 4, el: { type: 'bi.button', - text: '新建数据连接', + text: BI.i18nText('BI-Connection-New'), height: 24, }, popup: { @@ -38,17 +38,17 @@ const Widget: WidgetType = { cls: 'link-item', height: 24, width: 152, - text: '更多数据连接...', - title:'更多数据连接...', + text: BI.i18nText('BI-Connection-More'), + title: BI.i18nText('BI-Connection-More'), value: 'more', }, { type: TextItem, cls: 'link-item', height: 24, width: 152, - text: '其他', - title:'其他', - value: '其他', + text: BI.i18nText('BI-Connection-Other'), + title: BI.i18nText('BI-Connection-Other'), + value: 'other', }], layouts: [{ type: Vertical, diff --git a/src/app/link_set/select/select.service.ts b/src/app/link_set/select/select.service.ts index 37d2b08..fe05085 100644 --- a/src/app/link_set/select/select.service.ts +++ b/src/app/link_set/select/select.service.ts @@ -70,7 +70,7 @@ export const databaseTyle = [ url: 'jdbc:mysql://localhost/dbname', }, { - text:'其他', + text:'other', databaseType: 'other', driver: 'org.h2.Driver', drivers:['org.h2.Driver', 'com.fr.third.org.hsqldb.jdbcDriver', 'org.sqlite.JDBC'], @@ -266,7 +266,7 @@ export const getCnnectionName = (links: LinkType[], name: string): string => { let nameIndex = 0; const title = name.replace(/[0-9]/g, ''); const isPlugin = BI.some(plugins, (index: number, item: string) => item === title); - const startWith = isPlugin ? title : '数据连接'; + const startWith = isPlugin ? title : BI.i18nText('BI-Data_Connections'); links.forEach(link => { link.isSelected = false; diff --git a/src/app/link_status/left/left.service.ts b/src/app/link_status/left/left.service.ts index 7df380c..e1de494 100644 --- a/src/app/link_status/left/left.service.ts +++ b/src/app/link_status/left/left.service.ts @@ -10,7 +10,7 @@ export const getLinks = (linkList: LinkType[], selectTitle = ''): any => { title: item.connectionName, id: item.connectionId, creator: item.creator, - text: item.text ? item.text : '默认', + text: item.text ? item.text : BI.i18nText('BI-Default'), }); }); diff --git a/src/app/link_status/link_status.component.ts b/src/app/link_status/link_status.component.ts index 196174d..bb09f96 100644 --- a/src/app/link_status/link_status.component.ts +++ b/src/app/link_status/link_status.component.ts @@ -10,7 +10,7 @@ const Widget: WidgetType = { }, watch:{ tab(tab: string) { - this.setVisible(tab === '连接池状态'); + this.setVisible(tab === BI.i18nText('BI-Pool_Connection_Management')); }, }, render() { @@ -30,7 +30,7 @@ const Widget: WidgetType = { { type: Label, cls:'status-title', - text: '数据连接', + text: BI.i18nText('BI-Data_Connections'), }, ], }, diff --git a/src/app/link_status/right/right.card.component.ts b/src/app/link_status/right/right.card.component.ts index 6249ced..ffce69a 100644 --- a/src/app/link_status/right/right.card.component.ts +++ b/src/app/link_status/right/right.card.component.ts @@ -40,7 +40,7 @@ const Widget: WidgetType = { { type: Label, height: 20, - text: '活动连接数', + text: BI.i18nText('BI-Active_Connections_Number'), }, ], }, @@ -79,7 +79,7 @@ const Widget: WidgetType = { { type: Label, height: 20, - text: '空闲连接数', + text: BI.i18nText('BI-Leisure_Connections_Number'), }, ], }, diff --git a/src/app/link_status/right/right.component.ts b/src/app/link_status/right/right.component.ts index 35c4122..31b638a 100644 --- a/src/app/link_status/right/right.component.ts +++ b/src/app/link_status/right/right.component.ts @@ -26,7 +26,7 @@ const Widget: WidgetType = { ...res, }])); }); - Title.setText(`数据连接(${title})`); + Title.setText(`${BI.i18nText('BI-Data_Connections')}(${title})`); }, }, render() { @@ -41,7 +41,7 @@ const Widget: WidgetType = { items:[ { type: Label, - text:'数据连接', + text:BI.i18nText('BI-Data_Connections'), }, ], ref(ref: any) { diff --git a/src/app/title/title.component.ts b/src/app/title/title.component.ts index 3aaa127..e8dd994 100644 --- a/src/app/title/title.component.ts +++ b/src/app/title/title.component.ts @@ -1,7 +1,7 @@ import {Left, WidgetType, IconButton} from '@ui/index'; import TitleItem from './title_item/title_item.component'; import {isDesigner, closeWindow} from '@shared/crud/crud.request'; -const tabs = ['数据连接管理', '连接池状态']; +const tabs = ['BI-Data_Connection_Management', 'BI-Pool_Connection_Management']; const className = 'fr.title'; const Widget: WidgetType = { render() { @@ -12,7 +12,7 @@ const Widget: WidgetType = { ...BI.map(tabs, (index: number, text: string) => { return { type: TitleItem, - text, + text: BI.i18nText(text), }; }), { diff --git a/src/app/title/title_item/title_item.component.ts b/src/app/title/title_item/title_item.component.ts index 7a3adef..ffba11d 100644 --- a/src/app/title/title_item/title_item.component.ts +++ b/src/app/title/title_item/title_item.component.ts @@ -26,7 +26,7 @@ const Widget = BI.inherit(BI.Widget, { }, mounted() { const {text} = this.options; - this.element.css(getSelectStyle('数据连接管理', text)); + this.element.css(getSelectStyle(BI.i18nText('BI-Data_Connection_Management'), text)); this.element.on('click', () => { this.store.setTab(text); }); diff --git a/src/demo/plugin.redis.edit.ts b/src/demo/plugin.redis.edit.ts index 49a8f6b..c1630dd 100644 --- a/src/demo/plugin.redis.edit.ts +++ b/src/demo/plugin.redis.edit.ts @@ -20,7 +20,7 @@ const Widget = BI.inherit(BI.Widget, { items: [ { type: 'bi.label', - text: '数据库地址:', + text: BI.i18nText('BI-Connection-Form-Database-Addr'), height: 24, width: 115, textAlign: 'left', @@ -28,7 +28,7 @@ const Widget = BI.inherit(BI.Widget, { { type: 'bi.editor', cls: 'bi-border', - watermark: '数据库地址', + watermark: BI.i18nText('BI-Connection-Form-Database-Addr'), value:form.url, allowBlank: true, width: 300, @@ -41,7 +41,7 @@ const Widget = BI.inherit(BI.Widget, { items: [ { type: 'bi.label', - text: '端口:', + text: BI.i18nText('BI-Connection-Form-Database-Port'), height: 24, width: 115, textAlign: 'left', @@ -49,12 +49,12 @@ const Widget = BI.inherit(BI.Widget, { { type: 'bi.editor', cls: 'bi-border', - watermark: '端口', + watermark: BI.i18nText('BI-Connection-Form-Database-Port'), allowBlank: true, width: 300, height: 24, value: form.port, - errorText: '请输入有效的正整数', + errorText: BI.i18nText('BI-Connection-Form-Place-Input-Number'), validationChecker (v: string) { if (/^\+?[1-9][0-9]*$/.test(v)) { return true; @@ -70,7 +70,7 @@ const Widget = BI.inherit(BI.Widget, { items: [ { type: 'bi.label', - text: '密码:', + text: BI.i18nText('BI-Connection-Form-Password'), height: 24, width: 115, textAlign: 'left', diff --git a/src/demo/plugin.redis.preview.ts b/src/demo/plugin.redis.preview.ts index 7082bf3..ff12daa 100644 --- a/src/demo/plugin.redis.preview.ts +++ b/src/demo/plugin.redis.preview.ts @@ -15,7 +15,7 @@ const Widget = BI.inherit(BI.Widget, { items: [ { type: 'bi.label', - text: '数据库地址:', + text: BI.i18nText('BI-Connection-Form-Database-Addr'), height: 24, width: 115, textAlign: 'left', @@ -32,7 +32,7 @@ const Widget = BI.inherit(BI.Widget, { items: [ { type: 'bi.label', - text: '端口:', + text: BI.i18nText('BI-Connection-Form-Database-Port'), height: 24, width: 115, textAlign: 'left', @@ -49,7 +49,7 @@ const Widget = BI.inherit(BI.Widget, { items: [ { type: 'bi.label', - text: '密码:', + text: BI.i18nText('BI-Connection-Form-Password'), height: 24, width: 115, textAlign: 'left', diff --git a/src/demo/plugin.tedis.pool.ts b/src/demo/plugin.tedis.pool.ts index 4dc1c0d..50d9ffd 100644 --- a/src/demo/plugin.tedis.pool.ts +++ b/src/demo/plugin.tedis.pool.ts @@ -39,7 +39,8 @@ const WidgetPool = BI.inherit(BI.Widget, { }, { type: 'bi.label', - text: 'Redis连接数', + height: 20, + text: BI.i18nText('BI-Active_Connections_Number'), }, ], }, diff --git a/src/index.html b/src/index.html index c4b8ed2..c402e16 100644 --- a/src/index.html +++ b/src/index.html @@ -7,6 +7,7 @@ + diff --git a/src/index.ts b/src/index.ts index 7a5ad89..7203543 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ BI.DOM.ready(() => { const app = require('./app/app.component').default; + BI.i18n = Store.i18n; BI.createWidget({ type:app, element: 'body', diff --git a/src/lib/locale/i18n_zh_CN.js b/src/lib/locale/i18n_zh_CN.js new file mode 100644 index 0000000..601c24c --- /dev/null +++ b/src/lib/locale/i18n_zh_CN.js @@ -0,0 +1,61 @@ +var Store = { + i18n : { + 'BI-Basic_Cancel': '取消', + 'BI-Basic_Sure': '确定', + 'BI-Data_Connection_Management': '数据连接管理', + 'BI-Pool_Connection_Management': '连接池管理', + 'BI-Data_Connections': '数据连接', + 'BI-Active_Connections_Number': '活动连接数', + 'BI-Leisure_Connections_Number': '空闲连接数', + 'BI-Connections': '连接', + 'BI-Default': '默认', + 'BI-Delete': '删除', + 'BI-Test-Connection': '测试连接', + 'BI-Copy': '复制', + 'BI-Edit': '编辑', + 'BI-Save': '保存', + 'BI-Yes': '是', + 'BI-No': '否', + 'BI-Search': '搜索', + 'BI-Type': '类型', + 'BI-Other': '其他', + 'BI-Tips': '提示', + 'BI-Back': '返回', + 'BI-Creator': '创建者', + 'BI-First_Step': '第一步', + 'BI-Second_Step': '第一步', + 'BI-Third_Step': '第一步', + 'BI-Connection-Detailed-Information': '详细信息', + 'BI-Connection-Handup-Information': '收起信息', + 'BI-Connection-Testing': '正在测试连接,请稍候...', + 'BI-Connection-Test-Fail': '测试连接失败', + 'BI-Connection-Test-Success': '连接成功', + 'BI-Connection-Option-Cannot-Find': '找不到该连接的配置信息', + 'BI-Connection-Config-No-Save': '当前设置尚未保存,是否保存?', + 'BI-Connection-New': '新建数据连接', + 'BI-Connection-More': '更多数据连接...', + 'BI-Connection-More-Title': '更多数据连接', + 'BI-Connection-Other': '其他', + 'BI-Connection-Plase-Add-One': '请选择左侧数据连接或点击新建数据连接', + 'BI-Connection-Is-Existence': '数据连接名已存在', + 'BI-Connection-Form-ConnectionName': '数据连接名', + 'BI-Connection-Form-ConnectionName-Change-Confirm': '*修改数据连接名会影响相关数据表和仪表板', + 'BI-Connection-Form-Driver': '驱动器', + 'BI-Connection-Form-URL': 'URL', + 'BI-Connection-Form-Place-Input': '请输入', + 'BI-Connection-Form-OriginalCharsetName': '编码', + 'BI-Connection-Form-Auto': '自动', + 'BI-Connection-Form-UserName': '用户名', + 'BI-Connection-Form-Password': '密码', + 'BI-Connection-Form-Pool-Properties': '连接池属性', + 'BI-Connection-Form-SQL-Validation-Query': 'SQL验证查询', + 'BI-Connection-Form-Connection-Check': '获取连接前校验', + 'BI-Connection-Form-Connection-Max-Number': '最大活动连接数', + 'BI-Connection-Form-Place-Input-Number': '请输入有效的正整数', + 'BI-Connection-Form-Pattern': '模式', + 'BI-Connection-Form-Database-Addr': '数据库地址', + 'BI-Connection-Form-Database-Port': '端口号', + 'BI-Connection-Make-Sure-Delete': '确定删除该数据连接?', + 'BI-Connection-ReConnect': '重新连接', + }} +window.Store = Store; \ No newline at end of file diff --git a/src/shared/service/dialog.service.ts b/src/shared/service/dialog.service.ts index 349e25c..13e53ea 100644 --- a/src/shared/service/dialog.service.ts +++ b/src/shared/service/dialog.service.ts @@ -10,7 +10,7 @@ class Dialog { BI.Popovers.create(id, { type: 'bi.bar_popover', size: 'normal', - header: '提示', + header: BI.i18nText('BI-Tips'), width: 450, height: 220, body: { @@ -156,20 +156,20 @@ class Dialog { items:[ { type: Button, - text:'详细信息', + text: BI.i18nText('BI-Connection-Detailed-Information'), level: 'ignore', handler() { - const isHide = this.getText() === '详细信息'; + const isHide = this.getText() === BI.i18nText('BI-Connection-Detailed-Information'); Popover.element.css({ height: isHide ? '290' : '220', }); More.setVisible(isHide); - this.setText(isHide ? '收起信息' : '详细信息'); + this.setText(isHide ? BI.i18nText('BI-Connection-Handup-Information') : BI.i18nText('BI-Connection-Detailed-Information')); }, }, { type: Button, - text:'返回', + text: BI.i18nText('BI-Back'), level: 'ignore', handler() { that.close(id); @@ -177,7 +177,7 @@ class Dialog { }, { type: Button, - text:'重新连接', + text: BI.i18nText('BI-Connection-ReConnect'), handler() { that.close(id); cb ? cb() : null; diff --git a/types/globals.d.ts b/types/globals.d.ts index 3a1bc4b..44cf726 100644 --- a/types/globals.d.ts +++ b/types/globals.d.ts @@ -6,3 +6,4 @@ declare let BI: Obj; declare const Fix: Obj; declare const Dec: Obj; declare const PluginHelper: Obj; +declare const Store: Obj;