refactor: i18n 언어 호출 수정
This commit is contained in:
@@ -7,23 +7,14 @@ export default defineI18nLocale(async (locale: string) => {
|
||||
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'
|
||||
}
|
||||
})
|
||||
|
||||
// API 데이터에서 locale에 맞는 데이터를 추출
|
||||
const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환
|
||||
|
||||
// API 데이터와 common.json 데이터를 병합 (common.json이 우선순위)
|
||||
const finalResult = { ...apiData }
|
||||
|
||||
return finalResult
|
||||
} catch (error) {
|
||||
console.error('Error fetching translation data:', error)
|
||||
// 에러 발생 시 common.json 데이터라도 반환
|
||||
return commonData[locale] || {}
|
||||
const result = (await commonFetch('GET', `${translationApi}`)) as any
|
||||
if(import.meta.client) {
|
||||
console.log("🚀 ~ result:", result[locale])
|
||||
}
|
||||
return result[locale]
|
||||
} catch (e) {
|
||||
console.error('[Exception] ko.defineI18nLocale: ', e)
|
||||
return fallback
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -7,28 +7,14 @@ export default defineI18nLocale(async (locale: string) => {
|
||||
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'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
if(locale === 'zh-tw') {
|
||||
locale = 'zh-TW'
|
||||
const result = (await commonFetch('GET', `${translationApi}`)) as any
|
||||
if(import.meta.client) {
|
||||
console.log("🚀 ~ result:", result[locale])
|
||||
}
|
||||
|
||||
// API 데이터에서 locale에 맞는 데이터를 추출
|
||||
const apiData = data.value?.[locale] || {} // locale에 맞는 데이터가 없으면 빈 객체 반환
|
||||
|
||||
// API 데이터와 common.json 데이터를 병합 (common.json이 우선순위)
|
||||
const finalResult = { ...apiData }
|
||||
|
||||
return finalResult
|
||||
} catch (error) {
|
||||
console.error('Error fetching translation data:', error)
|
||||
// 에러 발생 시 common.json 데이터라도 반환
|
||||
return commonData[locale] || {}
|
||||
return result[locale]
|
||||
} catch (e) {
|
||||
console.error('[Exception] ko.defineI18nLocale: ', e)
|
||||
return fallback
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user