feat. i18n 설정

This commit is contained in:
김채린
2025-09-09 04:09:54 +00:00
parent 9581e5d356
commit a3dee13089
45 changed files with 2929 additions and 2374 deletions

View File

@@ -0,0 +1,25 @@
export default defineNuxtPlugin(() => {
const { $i18n } = useNuxtApp()
const gameDataStore = useGameDataStore()
// gameData가 로드되면 언어 제외 설정 적용
watchEffect(() => {
const gameData = gameDataStore.gameData
if (gameData && gameData.lang_codes && gameData.lang_codes.length > 0) {
const allowedLangCodes = gameData.lang_codes
// 현재 설정된 locales에서 허용된 언어만 필터링
const availableLocales = $i18n.locales.value.filter((locale: any) =>
allowedLangCodes.includes(locale.code)
)
// locales 업데이트
$i18n.locales.value = availableLocales
// 현재 locale이 허용되지 않은 경우 기본 locale로 변경
if (!allowedLangCodes.includes($i18n.locale.value)) {
$i18n.locale.value = gameData.default_lang_code || 'ko'
}
}
})
})

View File

@@ -0,0 +1,25 @@
export default defineNuxtPlugin(() => {
const { $i18n } = useNuxtApp()
// SSR에서 gameData를 가져와서 언어 제외 설정 적용
const gameDataFromServer = process.server
? useNuxtApp().ssrContext?.event.context.gameData
: null
if (gameDataFromServer && gameDataFromServer.lang_codes && gameDataFromServer.lang_codes.length > 0) {
const allowedLangCodes = gameDataFromServer.lang_codes
// 현재 설정된 locales에서 허용된 언어만 필터링
const availableLocales = $i18n.locales.value.filter((locale: any) =>
allowedLangCodes.includes(locale.code)
)
// locales 업데이트
$i18n.locales.value = availableLocales
// 현재 locale이 허용되지 않은 경우 기본 locale로 변경
if (!allowedLangCodes.includes($i18n.locale.value)) {
$i18n.locale.value = gameDataFromServer.default_lang_code || 'ko'
}
}
})