From f7a292808f2b975c4f6890edf37cd8ecb6de462d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chyeonggkim=E2=80=9D?= <“hyeonggkim@smilegate.com”> Date: Fri, 24 Oct 2025 14:14:54 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=8B=A4=EA=B5=AD=EC=96=B4=20json=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/locales/de.ts | 51 ++++--------- i18n/locales/en.ts | 61 ++++----------- i18n/locales/es.ts | 51 ++++--------- i18n/locales/fr.ts | 51 ++++--------- i18n/locales/ja.ts | 61 ++++----------- i18n/locales/ko.ts | 61 ++++----------- i18n/locales/pt.ts | 51 ++++--------- i18n/locales/th.ts | 45 +++--------- i18n/locales/zh-cn.ts | 64 +++++----------- i18n/locales/zh-tw.ts | 64 +++++----------- layers/components/layouts/Footer.vue | 106 +++++---------------------- layers/components/layouts/Main.vue | 7 ++ layers/composables/useAnalytics.ts | 84 ++++++++------------- 13 files changed, 196 insertions(+), 561 deletions(-) diff --git a/i18n/locales/de.ts b/i18n/locales/de.ts index 5e93706..e7f3c28 100644 --- a/i18n/locales/de.ts +++ b/i18n/locales/de.ts @@ -1,49 +1,24 @@ -// import { TRANSLATION_ITEMS } from '../i18n.config' -// common.json 파일을 직접 import -// @ts-ignore -import commonData from '../../layers/assets/data/common.json' - export default defineI18nLocale(async (locale: string) => { - const runtimeConfig = useRuntimeConfig() - const baseType = runtimeConfig.public.baseType - const translationItems = runtimeConfig.public.translationItems - const translationItemsArr = translationItems.split(',') - const staticUrl = runtimeConfig.public.staticUrl - const translationApi = translationItemsArr.map((item: string): string => { - return `${staticUrl}/${baseType}/tmp/${item}.json` - }) + //https://static-pubcomm.gate8.com/dev/test/multilingual/test_common_template.json?20251021185116 + const config = useRuntimeConfig() + const rootPath = config.public.staticUrl + const runType = config.public.runType - // API 데이터 가져오기 - const fetchDataPromises = translationApi.map(apiUrl => { - return useFetch(apiUrl, { - method: 'GET', - headers: { - 'Content-Type': 'application/json;charset=UTF-8', - }, - }) - }) + const translationApi = `${rootPath}/${runType}/test/multilingual/test_common_template.json` try { - const fetchResults = await Promise.all(fetchDataPromises) - - // 각 결과에서 locale에 맞는 데이터를 추출 - const apiData = fetchResults.map(result => { - return result.data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 + const { data } = await useFetch(translationApi, { + method: 'GET', + headers: { + 'Content-Type': 'application/json;charset=UTF-8' + } }) - // apiData를 이용해 자동으로 병합 - const mergedResult = apiData.reduce((acc, data) => { - return { ...acc, ...data } - }, {}) - - // common.json에서 해당 locale의 데이터를 가져와서 병합 - const commonLocaleData = commonData[locale] || {} + // API 데이터에서 locale에 맞는 데이터를 추출 + const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 // API 데이터와 common.json 데이터를 병합 (common.json이 우선순위) - const finalResult = { ...mergedResult, ...commonLocaleData } - - // 병합된 결과 출력 - // console.log('finalResult:', finalResult) + const finalResult = { ...apiData } return finalResult } catch (error) { diff --git a/i18n/locales/en.ts b/i18n/locales/en.ts index c9ce1cd..e7f3c28 100644 --- a/i18n/locales/en.ts +++ b/i18n/locales/en.ts @@ -1,57 +1,24 @@ -// import { TRANSLATION_ITEMS } from '../i18n.config' -// common.json 파일을 직접 import -// @ts-ignore -import commonData from '../../layers/assets/data/common.json' - export default defineI18nLocale(async (locale: string) => { - // const config = useRuntimeConfig() - // const baseType = config.public.baseType - // const translationItems = config.public.translationItems - // const translationItemsArr = translationItems.split(',') - // const staticUrl = config.public.staticUrl - // const translationPaths = translationItemsArr.map((item) => { - // 경로를 생성하며 ~/assets/data 경로로 설정 - // return `~/assets/data/${item}.json` - // }) - // const resources = await Promise.all(translationPaths.map((path) => import(`${path}`))) + //https://static-pubcomm.gate8.com/dev/test/multilingual/test_common_template.json?20251021185116 + const config = useRuntimeConfig() + const rootPath = config.public.staticUrl + const runType = config.public.runType - // console.log('translationLocal ~ translationLocal:', translationLocal) - // const translationApi = translationItemsArr.map((item: string): string => { - // return `${staticUrl}/${baseType}/tmp/${item}.json` - // }) - - // // API 데이터 가져오기 - // const fetchDataPromises = translationApi.map((apiUrl) => { - // return useFetch(apiUrl, { - // method: 'GET', - // headers: { - // 'Content-Type': 'application/json;charset=UTF-8' - // } - // }) - // }) + const translationApi = `${rootPath}/${runType}/test/multilingual/test_common_template.json` try { - // const fetchResults = await Promise.all(fetchDataPromises) + const { data } = await useFetch(translationApi, { + method: 'GET', + headers: { + 'Content-Type': 'application/json;charset=UTF-8' + } + }) - // // 각 결과에서 locale에 맞는 데이터를 추출 - // const apiData = fetchResults.map((result) => { - // return result.data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - // }) + // API 데이터에서 locale에 맞는 데이터를 추출 + const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - // // apiData를 이용해 자동으로 병합 - // const mergedResult = apiData.reduce((acc, data) => { - // return { ...acc, ...data } - // }, {}) - - // common.json에서 해당 locale의 데이터를 가져와서 병합 - const commonLocaleData = commonData[locale] || {} - // API 데이터와 common.json 데이터를 병합 (common.json이 우선순위) - // const finalResult = { ...mergedResult, ...commonLocaleData } - const finalResult = { ...commonLocaleData } - - // 병합된 결과 출력 - // console.log('finalResult:', finalResult) + const finalResult = { ...apiData } return finalResult } catch (error) { diff --git a/i18n/locales/es.ts b/i18n/locales/es.ts index 5e93706..e7f3c28 100644 --- a/i18n/locales/es.ts +++ b/i18n/locales/es.ts @@ -1,49 +1,24 @@ -// import { TRANSLATION_ITEMS } from '../i18n.config' -// common.json 파일을 직접 import -// @ts-ignore -import commonData from '../../layers/assets/data/common.json' - export default defineI18nLocale(async (locale: string) => { - const runtimeConfig = useRuntimeConfig() - const baseType = runtimeConfig.public.baseType - const translationItems = runtimeConfig.public.translationItems - const translationItemsArr = translationItems.split(',') - const staticUrl = runtimeConfig.public.staticUrl - const translationApi = translationItemsArr.map((item: string): string => { - return `${staticUrl}/${baseType}/tmp/${item}.json` - }) + //https://static-pubcomm.gate8.com/dev/test/multilingual/test_common_template.json?20251021185116 + const config = useRuntimeConfig() + const rootPath = config.public.staticUrl + const runType = config.public.runType - // API 데이터 가져오기 - const fetchDataPromises = translationApi.map(apiUrl => { - return useFetch(apiUrl, { - method: 'GET', - headers: { - 'Content-Type': 'application/json;charset=UTF-8', - }, - }) - }) + const translationApi = `${rootPath}/${runType}/test/multilingual/test_common_template.json` try { - const fetchResults = await Promise.all(fetchDataPromises) - - // 각 결과에서 locale에 맞는 데이터를 추출 - const apiData = fetchResults.map(result => { - return result.data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 + const { data } = await useFetch(translationApi, { + method: 'GET', + headers: { + 'Content-Type': 'application/json;charset=UTF-8' + } }) - // apiData를 이용해 자동으로 병합 - const mergedResult = apiData.reduce((acc, data) => { - return { ...acc, ...data } - }, {}) - - // common.json에서 해당 locale의 데이터를 가져와서 병합 - const commonLocaleData = commonData[locale] || {} + // API 데이터에서 locale에 맞는 데이터를 추출 + const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 // API 데이터와 common.json 데이터를 병합 (common.json이 우선순위) - const finalResult = { ...mergedResult, ...commonLocaleData } - - // 병합된 결과 출력 - // console.log('finalResult:', finalResult) + const finalResult = { ...apiData } return finalResult } catch (error) { diff --git a/i18n/locales/fr.ts b/i18n/locales/fr.ts index 5e93706..e7f3c28 100644 --- a/i18n/locales/fr.ts +++ b/i18n/locales/fr.ts @@ -1,49 +1,24 @@ -// import { TRANSLATION_ITEMS } from '../i18n.config' -// common.json 파일을 직접 import -// @ts-ignore -import commonData from '../../layers/assets/data/common.json' - export default defineI18nLocale(async (locale: string) => { - const runtimeConfig = useRuntimeConfig() - const baseType = runtimeConfig.public.baseType - const translationItems = runtimeConfig.public.translationItems - const translationItemsArr = translationItems.split(',') - const staticUrl = runtimeConfig.public.staticUrl - const translationApi = translationItemsArr.map((item: string): string => { - return `${staticUrl}/${baseType}/tmp/${item}.json` - }) + //https://static-pubcomm.gate8.com/dev/test/multilingual/test_common_template.json?20251021185116 + const config = useRuntimeConfig() + const rootPath = config.public.staticUrl + const runType = config.public.runType - // API 데이터 가져오기 - const fetchDataPromises = translationApi.map(apiUrl => { - return useFetch(apiUrl, { - method: 'GET', - headers: { - 'Content-Type': 'application/json;charset=UTF-8', - }, - }) - }) + const translationApi = `${rootPath}/${runType}/test/multilingual/test_common_template.json` try { - const fetchResults = await Promise.all(fetchDataPromises) - - // 각 결과에서 locale에 맞는 데이터를 추출 - const apiData = fetchResults.map(result => { - return result.data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 + const { data } = await useFetch(translationApi, { + method: 'GET', + headers: { + 'Content-Type': 'application/json;charset=UTF-8' + } }) - // apiData를 이용해 자동으로 병합 - const mergedResult = apiData.reduce((acc, data) => { - return { ...acc, ...data } - }, {}) - - // common.json에서 해당 locale의 데이터를 가져와서 병합 - const commonLocaleData = commonData[locale] || {} + // API 데이터에서 locale에 맞는 데이터를 추출 + const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 // API 데이터와 common.json 데이터를 병합 (common.json이 우선순위) - const finalResult = { ...mergedResult, ...commonLocaleData } - - // 병합된 결과 출력 - // console.log('finalResult:', finalResult) + const finalResult = { ...apiData } return finalResult } catch (error) { diff --git a/i18n/locales/ja.ts b/i18n/locales/ja.ts index c9ce1cd..e7f3c28 100644 --- a/i18n/locales/ja.ts +++ b/i18n/locales/ja.ts @@ -1,57 +1,24 @@ -// import { TRANSLATION_ITEMS } from '../i18n.config' -// common.json 파일을 직접 import -// @ts-ignore -import commonData from '../../layers/assets/data/common.json' - export default defineI18nLocale(async (locale: string) => { - // const config = useRuntimeConfig() - // const baseType = config.public.baseType - // const translationItems = config.public.translationItems - // const translationItemsArr = translationItems.split(',') - // const staticUrl = config.public.staticUrl - // const translationPaths = translationItemsArr.map((item) => { - // 경로를 생성하며 ~/assets/data 경로로 설정 - // return `~/assets/data/${item}.json` - // }) - // const resources = await Promise.all(translationPaths.map((path) => import(`${path}`))) + //https://static-pubcomm.gate8.com/dev/test/multilingual/test_common_template.json?20251021185116 + const config = useRuntimeConfig() + const rootPath = config.public.staticUrl + const runType = config.public.runType - // console.log('translationLocal ~ translationLocal:', translationLocal) - // const translationApi = translationItemsArr.map((item: string): string => { - // return `${staticUrl}/${baseType}/tmp/${item}.json` - // }) - - // // API 데이터 가져오기 - // const fetchDataPromises = translationApi.map((apiUrl) => { - // return useFetch(apiUrl, { - // method: 'GET', - // headers: { - // 'Content-Type': 'application/json;charset=UTF-8' - // } - // }) - // }) + const translationApi = `${rootPath}/${runType}/test/multilingual/test_common_template.json` try { - // const fetchResults = await Promise.all(fetchDataPromises) + const { data } = await useFetch(translationApi, { + method: 'GET', + headers: { + 'Content-Type': 'application/json;charset=UTF-8' + } + }) - // // 각 결과에서 locale에 맞는 데이터를 추출 - // const apiData = fetchResults.map((result) => { - // return result.data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - // }) + // API 데이터에서 locale에 맞는 데이터를 추출 + const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - // // apiData를 이용해 자동으로 병합 - // const mergedResult = apiData.reduce((acc, data) => { - // return { ...acc, ...data } - // }, {}) - - // common.json에서 해당 locale의 데이터를 가져와서 병합 - const commonLocaleData = commonData[locale] || {} - // API 데이터와 common.json 데이터를 병합 (common.json이 우선순위) - // const finalResult = { ...mergedResult, ...commonLocaleData } - const finalResult = { ...commonLocaleData } - - // 병합된 결과 출력 - // console.log('finalResult:', finalResult) + const finalResult = { ...apiData } return finalResult } catch (error) { diff --git a/i18n/locales/ko.ts b/i18n/locales/ko.ts index c9ce1cd..e7f3c28 100644 --- a/i18n/locales/ko.ts +++ b/i18n/locales/ko.ts @@ -1,57 +1,24 @@ -// import { TRANSLATION_ITEMS } from '../i18n.config' -// common.json 파일을 직접 import -// @ts-ignore -import commonData from '../../layers/assets/data/common.json' - export default defineI18nLocale(async (locale: string) => { - // const config = useRuntimeConfig() - // const baseType = config.public.baseType - // const translationItems = config.public.translationItems - // const translationItemsArr = translationItems.split(',') - // const staticUrl = config.public.staticUrl - // const translationPaths = translationItemsArr.map((item) => { - // 경로를 생성하며 ~/assets/data 경로로 설정 - // return `~/assets/data/${item}.json` - // }) - // const resources = await Promise.all(translationPaths.map((path) => import(`${path}`))) + //https://static-pubcomm.gate8.com/dev/test/multilingual/test_common_template.json?20251021185116 + const config = useRuntimeConfig() + const rootPath = config.public.staticUrl + const runType = config.public.runType - // console.log('translationLocal ~ translationLocal:', translationLocal) - // const translationApi = translationItemsArr.map((item: string): string => { - // return `${staticUrl}/${baseType}/tmp/${item}.json` - // }) - - // // API 데이터 가져오기 - // const fetchDataPromises = translationApi.map((apiUrl) => { - // return useFetch(apiUrl, { - // method: 'GET', - // headers: { - // 'Content-Type': 'application/json;charset=UTF-8' - // } - // }) - // }) + const translationApi = `${rootPath}/${runType}/test/multilingual/test_common_template.json` try { - // const fetchResults = await Promise.all(fetchDataPromises) + const { data } = await useFetch(translationApi, { + method: 'GET', + headers: { + 'Content-Type': 'application/json;charset=UTF-8' + } + }) - // // 각 결과에서 locale에 맞는 데이터를 추출 - // const apiData = fetchResults.map((result) => { - // return result.data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - // }) + // API 데이터에서 locale에 맞는 데이터를 추출 + const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - // // apiData를 이용해 자동으로 병합 - // const mergedResult = apiData.reduce((acc, data) => { - // return { ...acc, ...data } - // }, {}) - - // common.json에서 해당 locale의 데이터를 가져와서 병합 - const commonLocaleData = commonData[locale] || {} - // API 데이터와 common.json 데이터를 병합 (common.json이 우선순위) - // const finalResult = { ...mergedResult, ...commonLocaleData } - const finalResult = { ...commonLocaleData } - - // 병합된 결과 출력 - // console.log('finalResult:', finalResult) + const finalResult = { ...apiData } return finalResult } catch (error) { diff --git a/i18n/locales/pt.ts b/i18n/locales/pt.ts index 5e93706..e7f3c28 100644 --- a/i18n/locales/pt.ts +++ b/i18n/locales/pt.ts @@ -1,49 +1,24 @@ -// import { TRANSLATION_ITEMS } from '../i18n.config' -// common.json 파일을 직접 import -// @ts-ignore -import commonData from '../../layers/assets/data/common.json' - export default defineI18nLocale(async (locale: string) => { - const runtimeConfig = useRuntimeConfig() - const baseType = runtimeConfig.public.baseType - const translationItems = runtimeConfig.public.translationItems - const translationItemsArr = translationItems.split(',') - const staticUrl = runtimeConfig.public.staticUrl - const translationApi = translationItemsArr.map((item: string): string => { - return `${staticUrl}/${baseType}/tmp/${item}.json` - }) + //https://static-pubcomm.gate8.com/dev/test/multilingual/test_common_template.json?20251021185116 + const config = useRuntimeConfig() + const rootPath = config.public.staticUrl + const runType = config.public.runType - // API 데이터 가져오기 - const fetchDataPromises = translationApi.map(apiUrl => { - return useFetch(apiUrl, { - method: 'GET', - headers: { - 'Content-Type': 'application/json;charset=UTF-8', - }, - }) - }) + const translationApi = `${rootPath}/${runType}/test/multilingual/test_common_template.json` try { - const fetchResults = await Promise.all(fetchDataPromises) - - // 각 결과에서 locale에 맞는 데이터를 추출 - const apiData = fetchResults.map(result => { - return result.data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 + const { data } = await useFetch(translationApi, { + method: 'GET', + headers: { + 'Content-Type': 'application/json;charset=UTF-8' + } }) - // apiData를 이용해 자동으로 병합 - const mergedResult = apiData.reduce((acc, data) => { - return { ...acc, ...data } - }, {}) - - // common.json에서 해당 locale의 데이터를 가져와서 병합 - const commonLocaleData = commonData[locale] || {} + // API 데이터에서 locale에 맞는 데이터를 추출 + const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 // API 데이터와 common.json 데이터를 병합 (common.json이 우선순위) - const finalResult = { ...mergedResult, ...commonLocaleData } - - // 병합된 결과 출력 - // console.log('finalResult:', finalResult) + const finalResult = { ...apiData } return finalResult } catch (error) { diff --git a/i18n/locales/th.ts b/i18n/locales/th.ts index a40148b..e7f3c28 100644 --- a/i18n/locales/th.ts +++ b/i18n/locales/th.ts @@ -1,49 +1,24 @@ -// import { TRANSLATION_ITEMS } from '../i18n.config' -// common.json 파일을 직접 import -// @ts-ignore -import commonData from '../../layers/assets/data/common.json' - export default defineI18nLocale(async (locale: string) => { + //https://static-pubcomm.gate8.com/dev/test/multilingual/test_common_template.json?20251021185116 const config = useRuntimeConfig() - const baseType = config.public.baseType - const translationItems = config.public.translationItems - const translationItemsArr = translationItems.split(',') - const staticUrl = config.public.staticUrl - const translationApi = translationItemsArr.map((item: string): string => { - return `${staticUrl}/${baseType}/tmp/${item}.json` - }) + const rootPath = config.public.staticUrl + const runType = config.public.runType - // API 데이터 가져오기 - const fetchDataPromises = translationApi.map((apiUrl) => { - return useFetch(apiUrl, { + const translationApi = `${rootPath}/${runType}/test/multilingual/test_common_template.json` + + try { + const { data } = await useFetch(translationApi, { method: 'GET', headers: { 'Content-Type': 'application/json;charset=UTF-8' } }) - }) - try { - const fetchResults = await Promise.all(fetchDataPromises) + // API 데이터에서 locale에 맞는 데이터를 추출 + const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - // 각 결과에서 locale에 맞는 데이터를 추출 - const apiData = fetchResults.map((result) => { - return result.data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - }) - - // apiData를 이용해 자동으로 병합 - const mergedResult = apiData.reduce((acc, data) => { - return { ...acc, ...data } - }, {}) - - // common.json에서 해당 locale의 데이터를 가져와서 병합 - const commonLocaleData = commonData[locale] || {} - // API 데이터와 common.json 데이터를 병합 (common.json이 우선순위) - const finalResult = { ...mergedResult, ...commonLocaleData } - - // 병합된 결과 출력 - // console.log('finalResult:', finalResult) + const finalResult = { ...apiData } return finalResult } catch (error) { diff --git a/i18n/locales/zh-cn.ts b/i18n/locales/zh-cn.ts index c9ce1cd..1f3ef75 100644 --- a/i18n/locales/zh-cn.ts +++ b/i18n/locales/zh-cn.ts @@ -1,57 +1,29 @@ -// import { TRANSLATION_ITEMS } from '../i18n.config' -// common.json 파일을 직접 import -// @ts-ignore -import commonData from '../../layers/assets/data/common.json' - export default defineI18nLocale(async (locale: string) => { - // const config = useRuntimeConfig() - // const baseType = config.public.baseType - // const translationItems = config.public.translationItems - // const translationItemsArr = translationItems.split(',') - // const staticUrl = config.public.staticUrl - // const translationPaths = translationItemsArr.map((item) => { - // 경로를 생성하며 ~/assets/data 경로로 설정 - // return `~/assets/data/${item}.json` - // }) - // const resources = await Promise.all(translationPaths.map((path) => import(`${path}`))) + //https://static-pubcomm.gate8.com/dev/test/multilingual/test_common_template.json?20251021185116 + const config = useRuntimeConfig() + const rootPath = config.public.staticUrl + const runType = config.public.runType - // console.log('translationLocal ~ translationLocal:', translationLocal) - // const translationApi = translationItemsArr.map((item: string): string => { - // return `${staticUrl}/${baseType}/tmp/${item}.json` - // }) - - // // API 데이터 가져오기 - // const fetchDataPromises = translationApi.map((apiUrl) => { - // return useFetch(apiUrl, { - // method: 'GET', - // headers: { - // 'Content-Type': 'application/json;charset=UTF-8' - // } - // }) - // }) + const translationApi = `${rootPath}/${runType}/test/multilingual/test_common_template.json` try { - // const fetchResults = await Promise.all(fetchDataPromises) + const { data } = await useFetch(translationApi, { + method: 'GET', + headers: { + 'Content-Type': 'application/json;charset=UTF-8' + } + }) - // // 각 결과에서 locale에 맞는 데이터를 추출 - // const apiData = fetchResults.map((result) => { - // return result.data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - // }) - // // apiData를 이용해 자동으로 병합 - // const mergedResult = apiData.reduce((acc, data) => { - // return { ...acc, ...data } - // }, {}) + if(locale === 'zh-cn') { + locale = 'zh-CN' + } + + // API 데이터에서 locale에 맞는 데이터를 추출 + const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - // common.json에서 해당 locale의 데이터를 가져와서 병합 - const commonLocaleData = commonData[locale] || {} - // API 데이터와 common.json 데이터를 병합 (common.json이 우선순위) - // const finalResult = { ...mergedResult, ...commonLocaleData } - const finalResult = { ...commonLocaleData } - - // 병합된 결과 출력 - // console.log('finalResult:', finalResult) + const finalResult = { ...apiData } return finalResult } catch (error) { diff --git a/i18n/locales/zh-tw.ts b/i18n/locales/zh-tw.ts index c9ce1cd..46de894 100644 --- a/i18n/locales/zh-tw.ts +++ b/i18n/locales/zh-tw.ts @@ -1,57 +1,29 @@ -// import { TRANSLATION_ITEMS } from '../i18n.config' -// common.json 파일을 직접 import -// @ts-ignore -import commonData from '../../layers/assets/data/common.json' - export default defineI18nLocale(async (locale: string) => { - // const config = useRuntimeConfig() - // const baseType = config.public.baseType - // const translationItems = config.public.translationItems - // const translationItemsArr = translationItems.split(',') - // const staticUrl = config.public.staticUrl - // const translationPaths = translationItemsArr.map((item) => { - // 경로를 생성하며 ~/assets/data 경로로 설정 - // return `~/assets/data/${item}.json` - // }) - // const resources = await Promise.all(translationPaths.map((path) => import(`${path}`))) + //https://static-pubcomm.gate8.com/dev/test/multilingual/test_common_template.json?20251021185116 + const config = useRuntimeConfig() + const rootPath = config.public.staticUrl + const runType = config.public.runType - // console.log('translationLocal ~ translationLocal:', translationLocal) - // const translationApi = translationItemsArr.map((item: string): string => { - // return `${staticUrl}/${baseType}/tmp/${item}.json` - // }) - - // // API 데이터 가져오기 - // const fetchDataPromises = translationApi.map((apiUrl) => { - // return useFetch(apiUrl, { - // method: 'GET', - // headers: { - // 'Content-Type': 'application/json;charset=UTF-8' - // } - // }) - // }) + const translationApi = `${rootPath}/${runType}/test/multilingual/test_common_template.json` try { - // const fetchResults = await Promise.all(fetchDataPromises) + const { data } = await useFetch(translationApi, { + method: 'GET', + headers: { + 'Content-Type': 'application/json;charset=UTF-8' + } + }) - // // 각 결과에서 locale에 맞는 데이터를 추출 - // const apiData = fetchResults.map((result) => { - // return result.data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - // }) - // // apiData를 이용해 자동으로 병합 - // const mergedResult = apiData.reduce((acc, data) => { - // return { ...acc, ...data } - // }, {}) + if(locale === 'zh-tw') { + locale = 'zh-TW' + } + + // API 데이터에서 locale에 맞는 데이터를 추출 + const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환 - // common.json에서 해당 locale의 데이터를 가져와서 병합 - const commonLocaleData = commonData[locale] || {} - // API 데이터와 common.json 데이터를 병합 (common.json이 우선순위) - // const finalResult = { ...mergedResult, ...commonLocaleData } - const finalResult = { ...commonLocaleData } - - // 병합된 결과 출력 - // console.log('finalResult:', finalResult) + const finalResult = { ...apiData } return finalResult } catch (error) { diff --git a/layers/components/layouts/Footer.vue b/layers/components/layouts/Footer.vue index d822bad..9dbfecd 100644 --- a/layers/components/layouts/Footer.vue +++ b/layers/components/layouts/Footer.vue @@ -16,7 +16,7 @@ }" > - 게임등급 + /> -->
스마일게이트 로고 NX3 로고 @@ -160,85 +157,18 @@