You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by zh...@apache.org on 2022/07/03 02:30:49 UTC
[incubator-seatunnel] branch dev updated: [Feat][UI] Add multi-language related configuration. (#2116)
This is an automated email from the ASF dual-hosted git repository.
zhongjiajie pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new 66f8161ab [Feat][UI] Add multi-language related configuration. (#2116)
66f8161ab is described below
commit 66f8161ababc5730cf8822292ca384f9612ff5a8
Author: songjianet <17...@qq.com>
AuthorDate: Sun Jul 3 10:30:43 2022 +0800
[Feat][UI] Add multi-language related configuration. (#2116)
---
seatunnel-ui/src/App.tsx | 13 +++++++---
.../src/{main.ts => locales/en_US/index.ts} | 11 ++++----
seatunnel-ui/src/{App.tsx => locales/index.ts} | 20 ++++++++-------
.../src/{main.ts => locales/zh_CN/index.ts} | 11 ++++----
seatunnel-ui/src/main.ts | 8 ++++++
.../src/{App.tsx => store/locales/index.ts} | 29 ++++++++++++++--------
.../src/{main.ts => store/locales/types.ts} | 9 ++++---
7 files changed, 64 insertions(+), 37 deletions(-)
diff --git a/seatunnel-ui/src/App.tsx b/seatunnel-ui/src/App.tsx
index 2a5ea1996..7ceca19d9 100644
--- a/seatunnel-ui/src/App.tsx
+++ b/seatunnel-ui/src/App.tsx
@@ -17,12 +17,19 @@
import { defineComponent } from 'vue'
import { NButton } from 'naive-ui'
+import { useI18n } from 'vue-i18n'
- const App = defineComponent({
- setup() {},
+const App = defineComponent({
+ setup() {
+ const { t } = useI18n()
+
+ return { t }
+ },
render() {
+ const { t } = this
+
return (
- <NButton>test</NButton>
+ <NButton>{t('test.test')}</NButton>
)
}
})
diff --git a/seatunnel-ui/src/main.ts b/seatunnel-ui/src/locales/en_US/index.ts
similarity index 88%
copy from seatunnel-ui/src/main.ts
copy to seatunnel-ui/src/locales/en_US/index.ts
index 8d92c8604..1e7d2e414 100644
--- a/seatunnel-ui/src/main.ts
+++ b/seatunnel-ui/src/locales/en_US/index.ts
@@ -15,9 +15,10 @@
* limitations under the License.
*/
-import { createApp } from 'vue'
-import App from './App'
+const test = {
+ 'test': 'test'
+}
-const app = createApp(App)
-
-app.mount('#app')
\ No newline at end of file
+export default {
+ test
+}
\ No newline at end of file
diff --git a/seatunnel-ui/src/App.tsx b/seatunnel-ui/src/locales/index.ts
similarity index 77%
copy from seatunnel-ui/src/App.tsx
copy to seatunnel-ui/src/locales/index.ts
index 2a5ea1996..1d2769c17 100644
--- a/seatunnel-ui/src/App.tsx
+++ b/seatunnel-ui/src/locales/index.ts
@@ -15,16 +15,18 @@
* limitations under the License.
*/
-import { defineComponent } from 'vue'
-import { NButton } from 'naive-ui'
+import { createI18n } from 'vue-i18n'
+import zh_CN from './zh_CN'
+import en_US from './en_US'
- const App = defineComponent({
- setup() {},
- render() {
- return (
- <NButton>test</NButton>
- )
+const i18n = createI18n({
+ legacy: false,
+ globalInjection: true,
+ locale: 'en_US',
+ messages: {
+ zh_CN,
+ en_US
}
})
-export default App
\ No newline at end of file
+export default i18n
\ No newline at end of file
diff --git a/seatunnel-ui/src/main.ts b/seatunnel-ui/src/locales/zh_CN/index.ts
similarity index 88%
copy from seatunnel-ui/src/main.ts
copy to seatunnel-ui/src/locales/zh_CN/index.ts
index 8d92c8604..e979946bb 100644
--- a/seatunnel-ui/src/main.ts
+++ b/seatunnel-ui/src/locales/zh_CN/index.ts
@@ -15,9 +15,10 @@
* limitations under the License.
*/
-import { createApp } from 'vue'
-import App from './App'
+const test = {
+ 'test': '测试'
+}
-const app = createApp(App)
-
-app.mount('#app')
\ No newline at end of file
+export default {
+ test
+}
\ No newline at end of file
diff --git a/seatunnel-ui/src/main.ts b/seatunnel-ui/src/main.ts
index 8d92c8604..f5163bb6a 100644
--- a/seatunnel-ui/src/main.ts
+++ b/seatunnel-ui/src/main.ts
@@ -17,7 +17,15 @@
import { createApp } from 'vue'
import App from './App'
+import { createPinia } from 'pinia'
+import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
+import i18n from '@/locales'
const app = createApp(App)
+const pinia = createPinia()
+pinia.use(piniaPluginPersistedstate)
+
+app.use(pinia)
+app.use(i18n)
app.mount('#app')
\ No newline at end of file
diff --git a/seatunnel-ui/src/App.tsx b/seatunnel-ui/src/store/locales/index.ts
similarity index 67%
copy from seatunnel-ui/src/App.tsx
copy to seatunnel-ui/src/store/locales/index.ts
index 2a5ea1996..b5139aa1c 100644
--- a/seatunnel-ui/src/App.tsx
+++ b/seatunnel-ui/src/store/locales/index.ts
@@ -15,16 +15,23 @@
* limitations under the License.
*/
-import { defineComponent } from 'vue'
-import { NButton } from 'naive-ui'
+import { defineStore } from 'pinia'
+import { LocalesStore, Locales } from './types'
- const App = defineComponent({
- setup() {},
- render() {
- return (
- <NButton>test</NButton>
- )
+export const useLocalesStore = defineStore({
+ id: 'locales',
+ state: (): LocalesStore => ({
+ locales: 'en_US'
+ }),
+ persist: true,
+ getters: {
+ getLocales(): Locales {
+ return this.locales
+ }
+ },
+ actions: {
+ setLocales(lang: Locales): void {
+ this.locales = lang
+ }
}
-})
-
-export default App
\ No newline at end of file
+})
\ No newline at end of file
diff --git a/seatunnel-ui/src/main.ts b/seatunnel-ui/src/store/locales/types.ts
similarity index 87%
copy from seatunnel-ui/src/main.ts
copy to seatunnel-ui/src/store/locales/types.ts
index 8d92c8604..095d54269 100644
--- a/seatunnel-ui/src/main.ts
+++ b/seatunnel-ui/src/store/locales/types.ts
@@ -15,9 +15,10 @@
* limitations under the License.
*/
-import { createApp } from 'vue'
-import App from './App'
+type Locales = 'zh_CN' | 'en_US'
-const app = createApp(App)
+interface LocalesStore {
+ locales: Locales
+}
-app.mount('#app')
\ No newline at end of file
+export { LocalesStore, Locales }
\ No newline at end of file