rayyy-vue-table-components 1.4.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +13993 -10306
- package/dist/index.umd.js +40 -20
- package/dist/rayyy-vue-table-components.css +1 -1
- package/dist/src/components/items/BaseWaringDialog.vue.d.ts +1 -4
- package/dist/src/index.d.ts +3 -0
- package/dist/src/locales/en-US.json.d.ts +39 -0
- package/dist/src/locales/index.d.ts +80 -0
- package/dist/src/locales/zh-TW.json.d.ts +39 -0
- package/dist/src/router/constants.d.ts +2 -0
- package/dist/src/types/components.d.ts +2 -0
- package/dist/src/utils/i18n.d.ts +21 -0
- package/dist/src/views/demo/I18nTestDemo.vue.d.ts +2 -0
- package/package.json +10 -2
- package/src/components/form/BaseSelector.vue +5 -2
- package/src/components/items/BaseDialog.vue +12 -3
- package/src/components/items/BaseWaringDialog.vue +7 -10
- package/src/components/items/SearchBar.vue +4 -1
- package/src/components/layout/DetailLayout.vue +5 -2
- package/src/components/layout/FilterLayout.vue +5 -2
- package/src/components/layout/SearchableListPanel.vue +1 -1
- package/src/components/tables/BaseTable.vue +6 -3
- package/src/components/tables/SortTable.vue +2 -2
- package/src/components/tables/TitleTable.vue +15 -3
- package/src/components/transfer/TransferDialog.vue +4 -1
- package/src/locales/en-US.json +37 -0
- package/src/locales/index.d.ts +10 -0
- package/src/locales/index.ts +12 -0
- package/src/locales/zh-TW.json +37 -0
- package/src/types/components.d.ts +2 -0
- package/src/utils/i18n.ts +89 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"common.select": "請選擇",
|
|
3
|
+
"common.confirm": "確定",
|
|
4
|
+
"common.cancel": "取消",
|
|
5
|
+
"dialog.confirmRemoveUser": "請問是否確認移除該使用者",
|
|
6
|
+
"common.warning": "警告",
|
|
7
|
+
"search.placeholder": "請輸入關鍵字搜尋列表",
|
|
8
|
+
"common.execute": "執行",
|
|
9
|
+
"common.reset": "重設",
|
|
10
|
+
"common.loading": "數據加載中",
|
|
11
|
+
"common.view": "查看",
|
|
12
|
+
"common.edit": "編輯",
|
|
13
|
+
"common.column": "欄",
|
|
14
|
+
"common.back": "回到前一頁",
|
|
15
|
+
"demo.componentDemo": "組件示範",
|
|
16
|
+
"button.title": "按鈕",
|
|
17
|
+
"button.primary ": "主要",
|
|
18
|
+
"button.default": "默認",
|
|
19
|
+
"button.danger": "危險",
|
|
20
|
+
"button.success": "成功",
|
|
21
|
+
"button.warning": "警告",
|
|
22
|
+
"button.info": "信息",
|
|
23
|
+
"button.style": "樣式",
|
|
24
|
+
"button.size": "尺寸",
|
|
25
|
+
"button.small": "小",
|
|
26
|
+
"button.medium": "中",
|
|
27
|
+
"button.large ": "大",
|
|
28
|
+
"status.title": "狀態",
|
|
29
|
+
"status.normal ": "正常",
|
|
30
|
+
"status.loading": "載入中",
|
|
31
|
+
"status.disabled": "禁用",
|
|
32
|
+
"button.withIcon ": "帶圖標的",
|
|
33
|
+
"button.add": "添加",
|
|
34
|
+
"button.delete": "刪除",
|
|
35
|
+
"common.save": "儲存",
|
|
36
|
+
"common.discard": "捨棄"
|
|
37
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createI18n, type I18n, type Composer } from 'vue-i18n'
|
|
2
|
+
import { getCurrentInstance, computed } from 'vue'
|
|
3
|
+
import { messages } from '../locales'
|
|
4
|
+
|
|
5
|
+
// 內部 i18n 實例
|
|
6
|
+
let internalI18n: I18n | null = null
|
|
7
|
+
|
|
8
|
+
// 預設語系
|
|
9
|
+
const DEFAULT_LOCALE = 'zh-TW'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 取得或建立內部 i18n 實例
|
|
13
|
+
*/
|
|
14
|
+
function getInternalI18n(): I18n {
|
|
15
|
+
if (!internalI18n) {
|
|
16
|
+
internalI18n = createI18n({
|
|
17
|
+
legacy: false,
|
|
18
|
+
locale: DEFAULT_LOCALE,
|
|
19
|
+
fallbackLocale: DEFAULT_LOCALE,
|
|
20
|
+
messages,
|
|
21
|
+
silentTranslationWarn: true,
|
|
22
|
+
missingWarn: false,
|
|
23
|
+
fallbackWarn: false,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
return internalI18n
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 設定內部 i18n 的語系
|
|
31
|
+
*/
|
|
32
|
+
export function setLocale(locale: string): void {
|
|
33
|
+
const i18n = getInternalI18n()
|
|
34
|
+
const global = i18n.global as Composer
|
|
35
|
+
global.locale.value = locale
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 組件內使用的 i18n composable
|
|
40
|
+
* 會優先使用外部專案的 i18n,如果不存在則使用內部 i18n
|
|
41
|
+
*/
|
|
42
|
+
export function useComponentI18n() {
|
|
43
|
+
const instance = getCurrentInstance()
|
|
44
|
+
|
|
45
|
+
// 嘗試取得外部專案的 i18n(支援 Composition API 模式)
|
|
46
|
+
let externalI18n: Composer | undefined
|
|
47
|
+
try {
|
|
48
|
+
const globalProperties = instance?.appContext.config.globalProperties
|
|
49
|
+
const externalI18nInstance = globalProperties?.$i18n as I18n | undefined
|
|
50
|
+
|
|
51
|
+
// 如果是 I18n 實例,取得其 global 屬性
|
|
52
|
+
if (externalI18nInstance && 'global' in externalI18nInstance) {
|
|
53
|
+
externalI18n = externalI18nInstance.global as Composer
|
|
54
|
+
}
|
|
55
|
+
} catch (e) {
|
|
56
|
+
// 如果取得失敗,繼續使用內部 i18n
|
|
57
|
+
externalI18n = undefined
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 取得內部 i18n
|
|
61
|
+
const internalI18nInstance = getInternalI18n()
|
|
62
|
+
const internalGlobal = internalI18nInstance.global as Composer
|
|
63
|
+
|
|
64
|
+
// 如果存在外部 i18n,優先使用外部的(因為外部可能有覆蓋的翻譯)
|
|
65
|
+
// 但要支援回退到內部 i18n
|
|
66
|
+
const currentI18n = externalI18n || internalGlobal
|
|
67
|
+
|
|
68
|
+
// 直接使用 i18n 的 t 函數(它本身就是響應式的)
|
|
69
|
+
// 如果需要回退邏輯,我們需要檢查 key 是否存在
|
|
70
|
+
const t = currentI18n.t
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
t,
|
|
74
|
+
locale: currentI18n.locale,
|
|
75
|
+
i18n: currentI18n,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 全域 i18n 實例(用於非組件環境)
|
|
81
|
+
*/
|
|
82
|
+
export function useI18n() {
|
|
83
|
+
const i18n = getInternalI18n()
|
|
84
|
+
return i18n.global as Composer
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 導出類型
|
|
88
|
+
export type { I18n, Composer }
|
|
89
|
+
|