refactor: 다국어 파일 경로 수정, 다국어 플러그인 추가
This commit is contained in:
2
.env.dev
2
.env.dev
@@ -4,7 +4,7 @@ BASE_DOMAIN='.onstove.com'
|
||||
# URLS ##############################################################################
|
||||
STATIC_URL='https://static-pubcomm.gate8.com'
|
||||
ASSETS_URL='https://static-pubcomm.gate8.com/dev/template/brand'
|
||||
DATA_RESOURCE_URL='https://static-pubcomm.gate8.com/dev/test'
|
||||
DATA_RESOURCE_URL='https://static-pubcomm.gate8.com/dev/STOVE_PUBTEMPLATE'
|
||||
|
||||
# STOVE #############################################################################
|
||||
# STOVE - API Url
|
||||
|
||||
@@ -4,7 +4,7 @@ BASE_DOMAIN='.onstove.com'
|
||||
# URLS ##############################################################################
|
||||
STATIC_URL='https://static-pubcomm.onstove.com'
|
||||
ASSETS_URL='https://static-pubcomm.onstove.com/live/template/brand'
|
||||
DATA_RESOURCE_URL='https://static-pubcomm.onstove.com/live/test'
|
||||
DATA_RESOURCE_URL='https://static-pubcomm.gate8.com/live/STOVE_PUBTEMPLATE'
|
||||
|
||||
# STOVE #############################################################################
|
||||
# STOVE - API Url
|
||||
|
||||
2
.env.qa
2
.env.qa
@@ -4,7 +4,7 @@ BASE_DOMAIN='.onstove.com'
|
||||
# URLS ##############################################################################
|
||||
STATIC_URL='https://static-pubcomm.gate8.com'
|
||||
ASSETS_URL='https://static-pubcomm.gate8.com/qa/template/brand'
|
||||
DATA_RESOURCE_URL='https://static-pubcomm.gate8.com/qa/test'
|
||||
DATA_RESOURCE_URL='https://static-pubcomm.gate8.com/qa/STOVE_PUBTEMPLATE'
|
||||
|
||||
# STOVE #############################################################################
|
||||
# STOVE - API Url
|
||||
|
||||
@@ -5,7 +5,7 @@ BASE_DOMAIN='.gate8.com'
|
||||
STATIC_URL='https://static-pubcomm.gate8.com'
|
||||
ASSETS_URL='https://static-pubcomm.gate8.com/sandbox/template/brand'
|
||||
DATA_RESOURCE_URL='https://static-pubcomm.gate8.com/sandbox/test'
|
||||
|
||||
DATA_RESOURCE_URL='https://static-pubcomm.gate8.com/sandbox/STOVE_PUBTEMPLATE'
|
||||
# STOVE #############################################################################
|
||||
# STOVE - API Url
|
||||
STOVE_API_URL=https://api.gate8.com
|
||||
|
||||
@@ -3,7 +3,7 @@ import fallback from './fallback/de'
|
||||
export default defineI18nLocale(async (locale: string) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_common_template.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_secure.json'
|
||||
try {
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
baseApiUrl: dataResourcesUrl,
|
||||
|
||||
@@ -3,7 +3,7 @@ import fallback from './fallback/en'
|
||||
export default defineI18nLocale(async (locale: string) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_common_template.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_secure.json'
|
||||
try {
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
baseApiUrl: dataResourcesUrl,
|
||||
|
||||
@@ -3,7 +3,7 @@ import fallback from './fallback/es'
|
||||
export default defineI18nLocale(async (locale: string) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_common_template.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_secure.json'
|
||||
try {
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
baseApiUrl: dataResourcesUrl,
|
||||
|
||||
@@ -3,7 +3,7 @@ import fallback from './fallback/fr'
|
||||
export default defineI18nLocale(async (locale: string) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_common_template.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_secure.json'
|
||||
try {
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
baseApiUrl: dataResourcesUrl,
|
||||
|
||||
@@ -3,7 +3,7 @@ import fallback from './fallback/ja'
|
||||
export default defineI18nLocale(async (locale: string) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_common_template.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_secure.json'
|
||||
try {
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
baseApiUrl: dataResourcesUrl,
|
||||
|
||||
@@ -3,7 +3,7 @@ import fallback from './fallback/ko'
|
||||
export default defineI18nLocale(async (locale: string) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_common_template.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_secure.json'
|
||||
try {
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
baseApiUrl: dataResourcesUrl,
|
||||
|
||||
@@ -3,7 +3,7 @@ import fallback from './fallback/pt'
|
||||
export default defineI18nLocale(async (locale: string) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_common_template.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_secure.json'
|
||||
try {
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
baseApiUrl: dataResourcesUrl,
|
||||
|
||||
@@ -3,7 +3,7 @@ import fallback from './fallback/th'
|
||||
export default defineI18nLocale(async (locale: string) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_common_template.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_secure.json'
|
||||
try {
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
baseApiUrl: dataResourcesUrl,
|
||||
|
||||
@@ -3,7 +3,7 @@ import fallback from './fallback/zh-cn'
|
||||
export default defineI18nLocale(async (locale: string) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_common_template.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_secure.json'
|
||||
try {
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
baseApiUrl: dataResourcesUrl,
|
||||
|
||||
@@ -3,7 +3,7 @@ import fallback from './fallback/zh-tw'
|
||||
export default defineI18nLocale(async (locale: string) => {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_common_template.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_secure.json'
|
||||
try {
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
baseApiUrl: dataResourcesUrl,
|
||||
|
||||
@@ -138,20 +138,8 @@
|
||||
<script setup lang="ts">
|
||||
import type { FooterMenuItem, FooterData, DevCiConfig } from '#layers/types/Common'
|
||||
|
||||
// Configuration
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_common_template.json'
|
||||
|
||||
// Multilingual
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
baseApiUrl: dataResourcesUrl,
|
||||
fileName: multilingualFileName,
|
||||
})
|
||||
const { tm }: any = useI18n({
|
||||
useScope: 'local',
|
||||
messages: Object(resultGetMultilingual?.value?.multilingual),
|
||||
})
|
||||
const { tm }: any = useI18n()
|
||||
|
||||
const gameDataStore = useGameDataStore()
|
||||
const { gameData } = storeToRefs(gameDataStore)
|
||||
|
||||
52
layers/plugins/i18n-loader.client.ts
Normal file
52
layers/plugins/i18n-loader.client.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* i18n 다국어 로더 플러그인
|
||||
* S3에서 공통 다국어 파일을 로드하여 i18n 메시지에 주입합니다.
|
||||
*/
|
||||
export default defineNuxtPlugin(async (nuxtApp) => {
|
||||
const $i18n = nuxtApp.$i18n as any
|
||||
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const commonTranslations = 'STOVE_PUBTEMPLATE_common_translations.json'
|
||||
|
||||
const gameDataStore = useGameDataStore()
|
||||
const { gameData } = storeToRefs(gameDataStore)
|
||||
const langCodes = gameData.value?.lang_codes
|
||||
|
||||
if (!langCodes || langCodes.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const url = `${dataResourcesUrl}/multilingual/${commonTranslations}`
|
||||
const translations = await commonFetch('GET', url)
|
||||
|
||||
if (!translations || typeof translations !== 'object') {
|
||||
return
|
||||
}
|
||||
|
||||
// 로케일 코드 변환 맵 (소문자 하이픈 -> 대문자 하이픈)
|
||||
const localeMap: Record<string, string> = {
|
||||
'zh-tw': 'zh-TW',
|
||||
'zh-cn': 'zh-CN',
|
||||
}
|
||||
|
||||
langCodes.forEach((langCode) => {
|
||||
// 로케일 코드 변환 (필요한 경우)
|
||||
const normalizedLangCode = localeMap[langCode] || langCode
|
||||
|
||||
// 대소문자 구분 없이 로케일 데이터 찾기
|
||||
const localeData =
|
||||
translations[normalizedLangCode] ||
|
||||
translations[normalizedLangCode.toLowerCase()] ||
|
||||
translations[langCode] ||
|
||||
translations[langCode.toLowerCase()]
|
||||
|
||||
if (localeData && typeof localeData === 'object') {
|
||||
$i18n.setLocaleMessage(langCode, localeData)
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('[Exception] i18n-loader: Failed to load translations:', error)
|
||||
}
|
||||
})
|
||||
@@ -14,7 +14,7 @@ const props = defineProps<Props>()
|
||||
// Configuration
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_homepage_brand_download.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_download.json'
|
||||
|
||||
// Multilingual
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
|
||||
@@ -15,7 +15,7 @@ const { handleTokenValidation } = useTokenValidation()
|
||||
// Configuration
|
||||
const config = useRuntimeConfig()
|
||||
const dataResourcesUrl = config.public.dataResourcesUrl as string
|
||||
const multilingualFileName = 'test_homepage_brand_secure.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_secure.json'
|
||||
const stoveApiBaseUrl = config.public.stoveApiUrl
|
||||
|
||||
// Multilingual
|
||||
|
||||
@@ -26,7 +26,7 @@ const { pageData } = storeToRefs(pageDataStore)
|
||||
// Configuration
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const dataResourcesUrl = runtimeConfig.public.dataResourcesUrl
|
||||
const multilingualFileName = 'test_homepage_brand_video.json'
|
||||
const multilingualFileName = 'STOVE_PUBTEMPLATE_homepage_brand_video.json'
|
||||
|
||||
// Multilingual
|
||||
const resultGetMultilingual = await useGetMultilingual({
|
||||
|
||||
Reference in New Issue
Block a user