Ver3.0 ๐ ์น ๊ตญ์ ํ i18n๊ณผ ๋ค๊ตญ์ด ์ง์ ์๋ฒฝ ๊ฐ์ด๋

๐ ์น ๊ตญ์ ํ i18n๊ณผ ๋ค๊ตญ์ด ์ง์ ์๋ฒฝ ๊ฐ์ด๋
์ ์ธ๊ณ ์ฌ์ฉ์๋ฅผ ์ฌ๋ก์ก๋ ๊ธ๋ก๋ฒ ์น์ฌ์ดํธ ๋ง๋ค๊ธฐ
๐ฏ ์ i18n์ด ์ค์ํ ๊น?
์น๊ตฌ์ผ, ํน์ ํด์ธ ์ฌ์ดํธ ๋ค์ด๊ฐ๋ค๊ฐ ํ๊ธ ์ง์์ด ์ ๋ผ์ ๋นํฉํ ์ ์์ง? ๐ ์๋๋ฉด ๋ฒ์ญ์ด ๋๋ฌด ์ด์ํด์ ์์์ด ๋์จ ๊ฒฝํ์? ๋ฐ๋ก ๊ทธ๊ฒ ๊ตญ์ ํ(i18n)๊ฐ ์ ๋๋ก ์ ๋ ์ฌ๋ก์ผ.
i18n์ 'internationalization'์ ์ค์๋ง์ธ๋ฐ, i์ n ์ฌ์ด์ 18๊ธ์๊ฐ ์์ด์ ์ด๋ ๊ฒ ๋ถ๋ฅธ๋. ์ฌ์น์์ง? ๐ค ์ด๊ฑด ๋จ์ํ ์ธ์ด๋ง ๋ฐ๊พธ๋ ๊ฒ ์๋๋ผ, ์ ์ธ๊ณ ์ฌ์ฉ์๋ค์ด ์์ฐ์ค๋ฝ๊ฒ ์น์ฌ์ดํธ๋ฅผ ์ด์ฉํ ์ ์๋๋ก ๋ง๋๋ ๋ชจ๋ ๊ณผ์ ์ ๋งํด.
2. ์ฌ์ฉ์ ๊ฒฝํ: ๋ชจ๊ตญ์ด๋ก ์๋น์ค๋ฅผ ์ด์ฉํ ๋ ์ ๋ขฐ๋๊ฐ 70% ์ด์ ์ฆ๊ฐ
3. ๊ฒฝ์๋ ฅ: ๊ธ๋ก๋ฒ ๊ธฐ์ ๋ค์ ํ์ ์๊ฑด, ์ฐจ๋ณํ ํฌ์ธํธ
4. SEO ํจ๊ณผ: ๊ฐ ์ธ์ด๋ณ ๊ฒ์ ์์ง ์ต์ ํ๋ก ํธ๋ํฝ ์ฆ๊ฐ
์ค์ ๋ก ์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ๋ ๋ค์ํ ์ฌ๋ฅ์ ๊ฐ์ง ์ฌ๋๋ค์ด ๊ตญ๊ฒฝ์ ๋์ด ๊ฑฐ๋ํ ์ ์๋๋ก ๋ค๊ตญ์ด ์ง์์ ๊ณ ๋ คํ๊ณ ์์ด. ํ๋ก๊ทธ๋๋ฐ, ๋์์ธ, ๋ฒ์ญ ๋ฑ ๋ค์ํ ์ฌ๋ฅ์ด ์ค๊ฐ๋ ๊ณณ์ด๋๊น ๋ง์ด์ผ. ๐ผ
๐๏ธ i18n ์ํคํ ์ฒ ์ค๊ณ ๊ธฐ์ด
1. ๊ธฐ๋ณธ ๊ฐ๋ ์ดํดํ๊ธฐ
๊ตญ์ ํ๋ฅผ ์์ํ๊ธฐ ์ ์ ์์์ผ ํ ํต์ฌ ๊ฐ๋ ๋ค์ด ์์ด. ์ด๊ฑธ ๋ชจ๋ฅด๊ณ ์์ํ๋ฉด ๋์ค์ ์ ์ฒด๋ฅผ ๋ค์ ๋ง๋ค์ด์ผ ํ ์๋ ์์ผ๋ ์ฃผ์! โ ๏ธ
โข Translation Key: ๋ฒ์ญ ๋ฌธ์์ด์ ์๋ณํ๋ ๊ณ ์ ํค
โข Fallback Language: ๋ฒ์ญ์ด ์์ ๋ ๋์ฒดํ ๊ธฐ๋ณธ ์ธ์ด
โข RTL (Right-to-Left): ์๋์ด, ํ๋ธ๋ฆฌ์ด์ฒ๋ผ ์ค๋ฅธ์ชฝ์์ ์ผ์ชฝ์ผ๋ก ์ฐ๋ ์ธ์ด
โข Pluralization: ๋จ์/๋ณต์ ํํ ์ฒ๋ฆฌ
โข Interpolation: ๋ฒ์ญ ๋ฌธ์์ด์ ๋ณ์ ์ฝ์
2. ํ๋ก์ ํธ ๊ตฌ์กฐ ์ค๊ณ
์ฒ์๋ถํฐ ํ์ฅ ๊ฐ๋ฅํ ๊ตฌ์กฐ๋ก ๋ง๋๋ ๊ฒ ์ค์ํด. ๋์ค์ ์ธ์ด ์ถ๊ฐํ ๋๋ง๋ค ์ฝ๋ ์ ์ฒด๋ฅผ ๋ค์ง๊ณ ์ถ์ง ์๋ค๋ฉด ๋ง์ด์ผ. ๐๏ธ
project/
โโโ src/
โ โโโ locales/ # ๋ฒ์ญ ํ์ผ ๋๋ ํ ๋ฆฌ
โ โ โโโ ko/
โ โ โ โโโ common.json
โ โ โ โโโ home.json
โ โ โ โโโ errors.json
โ โ โโโ en/
โ โ โ โโโ common.json
โ โ โ โโโ home.json
โ โ โ โโโ errors.json
โ โ โโโ ja/
โ โ โโโ ...
โ โโโ i18n/ # i18n ์ค์ ๋ฐ ์ ํธ
โ โ โโโ config.js
โ โ โโโ detector.js # ์ธ์ด ๊ฐ์ง
โ โ โโโ formatter.js # ๋ ์ง, ์ซ์ ํฌ๋งท
โ โโโ components/
โโโ public/
โโโ locales/ # ์ ์ ๋ฒ์ญ ํ์ผ (์ต์
)
์ด๋ ๊ฒ ๊ตฌ์กฐ๋ฅผ ์ก์ผ๋ฉด ๊ฐ ์ธ์ด๋ณ๋ก ํ์ผ์ ๋ถ๋ฆฌํด์ ๊ด๋ฆฌํ ์ ์๊ณ , ๋ฒ์ญ๊ฐ๋ค๋ ์ฝ๊ฒ ์์ ํ ์ ์์ด. โจ
3. ๋ฒ์ญ ํ์ผ ํฌ๋งท ์ ํ
JSON์ด ๊ฐ์ฅ ์ผ๋ฐ์ ์ด์ง๋ง, ํ๋ก์ ํธ ํน์ฑ์ ๋ฐ๋ผ ๋ค๋ฅธ ํฌ๋งท๋ ๊ณ ๋ คํด๋ณผ ์ ์์ด.
YAML: ๊ฐ๋ ์ฑ ์ฐ์, ์ฃผ์ ๊ฐ๋ฅ, ๋ณต์กํ ๊ตฌ์กฐ์ ์ ํฉ
PO/POT: ์ ๋ฌธ ๋ฒ์ญ ๋๊ตฌ ์ง์, ๋ฒ์ญ ๋ฉํ๋ฐ์ดํฐ ๊ด๋ฆฌ
ICU Message Format: ๋ณต์กํ ๋ฌธ๋ฒ ๊ท์น ์ฒ๋ฆฌ์ ๊ฐ๋ ฅ
JSON ์์๋ฅผ ๋ณด๋ฉด ์ดํด๊ฐ ๋น ๋ฅผ ๊ฑฐ์ผ:
{
"common": {
"welcome": "ํ์ํฉ๋๋ค",
"login": "๋ก๊ทธ์ธ",
"logout": "๋ก๊ทธ์์"
},
"home": {
"title": "ํํ์ด์ง",
"greeting": "์๋
ํ์ธ์, {{name}}๋!",
"itemCount": "{{count}}๊ฐ์ ์์ดํ
"
},
"errors": {
"notFound": "ํ์ด์ง๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค",
"serverError": "์๋ฒ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค"
}
}
โ๏ธ ์ฃผ์ ํ๋ ์์ํฌ๋ณ ๊ตฌํ ๋ฐฉ๋ฒ
1. React์์ i18n ๊ตฌํํ๊ธฐ
React์์๋ react-i18next๊ฐ ์ฌ์ค์ ํ์ค์ด์ผ. ์ฌ์ฉ๋ฒ๋ ์ง๊ด์ ์ด๊ณ ๊ธฐ๋ฅ๋ ๊ฐ๋ ฅํด์ ๋๋ถ๋ถ์ ํ๋ก์ ํธ์์ ์ฌ์ฉํ๊ณ ์์ด. โ๏ธ
// i18n.js ์ค์ ํ์ผ
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import translationKO from './locales/ko/translation.json';
import translationEN from './locales/en/translation.json';
const resources = {
ko: { translation: translationKO },
en: { translation: translationEN }
};
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources,
fallbackLng: 'ko',
debug: false,
interpolation: {
escapeValue: false
}
});
export default i18n;
์ปดํฌ๋ํธ์์ ์ฌ์ฉํ ๋๋ ์ด๋ ๊ฒ ๊ฐ๋จํด:
import { useTranslation } from 'react-i18next';
function Welcome() {
const { t, i18n } = useTranslation();
const changeLanguage = (lng) => {
i18n.changeLanguage(lng);
};
return (
<div>
<h1>{t('common.welcome')}</h1>
<p>{t('home.greeting', { name: '์ฒ ์' })}</p>
<button onClick={() => changeLanguage('en')}>English</button>
<button onClick={() => changeLanguage('ko')}>ํ๊ตญ์ด</button>
</div>
);
}
2. Namespace ๋ถ๋ฆฌ: ํ์ด์ง๋ณ๋ก ๋ฒ์ญ ํ์ผ ๋ถ๋ฆฌํด์ ๋ฒ๋ค ํฌ๊ธฐ ์ต์ ํ
3. Trans ์ปดํฌ๋ํธ: HTML ํ๊ทธ๊ฐ ํฌํจ๋ ๋ฒ์ญ์ ์ฌ์ฉ
4. Context API ์ฐ๋: ์ ์ญ ์ธ์ด ์ํ ๊ด๋ฆฌ
2. Vue.js์์ i18n ๊ตฌํํ๊ธฐ
Vue๋ vue-i18n์ด ๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ผ. Vue 3๋ถํฐ๋ Composition API์๋ ์๋ฒฝํ๊ฒ ํธํ๋ผ. ๐จ
// i18n.js
import { createI18n } from 'vue-i18n';
const messages = {
ko: {
message: {
hello: '์๋
ํ์ธ์',
welcome: '{name}๋ ํ์ํฉ๋๋ค'
}
},
en: {
message: {
hello: 'Hello',
welcome: 'Welcome, {name}'
}
}
};
const i18n = createI18n({
locale: 'ko',
fallbackLocale: 'en',
messages
});
export default i18n;
// main.js
import { createApp } from 'vue';
import App from './App.vue';
import i18n from './i18n';
createApp(App).use(i18n).mount('#app');
์ปดํฌ๋ํธ์์๋ ์ด๋ ๊ฒ ์ฌ์ฉํด:
<template>
<div>
<h1>{{ $t('message.hello') }}</h1>
<p>{{ $t('message.welcome', { name: userName }) }}</p>
<select v-model="$i18n.locale">
<option value="ko">ํ๊ตญ์ด</option>
<option value="en">English</option>
</select>
</div>
</template>
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
const { t, locale } = useI18n();
const userName = ref('์ํฌ');
</script>
3. Next.js์์ i18n ๊ตฌํํ๊ธฐ
Next.js๋ ํ๋ ์์ํฌ ์์ฒด์ i18n ๋ผ์ฐํ ๊ธฐ๋ฅ์ด ๋ด์ฅ๋์ด ์์ด์ SEO์ ํนํ ์ ๋ฆฌํด. ๐
// next.config.js
module.exports = {
i18n: {
locales: ['ko', 'en', 'ja'],
defaultLocale: 'ko',
localeDetection: true
}
};
// pages/index.js
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useTranslation } from 'next-i18next';
export default function Home() {
const { t } = useTranslation('common');
return (
<div>
<h1>{t('welcome')}</h1>
</div>
);
}
export async function getStaticProps({ locale }) {
return {
props: {
...(await serverSideTranslations(locale, ['common']))
}
};
}
2. SSR/SSG ๊ณ ๋ ค: getStaticProps๋ getServerSideProps์์ ๋ฒ์ญ ๋ก๋
3. ๋์ ๋ผ์ฐํ : [locale] ํด๋ ๊ตฌ์กฐ๋ก ๊ด๋ฆฌ
4. ๋ฏธ๋ค์จ์ด ํ์ฉ: Next.js 12+ ์์ ์ธ์ด ๊ฐ์ง ๋ฐ ๋ฆฌ๋ค์ด๋ ํธ
4. Angular์์ i18n ๊ตฌํํ๊ธฐ
Angular๋ ๊ณต์ i18n ์๋ฃจ์ ์ด ์๊ณ , ๋น๋ ํ์์ ๋ฒ์ญ์ ์ฒ๋ฆฌํ๋ ๋ฐฉ์์ด ํน์ง์ด์ผ. ๐ ฐ๏ธ
// angular.json ์ค์
{
"projects": {
"myapp": {
"i18n": {
"sourceLocale": "ko",
"locales": {
"en": "src/locale/messages.en.xlf",
"ja": "src/locale/messages.ja.xlf"
}
}
}
}
}
// ์ปดํฌ๋ํธ์์ ์ฌ์ฉ
<h1 i18n="@@welcomeMessage">ํ์ํฉ๋๋ค</h1>
<p i18n>์๋
ํ์ธ์, {{userName}}๋!</p>
// ์ถ์ถ ๋ช
๋ น์ด
ng extract-i18n --output-path src/locale
// ๋น๋
ng build --localize
๐จ UI/UX ๊ตญ์ ํ ๊ณ ๋ ค์ฌํญ
1. ํ ์คํธ ๊ธธ์ด ๋ณํ ๋์
๊ฐ์ ๋ด์ฉ์ด๋ผ๋ ์ธ์ด๋ง๋ค ๊ธธ์ด๊ฐ ์์ ํ ๋ฌ๋ผ์ ธ. ๋ ์ผ์ด๋ ์์ด๋ณด๋ค ํ๊ท 30% ๋ ๊ธธ๊ณ , ํ๊ตญ์ด๋ ์ํฉ์ ๋ฐ๋ผ ์งง์ ์๋ ๊ธธ ์๋ ์์ด. ๐
โข ๋ ์ผ์ด: "Speichern" (์ฝ 2๋ฐฐ)
โข ํ๋์ค์ด: "Enregistrer" (์ฝ 2.5๋ฐฐ)
โข ํ๊ตญ์ด: "์ ์ฅ" (๋น์ท)
โข ์ผ๋ณธ์ด: "ไฟๅญ" (๋น์ท)
๋์์ธ ํ: ๋ฒํผ๊ณผ ๋ ์ด๋ธ์ ์ต์ 30% ์ฌ์ ๊ณต๊ฐ ํ๋ณด
/* CSS๋ก ํ
์คํธ ์ค๋ฒํ๋ก์ฐ ์ฒ๋ฆฌ */
.button {
min-width: 120px;
padding: 10px 20px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* ์ธ์ด๋ณ ์กฐ๊ฑด๋ถ ์คํ์ผ */
[lang="de"] .button {
min-width: 150px;
}
[lang="ko"] .button,
[lang="ja"] .button {
min-width: 100px;
}
2. RTL (Right-to-Left) ์ธ์ด ์ง์
์๋์ด, ํ๋ธ๋ฆฌ์ด, ํ๋ฅด์์์ด๋ ์ค๋ฅธ์ชฝ์์ ์ผ์ชฝ์ผ๋ก ์ฝ์ด. ๋จ์ํ ํ ์คํธ๋ง ๋ค์ง๋ ๊ฒ ์๋๋ผ ์ ์ฒด ๋ ์ด์์์ด ๋ฏธ๋ฌ๋ง๋์ด์ผ ํด. ๐ช
/* RTL ์๋ ๋์ CSS */
.container {
margin-inline-start: 20px; /* margin-left ๋์ */
padding-inline-end: 15px; /* padding-right ๋์ */
}
/* RTL ๊ฐ์ง ๋ฐ ์ ์ฉ */
[dir="rtl"] .sidebar {
left: auto;
right: 0;
}
[dir="rtl"] .icon {
transform: scaleX(-1); /* ์์ด์ฝ ์ข์ฐ ๋ฐ์ */
}
/* JavaScript๋ก dir ์์ฑ ์ค์ */
document.documentElement.dir = locale === 'ar' ? 'rtl' : 'ltr';
- โ ๋ ์ด์์: ์ฌ์ด๋๋ฐ, ๋ค๋น๊ฒ์ด์ ์์น ๋ฐ์
- โ ์์ด์ฝ: ๋ฐฉํฅ์ฑ ์๋ ์์ด์ฝ(ํ์ดํ ๋ฑ) ๋ฐ์
- โ ํผ: ๋ผ๋ฒจ๊ณผ ์ ๋ ฅ ํ๋ ์์น ์กฐ์
- โ ์ ๋๋ฉ์ด์ : ์ฌ๋ผ์ด๋ ๋ฐฉํฅ ๋ฐ์
- โ ํ ์คํธ ์ ๋ ฌ: text-align: start/end ์ฌ์ฉ
3. ๋ ์ง์ ์๊ฐ ํ์
๋ ์ง ํ๊ธฐ๋ ๋๋ผ๋ง๋ค ์์ ํ ๋ฌ๋ผ. ๋ฏธ๊ตญ์ MM/DD/YYYY, ํ๊ตญ์ YYYY.MM.DD, ์ ๋ฝ์ DD/MM/YYYY๋ฅผ ์จ. ๐
// JavaScript Intl API ํ์ฉ
const date = new Date('2024-01-15');
// ํ๊ตญ์ด
const koFormat = new Intl.DateTimeFormat('ko-KR', {
year: 'numeric',
month: 'long',
day: 'numeric'
}).format(date);
// ๊ฒฐ๊ณผ: "2024๋
1์ 15์ผ"
// ์์ด (๋ฏธ๊ตญ)
const enUSFormat = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
}).format(date);
// ๊ฒฐ๊ณผ: "January 15, 2024"
// ์์ด (์๊ตญ)
const enGBFormat = new Intl.DateTimeFormat('en-GB', {
year: 'numeric',
month: 'long',
day: 'numeric'
}).format(date);
// ๊ฒฐ๊ณผ: "15 January 2024"
// ์๋ ์๊ฐ ํ์
const rtf = new Intl.RelativeTimeFormat('ko', { numeric: 'auto' });
rtf.format(-1, 'day'); // "์ด์ "
rtf.format(2, 'hour'); // "2์๊ฐ ํ"
4. ์ซ์์ ํตํ ํ์
์ซ์ ํ๊ธฐ๋ ์ฒ์ฐจ๋ง๋ณ์ด์ผ. ์ฒ ๋จ์ ๊ตฌ๋ถ์๊ฐ ์ผํ์ธ ๊ณณ๋ ์๊ณ ์ ์ธ ๊ณณ๋ ์์ด. ๐ฐ
const number = 1234567.89;
// ํ๊ตญ์ด
new Intl.NumberFormat('ko-KR').format(number);
// "1,234,567.89"
// ๋
์ผ์ด
new Intl.NumberFormat('de-DE').format(number);
// "1.234.567,89"
// ํตํ ํ์
new Intl.NumberFormat('ko-KR', {
style: 'currency',
currency: 'KRW'
}).format(50000);
// "โฉ50,000"
new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(50000);
// "$50,000.00"
new Intl.NumberFormat('ja-JP', {
style: 'currency',
currency: 'JPY'
}).format(50000);
// "ยฅ50,000"
5. ํฐํธ์ ํ์ดํฌ๊ทธ๋ํผ
์ธ์ด๋ง๋ค ํ์ํ ํฐํธ๊ฐ ๋ค๋ฅด๊ณ , ๊ฐ๋ ์ฑ์ ์ํ ์ต์ ํฌ๊ธฐ๋ ๋ฌ๋ผ. ํนํ CJK(์ค๊ตญ์ด, ์ผ๋ณธ์ด, ํ๊ตญ์ด)๋ ๊ธ์ ์๊ฐ ๋ง์์ ์นํฐํธ ์ฉ๋์ด ์ปค์ง ์ ์์ด. ๐ค
/* ์ธ์ด๋ณ ํฐํธ ์คํ */
body {
font-family:
-apple-system, BlinkMacSystemFont,
"Segoe UI", Roboto,
"Noto Sans KR", /* ํ๊ตญ์ด */
"Noto Sans JP", /* ์ผ๋ณธ์ด */
"Noto Sans SC", /* ์ค๊ตญ์ด ๊ฐ์ฒด */
sans-serif;
}
/* ์ธ์ด๋ณ ํฐํธ ํฌ๊ธฐ ์กฐ์ */
[lang="ko"] {
font-size: 16px;
line-height: 1.6;
}
[lang="ja"] {
font-size: 15px;
line-height: 1.8;
}
[lang="th"] { /* ํ๊ตญ์ด๋ ์ค๊ฐ๊ฒฉ ๋ ํ์ */
line-height: 2.0;
}
/* ์นํฐํธ ์๋ธ์
๋ก๋ฉ */
@font-face {
font-family: 'Noto Sans KR';
src: url('/fonts/NotoSansKR-subset.woff2') format('woff2');
unicode-range: U+AC00-D7A3; /* ํ๊ธ ๋ฒ์๋ง */
font-display: swap;
}
๐ง ๊ณ ๊ธ i18n ๊ธฐ๋ฅ ๊ตฌํ
1. ๋ณต์ํ(Pluralization) ์ฒ๋ฆฌ
"1๊ฐ์ ์์ดํ "๊ณผ "2๊ฐ์ ์์ดํ "์ฒ๋ผ ์ซ์์ ๋ฐ๋ผ ํํ์ด ๋ฌ๋ผ์ง๋ ๊ฑธ ์ฒ๋ฆฌํด์ผ ํด. ์ธ์ด๋ง๋ค ๋ณต์ํ ๊ท์น์ด ์์ ํ ๋ค๋ฅด๋ค๋ ๊ฒ ํจ์ ์ด์ผ. ๐ข
ํ๊ตญ์ด/์ผ๋ณธ์ด: 1๊ฐ์ง ํํ (์ซ์๋ง ๋ฐ๋)
๋ฌ์์์ด: 3๊ฐ์ง ํํ (1, 2-4, 5+)
์๋์ด: 6๊ฐ์ง ํํ (0, 1, 2, 3-10, 11-99, 100+)
ํด๋๋์ด: 4๊ฐ์ง ํํ
// i18next ๋ณต์ํ ์์
{
"en": {
"item": "{{count}} item",
"item_plural": "{{count}} items"
},
"ko": {
"item": "{{count}}๊ฐ์ ์์ดํ
"
},
"ru": {
"item_one": "{{count}} ะฟัะตะดะผะตั",
"item_few": "{{count}} ะฟัะตะดะผะตัะฐ",
"item_many": "{{count}} ะฟัะตะดะผะตัะพะฒ"
}
}
// ์ฌ์ฉ
t('item', { count: 1 }); // "1 item" / "1๊ฐ์ ์์ดํ
"
t('item', { count: 5 }); // "5 items" / "5๊ฐ์ ์์ดํ
"
// ICU Message Format ์ฌ์ฉ
{
"items": "{count, plural, =0 {no items} one {# item} other {# items}}"
}
2. ์ปจํ ์คํธ๋ณ ๋ฒ์ญ
๊ฐ์ ๋จ์ด๋ผ๋ ๋ฌธ๋งฅ์ ๋ฐ๋ผ ๋ฒ์ญ์ด ๋ฌ๋ผ์ง ์ ์์ด. ์๋ฅผ ๋ค์ด "Close"๋ "๋ซ๊ธฐ"์ผ ์๋ ์๊ณ "๊ฐ๊น์ด"์ผ ์๋ ์์ง. ๐ญ
{
"close_button": "๋ซ๊ธฐ",
"close_distance": "๊ฐ๊น์ด",
"close_relationship": "์น๋ฐํ",
"bank_financial": "์ํ",
"bank_river": "๊ฐ๋",
"date_calendar": "๋ ์ง",
"date_romantic": "๋ฐ์ดํธ"
}
// ์ปจํ
์คํธ ๋ช
์์ ์ฌ์ฉ
t('close', { context: 'button' }); // "๋ซ๊ธฐ"
t('close', { context: 'distance' }); // "๊ฐ๊น์ด"
3. ๋์ ์ฝํ ์ธ ๋ฒ์ญ
์ฌ์ฉ์๊ฐ ์ ๋ ฅํ ์ฝํ ์ธ ๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค์์ ๊ฐ์ ธ์จ ๋ด์ฉ๋ ๋ฒ์ญ์ด ํ์ํ ๋๊ฐ ์์ด. ์ด๊ฑด ์ข ๋ ๋ณต์กํ ์ ๋ต์ด ํ์ํด. ๐
// ๋ฐ์ดํฐ๋ฒ ์ด์ค ์คํค๋ง ์์
CREATE TABLE products (
id INT PRIMARY KEY,
name_ko VARCHAR(255),
name_en VARCHAR(255),
name_ja VARCHAR(255),
description_ko TEXT,
description_en TEXT,
description_ja TEXT
);
// ๋๋ JSON ์ปฌ๋ผ ์ฌ์ฉ
CREATE TABLE products (
id INT PRIMARY KEY,
translations JSON
);
// translations ์์
{
"ko": {
"name": "์ํ๋ช
",
"description": "์ํ ์ค๋ช
"
},
"en": {
"name": "Product Name",
"description": "Product Description"
}
}
// API ์๋ต ๊ตฌ์กฐ
{
"id": 1,
"name": {
"ko": "๋
ธํธ๋ถ",
"en": "Laptop",
"ja": "ใใผใใใฝใณใณ"
},
"price": 1500000
}
// ํ๋ก ํธ์๋์์ ์ฌ์ฉ
const product = await fetchProduct(id);
const localizedName = product.name[currentLocale];
2. JSON ํ๋: ์ ์ฐํ์ง๋ง ์ฟผ๋ฆฌ๊ฐ ๋ณต์กํด์ง ์ ์์
3. ๋ณ๋ ํ ์ด๋ธ: ์ ๊ทํ๋์ง๋ง JOIN ํ์
4. ๋ฒ์ญ API: Google Translate API ๋ฑ ํ์ฉ (๋น์ฉ ๋ฐ์)
4. ์ธ์ด ๊ฐ์ง ๋ฐ ์๋ ์ ํ
์ฌ์ฉ์์ ์ธ์ด๋ฅผ ์๋์ผ๋ก ๊ฐ์งํด์ ์ ์ ํ ์ธ์ด๋ก ๋ณด์ฌ์ฃผ๋ ๊ฒ ์ข์ UX์ผ. ํ์ง๋ง ๊ฐ์ ํ๋ฉด ์ ๋๊ณ ์ ํ๊ถ์ ์ค์ผ ํด. ๐ฏ
// ์ธ์ด ๊ฐ์ง ์ฐ์ ์์
function detectLanguage() {
// 1. URL ํ๋ผ๋ฏธํฐ ํ์ธ
const urlParams = new URLSearchParams(window.location.search);
const urlLang = urlParams.get('lang');
if (urlLang && supportedLanguages.includes(urlLang)) {
return urlLang;
}
// 2. ๋ก์ปฌ ์คํ ๋ฆฌ์ง ํ์ธ (์ฌ์ฉ์๊ฐ ์ด์ ์ ์ ํํ ์ธ์ด)
const savedLang = localStorage.getItem('preferredLanguage');
if (savedLang && supportedLanguages.includes(savedLang)) {
return savedLang;
}
// 3. ๋ธ๋ผ์ฐ์ ์ธ์ด ์ค์ ํ์ธ
const browserLang = navigator.language.split('-')[0];
if (supportedLanguages.includes(browserLang)) {
return browserLang;
}
// 4. IP ๊ธฐ๋ฐ ์ง์ญ ๊ฐ์ง (์ ํ์ )
// const geoLang = await detectLanguageByIP();
// 5. ๊ธฐ๋ณธ ์ธ์ด ๋ฐํ
return 'ko';
}
// ์ธ์ด ๋ณ๊ฒฝ ํจ์
function changeLanguage(newLang) {
// ๋ก์ปฌ ์คํ ๋ฆฌ์ง์ ์ ์ฅ
localStorage.setItem('preferredLanguage', newLang);
// i18n ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ธ์ด ๋ณ๊ฒฝ
i18n.changeLanguage(newLang);
// URL ์
๋ฐ์ดํธ (์ ํ์ )
const url = new URL(window.location);
url.searchParams.set('lang', newLang);
window.history.pushState({}, '', url);
// HTML lang ์์ฑ ์
๋ฐ์ดํธ
document.documentElement.lang = newLang;
// RTL ์ธ์ด ์ฒ๋ฆฌ
document.documentElement.dir = rtlLanguages.includes(newLang) ? 'rtl' : 'ltr';
}
5. ๋ฒ์ญ ๋๋ฝ ์ฒ๋ฆฌ
๋ชจ๋ ํ ์คํธ๊ฐ ์๋ฒฝํ๊ฒ ๋ฒ์ญ๋์ด ์์ ์๋ ์์ด. ๋ฒ์ญ์ด ์์ ๋ ์ด๋ป๊ฒ ์ฒ๋ฆฌํ ์ง ์ ๋ต์ด ํ์ํด. ๐จ
// i18next ์ค์
i18n.init({
fallbackLng: 'ko', // ๊ธฐ๋ณธ ์ธ์ด
// ๋ฒ์ญ ๋๋ฝ ์ ์ฒ๋ฆฌ
saveMissing: true, // ๋๋ฝ๋ ํค ์ ์ฅ
missingKeyHandler: (lngs, ns, key, fallbackValue) => {
// ๊ฐ๋ฐ ํ๊ฒฝ์์ ๋ก๊น
if (process.env.NODE_ENV === 'development') {
console.warn(`Missing translation: ${key} for ${lngs}`);
}
// ์๋ฒ์ ๋๋ฝ ํค ์ ์ก (์ ํ์ )
reportMissingTranslation(lngs, key);
},
// ํค๋ฅผ ๊ทธ๋๋ก ํ์ํ์ง ์๊ณ ์ฒ๋ฆฌ
parseMissingKeyHandler: (key) => {
// "user.profile.name" -> "Name"
return key.split('.').pop().replace(/_/g, ' ');
}
});
// ๋ฒ์ญ ์ํ ํ์
function TranslationStatus({ translationKey }) {
const { t, i18n } = useTranslation();
const hasTranslation = i18n.exists(translationKey);
return (
<div>
{t(translationKey)}
{!hasTranslation && (
<span className="translation-missing-badge">
๐ ๋ฒ์ญ ์ค๋น์ค
</span>
)}
</div>
);
}
๐ ์ฑ๋ฅ ์ต์ ํ ์ ๋ต
1. ๋ฒ์ญ ํ์ผ ๋ถํ ๋ก๋ฉ
๋ชจ๋ ๋ฒ์ญ์ ํ ๋ฒ์ ๋ก๋ํ๋ฉด ์ด๊ธฐ ๋ก๋ฉ์ด ๋๋ ค์ ธ. ํ์ํ ๊ฒ๋ง ๋ก๋ํ๋ ๊ฒ ํต์ฌ์ด์ผ. โก
// ๋ค์์คํ์ด์ค๋ณ ๋ถํ
const resources = {
ko: {
common: () => import('./locales/ko/common.json'),
home: () => import('./locales/ko/home.json'),
product: () => import('./locales/ko/product.json')
}
};
// React์์ ๋์ ๋ก๋ฉ
function ProductPage() {
const { t, ready } = useTranslation('product', {
useSuspense: false
});
if (!ready) return <LoadingSpinner />;
return <div>{t('title')}</div>;
}
// Next.js์์ ํ์ด์ง๋ณ ๋ก๋ฉ
export async function getStaticProps({ locale }) {
return {
props: {
...(await serverSideTranslations(locale, [
'common',
'product' // ์ด ํ์ด์ง์ ํ์ํ ๋ค์์คํ์ด์ค๋ง
]))
}
};
}
2. ๋ฒ์ญ ์บ์ฑ ์ ๋ต
๋ฒ์ญ ํ์ผ์ ํจ๊ณผ์ ์ผ๋ก ์บ์ฑํ๋ฉด ์ฌ๋ฐฉ๋ฌธ ์ ๋ก๋ฉ ์๋๊ฐ ์์ฒญ ๋นจ๋ผ์ ธ. ๐พ
// Service Worker๋ก ๋ฒ์ญ ํ์ผ ์บ์ฑ
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open('i18n-v1').then((cache) => {
return cache.addAll([
'/locales/ko/common.json',
'/locales/en/common.json'
]);
})
);
});
// HTTP ์บ์ ํค๋ ์ค์ (์๋ฒ)
app.get('/locales/:lang/:namespace.json', (req, res) => {
res.set({
'Cache-Control': 'public, max-age=31536000', // 1๋
'ETag': generateETag(translationFile)
});
res.json(translations);
});
// ๋ฒ์ ๊ด๋ฆฌ๋ก ์บ์ ๋ฌดํจํ
const translationUrl = `/locales/ko/common.json?v=${VERSION}`;
// IndexedDB์ ๋ฒ์ญ ์ ์ฅ
async function cacheTranslations(locale, namespace, data) {
const db = await openDB('i18n-cache', 1);
await db.put('translations', {
key: `${locale}-${namespace}`,
data,
timestamp: Date.now()
});
}
3. ๋ฒ๋ค ํฌ๊ธฐ ์ต์ ํ
ํนํ CJK ์ธ์ด๋ ํฐํธ์ ๋ฒ์ญ ํ์ผ์ด ์ปค์ ์ต์ ํ๊ฐ ์ค์ํด. ๐ฆ
- โ Tree Shaking: ์ฌ์ฉํ์ง ์๋ ๋ฒ์ญ ์ ๊ฑฐ
- โ ์์ถ: Gzip/Brotli ์์ถ ์ ์ฉ
- โ ํฐํธ ์๋ธ์ : ํ์ํ ๊ธ์๋ง ํฌํจ
- โ CDN ํ์ฉ: ์ง์ญ๋ณ ์ฃ์ง ์๋ฒ์์ ์ ๊ณต
- โ ์ง์ฐ ๋ก๋ฉ: ์ด๊ธฐ ํ๋ฉด์ ๋ถํ์ํ ๋ฒ์ญ ์ง์ฐ
// Webpack ์ค์ ์ผ๋ก ๋ฒ์ญ ํ์ผ ์ต์ ํ
module.exports = {
optimization: {
splitChunks: {
cacheGroups: {
i18n: {
test: /[\\/]locales[\\/]/,
name: 'i18n',
chunks: 'all'
}
}
}
}
};
// ํฐํธ ์๋ธ์
์์ฑ (Python ์์)
from fontTools import subset
options = subset.Options()
options.text = "๊ฐ๋๋ค๋ผ๋ง๋ฐ์ฌ..." # ํ์ํ ๊ธ์๋ง
subsetter = subset.Subsetter(options)
font = TTFont('NotoSansKR-Regular.ttf')
subsetter.subset(font)
font.save('NotoSansKR-Subset.woff2')
๐ ๏ธ ๊ฐ๋ฐ ์ํฌํ๋ก์ฐ ๋ฐ ๋๊ตฌ
1. ๋ฒ์ญ ๊ด๋ฆฌ ํ๋ซํผ
๋ฒ์ญ๊ฐ์ ๊ฐ๋ฐ์๊ฐ ํ์ ํ๋ ค๋ฉด ์ ๋ฌธ ๋๊ตฌ๊ฐ ํ์ํด. ์๋์ผ๋ก JSON ํ์ผ ์ฃผ๊ณ ๋ฐ์ผ๋ฉด ์ค์๋ ๋ง๊ณ ๋นํจ์จ์ ์ด๊ฑฐ๋ . ๐ค
Lokalise: ๊ฐ๋ฐ์ ์นํ์ , API ๊ฐ๋ ฅ
Phrase: ์ํฐํ๋ผ์ด์ฆ๊ธ, ๊ณ ๊ธ ๊ธฐ๋ฅ ๋ง์
POEditor: ๊ฐ์ฑ๋น ์ข์, ์ค์๊ท๋ชจ ํ๋ก์ ํธ ์ ํฉ
Weblate: ์คํ์์ค, ์์ฒด ํธ์คํ ๊ฐ๋ฅ
// Crowdin CLI ์ฌ์ฉ ์์
# ์ค์ ํ์ผ (crowdin.yml)
project_id: "123456"
api_token: "your-token"
base_path: "."
files:
- source: /src/locales/en/**/*.json
translation: /src/locales/%two_letters_code%/**/%original_file_name%
# ์์ค ํ์ผ ์
๋ก๋
crowdin upload sources
# ๋ฒ์ญ ๋ค์ด๋ก๋
crowdin download
# GitHub Actions ์๋ํ
name: Crowdin Sync
on:
schedule:
- cron: '0 0 * * *' # ๋งค์ผ ์์
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: crowdin/github-action@v1
with:
upload_sources: true
download_translations: true
2. ๋ฒ์ญ ํค ๊ด๋ฆฌ ์ ๋ต
๋ฒ์ญ ํค๋ฅผ ์ด๋ป๊ฒ ๊ตฌ์กฐํํ๋๋๊ฐ ์ ์ง๋ณด์์ฑ์ ๊ฒฐ์ ํด. ์ผ๊ด๋ ๋ค์ด๋ฐ ๊ท์น์ด ์ค์ํด. ๐๏ธ
// ์ข์ ํค ๊ตฌ์กฐ ์์
{
"common": {
"button": {
"save": "์ ์ฅ",
"cancel": "์ทจ์",
"delete": "์ญ์ ",
"confirm": "ํ์ธ"
},
"message": {
"success": "์ฑ๊ณต์ ์ผ๋ก ์ฒ๋ฆฌ๋์์ต๋๋ค",
"error": "์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค"
}
},
"user": {
"profile": {
"title": "ํ๋กํ",
"edit": "ํ๋กํ ์์ ",
"field": {
"name": "์ด๋ฆ",
"email": "์ด๋ฉ์ผ",
"phone": "์ ํ๋ฒํธ"
}
}
}
}
// ๋ค์ด๋ฐ ๊ท์น
// [๋ชจ๋].[๊ธฐ๋ฅ].[์์ํ์
].[๊ตฌ์ฒด์ ์ค๋ช
]
// ์: user.profile.button.save
// product.list.message.empty
// checkout.payment.label.cardNumber
// ๋์ ์์ (ํผํด์ผ ํ ๊ฒ๋ค)
{
"text1": "์ ์ฅ", // ์๋ฏธ ์๋ ์ด๋ฆ
"saveButton": "์ ์ฅ", // ์นด๋ฉ์ผ์ด์ค ํผ์ฉ
"user_name": "์ด๋ฆ", // ์ค๋ค์ดํฌ์ผ์ด์ค ํผ์ฉ
"ํ๋กํ": "Profile" // ํ๊ธ ํค ์ฌ์ฉ
}
3. ๋ฒ์ญ ํ์ง ๊ฒ์ฆ
๋ฒ์ญ์ด ์ ๋๋ก ๋์๋์ง, ๋น ์ง ๊ฑด ์๋์ง ์๋์ผ๋ก ์ฒดํฌํ๋ ๊ฒ ์ข์. โ
// ๋ฒ์ญ ์์ฑ๋ ์ฒดํฌ ์คํฌ๋ฆฝํธ
const fs = require('fs');
const path = require('path');
function checkTranslationCompleteness(baseLocale, targetLocale) {
const basePath = `./locales/${baseLocale}`;
const targetPath = `./locales/${targetLocale}`;
const baseKeys = getAllKeys(basePath);
const targetKeys = getAllKeys(targetPath);
const missing = baseKeys.filter(key => !targetKeys.includes(key));
const extra = targetKeys.filter(key => !baseKeys.includes(key));
console.log(`Missing in ${targetLocale}:`, missing);
console.log(`Extra in ${targetLocale}:`, extra);
const completeness = ((targetKeys.length / baseKeys.length) * 100).toFixed(2);
console.log(`Completeness: ${completeness}%`);
return missing.length === 0;
}
// ๋ณ์ ๊ฒ์ฆ
function validateInterpolation(translations) {
const errors = [];
Object.entries(translations).forEach(([key, value]) => {
// {{variable}} ํ์ ์ฐพ๊ธฐ
const variables = value.match(/\{\{(\w+)\}\}/g) || [];
// ์ค๋ณต ๋ณ์ ์ฒดํฌ
const uniqueVars = new Set(variables);
if (variables.length !== uniqueVars.size) {
errors.push(`Duplicate variable in ${key}: ${value}`);
}
// ๋ซํ์ง ์์ ๊ดํธ ์ฒดํฌ
const openCount = (value.match(/\{\{/g) || []).length;
const closeCount = (value.match(/\}\}/g) || []).length;
if (openCount !== closeCount) {
errors.push(`Unclosed brackets in ${key}: ${value}`);
}
});
return errors;
}
// Jest ํ
์คํธ
describe('Translation Tests', () => {
test('All locales have same keys', () => {
const isComplete = checkTranslationCompleteness('ko', 'en');
expect(isComplete).toBe(true);
});
test('No interpolation errors', () => {
const translations = require('./locales/ko/common.json');
const errors = validateInterpolation(translations);
expect(errors).toHaveLength(0);
});
});
4. ๊ฐ๋ฐ ํ๊ฒฝ ์ค์
๊ฐ๋ฐํ ๋ ๋ฒ์ญ ํค๊ฐ ๋ณด์ด๊ฒ ํ๊ฑฐ๋, ๋ฒ์ญ์ด ์๋ ๋ถ๋ถ์ ๊ฐ์กฐํ๋ฉด ๋๋ฒ๊น ์ด ์ฌ์์ ธ. ๐
// ๊ฐ๋ฐ ๋ชจ๋ ์ค์
i18n.init({
debug: process.env.NODE_ENV === 'development',
// ๊ฐ๋ฐ ๋ชจ๋์์ ํค ํ์
returnNull: false,
returnEmptyString: false,
// ๋ฒ์ญ ํค๋ฅผ ๊ทธ๋๋ก ํ์
...(process.env.SHOW_KEYS && {
lng: 'cimode' // ํน์ ๋ชจ๋
})
});
// ๋ฒ์ญ ๋๋ฝ ํ์ด๋ผ์ดํธ ์ปดํฌ๋ํธ
function DevTranslation({ children, translationKey }) {
const { i18n } = useTranslation();
const exists = i18n.exists(translationKey);
if (process.env.NODE_ENV === 'production') {
return children;
}
return (
<span
style={{
backgroundColor: exists ? 'transparent' : 'yellow',
border: exists ? 'none' : '2px dashed red'
}}
title={exists ? '' : `Missing: ${translationKey}`}
>
{children}
</span>
);
}
// ์ฌ์ฉ
<DevTranslation translationKey="user.profile.title">
{t('user.profile.title')}
</DevTranslation>
๐ SEO์ ๊ตญ์ ํ
1. hreflang ํ๊ทธ ์ค์
๊ฒ์ ์์ง์๊ฒ ๊ฐ ์ธ์ด ๋ฒ์ ์ ํ์ด์ง๊ฐ ์ด๋ ์๋์ง ์๋ ค์ค์ผ ํด. ์ ๊ทธ๋ฌ๋ฉด ์ค๋ณต ์ฝํ ์ธ ๋ก ์ธ์๋ ์ ์์ด. ๐
<head>
<!-- ํ์ฌ ํ์ด์ง ์ธ์ด -->
<html lang="ko">
<!-- ๋์ฒด ์ธ์ด ๋ฒ์ -->
<link rel="alternate" hreflang="ko" href="https://example.com/ko/page" />
<link rel="alternate" hreflang="en" href="https://example.com/en/page" />
<link rel="alternate" hreflang="ja" href="https://example.com/ja/page" />
<!-- ๊ธฐ๋ณธ ์ธ์ด (์ธ์ด ๊ฐ์ง ์คํจ ์) -->
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
<!-- ์ง์ญ๋ณ ๋ณํ -->
<link rel="alternate" hreflang="en-US" href="https://example.com/en-us/page" />
<link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/page" />
</head>
// React Helmet์ผ๋ก ๋์ ์์ฑ
import { Helmet } from 'react-helmet';
function Page() {
const alternateLinks = languages.map(lang => ({
rel: 'alternate',
hreflang: lang.code,
href: `${baseUrl}/${lang.code}${pathname}`
}));
return (
<Helmet>
<html lang={currentLanguage} />
{alternateLinks.map(link => (
<link key={link.hreflang} {...link} />
))}
</Helmet>
);
}
2. URL ๊ตฌ์กฐ ์ ๋ต
๋ค๊ตญ์ด ์ฌ์ดํธ์ URL์ ์ด๋ป๊ฒ ๊ตฌ์ฑํ ์ง๋ SEO์ ํฐ ์ํฅ์ ๋ฏธ์ณ. ๊ฐ ๋ฐฉ์๋ง๋ค ์ฅ๋จ์ ์ด ์์ด. ๐
โข ์ฅ์ : ๊ด๋ฆฌ ์ฌ์, ๋จ์ผ ๋๋ฉ์ธ
โข ๋จ์ : ์ง์ญ๋ณ ์๋ฒ ์ต์ ํ ์ด๋ ค์
2. ์๋ธ๋๋ฉ์ธ: ko.example.com, en.example.com
โข ์ฅ์ : ์ง์ญ๋ณ ์๋ฒ ๋ถ๋ฆฌ ๊ฐ๋ฅ
โข ๋จ์ : SEO ๊ถํ ๋ถ์ฐ
3. ๋ณ๋ ๋๋ฉ์ธ: example.kr, example.com
โข ์ฅ์ : ์ง์ญ ํ๊ฒํ ์ต๊ณ
โข ๋จ์ : ๋น์ฉ, ๊ด๋ฆฌ ๋ณต์ก
4. ํ๋ผ๋ฏธํฐ: example.com?lang=ko
โข ์ฅ์ : ๊ตฌํ ๊ฐ๋จ
โข ๋จ์ : SEO์ ๋ถ๋ฆฌ, ๊ถ์ฅํ์ง ์์
// Next.js ์๋ธ๋๋ ํ ๋ฆฌ ๋ฐฉ์
// next.config.js
module.exports = {
i18n: {
locales: ['ko', 'en', 'ja'],
defaultLocale: 'ko',
localeDetection: true
}
};
// ์๋ ๋ผ์ฐํ
// /ko/about -> pages/about.js (ํ๊ตญ์ด)
// /en/about -> pages/about.js (์์ด)
// Express.js ์๋ธ๋๋ฉ์ธ ๋ฐฉ์
app.use((req, res, next) => {
const subdomain = req.subdomains[0];
const supportedLocales = ['ko', 'en', 'ja'];
if (supportedLocales.includes(subdomain)) {
req.locale = subdomain;
} else {
req.locale = 'ko';
}
next();
});
// ์ธ์ด๋ณ ๋ฆฌ๋ค์ด๋ ํธ
app.get('/', (req, res) => {
const userLang = detectLanguage(req);
res.redirect(`/${userLang}/`);
});
3. ๊ตฌ์กฐํ๋ ๋ฐ์ดํฐ (Schema.org)
๊ฒ์ ์์ง์ด ์ฝํ ์ธ ๋ฅผ ๋ ์ ์ดํดํ๋๋ก ๊ตฌ์กฐํ๋ ๋ฐ์ดํฐ๋ ๋ค๊ตญ์ด๋ก ์ ๊ณตํด์ผ ํด. ๐
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebPage",
"name": "ํํ์ด์ง",
"description": "์น ๊ฐ๋ฐ ๊ฐ์ด๋",
"inLanguage": "ko-KR",
"url": "https://example.com/ko/",
"potentialAction": {
"@type": "ReadAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "https://example.com/ko/",
"inLanguage": "ko-KR"
}
}
}
</script>
// React์์ ๋์ ์์ฑ
function generateStructuredData(locale, content) {
return {
"@context": "https://schema.org",
"@type": "Article",
"headline": content.title[locale],
"description": content.description[locale],
"inLanguage": locale,
"author": {
"@type": "Person",
"name": content.author
}
};
}
๐ ์ค์ ์์ : ์์ ํ ๋ค๊ตญ์ด ์ฌ์ดํธ ๊ตฌ์ถ
์ด์ ๋ฐฐ์ด ๊ฑธ ๋ค ํฉ์ณ์ ์ค์ ๋ก ๋์ํ๋ ๋ค๊ตญ์ด ์ฌ์ดํธ๋ฅผ ๋ง๋ค์ด๋ณด์. ์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ์์ ๊ธ๋ก๋ฒ ์๋น์ค๋ฅผ ์ ๊ณตํ๋ค๊ณ ๊ฐ์ ํด๋ณผ๊ฒ. ๐
1. ํ๋ก์ ํธ ์ด๊ธฐ ์ค์
// package.json
{
"dependencies": {
"react": "^18.2.0",
"react-i18next": "^13.0.0",
"i18next": "^23.0.0",
"i18next-browser-languagedetector": "^7.0.0",
"i18next-http-backend": "^2.0.0"
}
}
// ํ๋ก์ ํธ ๊ตฌ์กฐ
src/
โโโ i18n/
โ โโโ config.js
โ โโโ locales/
โ โโโ ko/
โ โ โโโ common.json
โ โ โโโ talent.json
โ โ โโโ marketplace.json
โ โโโ en/
โ โโโ ja/
โโโ components/
โ โโโ LanguageSwitcher.jsx
โ โโโ TalentCard.jsx
โ โโโ LocalizedPrice.jsx
โโโ hooks/
โ โโโ useLocalization.js
โโโ utils/
โโโ formatters.js
2. i18n ์ค์
// src/i18n/config.js
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import Backend from 'i18next-http-backend';
i18n
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng: 'ko',
supportedLngs: ['ko', 'en', 'ja'],
detection: {
order: ['querystring', 'localStorage', 'navigator'],
caches: ['localStorage'],
lookupQuerystring: 'lang'
},
backend: {
loadPath: '/locales/{{lng}}/{{ns}}.json'
},
interpolation: {
escapeValue: false,
format: (value, format, lng) => {
if (format === 'number') {
return new Intl.NumberFormat(lng).format(value);
}
if (format === 'currency') {
return new Intl.NumberFormat(lng, {
style: 'currency',
currency: getCurrency(lng)
}).format(value);
}
return value;
}
},
react: {
useSuspense: true
}
});
function getCurrency(locale) {
const currencyMap = {
'ko': 'KRW',
'en': 'USD',
'ja': 'JPY'
};
return currencyMap[locale] || 'USD';
}
export default i18n;
3. ๋ฒ์ญ ํ์ผ ์์ฑ
// locales/ko/talent.json
{
"marketplace": {
"title": "์ฌ๋ฅ ๋ง์ผํ๋ ์ด์ค",
"search": {
"placeholder": "์ด๋ค ์ฌ๋ฅ์ ์ฐพ์ผ์๋์?",
"button": "๊ฒ์"
},
"category": {
"programming": "ํ๋ก๊ทธ๋๋ฐ",
"design": "๋์์ธ",
"translation": "๋ฒ์ญ",
"consulting": "์ปจ์คํ
"
},
"talent": {
"price": "{{price, currency}}",
"rating": "ํ์ {{rating}}",
"reviews": "{{count}}๊ฐ์ ๋ฆฌ๋ทฐ",
"seller": "ํ๋งค์: {{name}}"
}
}
}
// locales/en/talent.json
{
"marketplace": {
"title": "Talent Marketplace",
"search": {
"placeholder": "What talent are you looking for?",
"button": "Search"
},
"category": {
"programming": "Programming",
"design": "Design",
"translation": "Translation",
"consulting": "Consulting"
},
"talent": {
"price": "{{price, currency}}",
"rating": "Rating {{rating}}",
"reviews": "{{count}} reviews",
"reviews_plural": "{{count}} reviews",
"seller": "Seller: {{name}}"
}
}
}
4. ์ปดํฌ๋ํธ ๊ตฌํ
// components/LanguageSwitcher.jsx
import { useTranslation } from 'react-i18next';
const languages = [
{ code: 'ko', name: 'ํ๊ตญ์ด', flag: '๐ฐ๐ท' },
{ code: 'en', name: 'English', flag: '๐บ๐ธ' },
{ code: 'ja', name: 'ๆฅๆฌ่ช', flag: '๐ฏ๐ต' }
];
export function LanguageSwitcher() {
const { i18n } = useTranslation();
const changeLanguage = (lng) => {
i18n.changeLanguage(lng);
document.documentElement.lang = lng;
// ์ธ์ด ๋ณ๊ฒฝ ์ด๋ฒคํธ ๋ฐ์
window.dispatchEvent(new CustomEvent('languageChanged', {
detail: { language: lng }
}));
};
return (
<div className="language-switcher">
{languages.map(lang => (
<button
key={lang.code}
onClick={() => changeLanguage(lang.code)}
className={i18n.language === lang.code ? 'active' : ''}
>
<span>{lang.flag}</span>
<span>{lang.name}</span>
</button>
))}
</div>
);
}
// components/TalentCard.jsx
import { useTranslation } from 'react-i18next';
export function TalentCard({ talent }) {
const { t } = useTranslation('talent');
return (
<div className="talent-card">
<img src={talent.image} alt={talent.title} />
<h3>{talent.title}</h3>
<p className="price">
{t('marketplace.talent.price', { price: talent.price })}
</p>
<div className="rating">
{t('marketplace.talent.rating', { rating: talent.rating })}
</div>
<div className="reviews">
{t('marketplace.talent.reviews', { count: talent.reviewCount })}
</div>
<p className="seller">
{t('marketplace.talent.seller', { name: talent.sellerName })}
</p>
</div>
);
}
// components/LocalizedPrice.jsx
export function LocalizedPrice({ amount, currency }) {
const { i18n } = useTranslation();
const formatted = new Intl.NumberFormat(i18n.language, {
style: 'currency',
currency: currency || getCurrency(i18n.language)
}).format(amount);
return <span className="price">{formatted}</span>;
}
5. ์ปค์คํ ํ ํ์ฉ
// hooks/useLocalization.js
import { useTranslation } from 'react-i18next';
import { useMemo } from 'react';
export function useLocalization() {
const { t, i18n } = useTranslation();
const formatDate = useMemo(() => {
return (date, options = {}) => {
return new Intl.DateTimeFormat(i18n.language, {
year: 'numeric',
month: 'long',
day: 'numeric',
...options
}).format(new Date(date));
};
}, [i18n.language]);
const formatNumber = useMemo(() => {
return (number, options = {}) => {
return new Intl.NumberFormat(i18n.language, options).format(number);
};
}, [i18n.language]);
const formatCurrency = useMemo(() => {
return (amount, currency) => {
return new Intl.NumberFormat(i18n.language, {
style: 'currency',
currency: currency || getCurrency(i18n.language)
}).format(amount);
};
}, [i18n.language]);
const formatRelativeTime = useMemo(() => {
return (date) => {
const rtf = new Intl.RelativeTimeFormat(i18n.language, {
numeric: 'auto'
});
const diff = new Date(date) - new Date();
const days = Math.round(diff / (1000 * 60 * 60 * 24));
if (Math.abs(days) < 1) {
const hours = Math.round(diff / (1000 * 60 * 60));
return rtf.format(hours, 'hour');
}
return rtf.format(days, 'day');
};
}, [i18n.language]);
return {
t,
i18n,
formatDate,
formatNumber,
formatCurrency,
formatRelativeTime,
currentLanguage: i18n.language,
isRTL: ['ar', 'he', 'fa'].includes(i18n.language)
};
}
// ์ฌ์ฉ ์์
function TalentList() {
const { t, formatCurrency, formatRelativeTime } = useLocalization();
return (
<div>
<h2>{t('marketplace.title')}</h2>
{talents.map(talent => (
<div key={talent.id}>
<h3>{talent.title}</h3>
<p>{formatCurrency(talent.price)}</p>
<p>{formatRelativeTime(talent.createdAt)}</p>
</div>
))}
</div>
);
}
โ ๏ธ ํํ ์ค์์ ํด๊ฒฐ ๋ฐฉ๋ฒ
1. ํ๋์ฝ๋ฉ๋ ํ ์คํธ
<button>์ ์ฅ</button>alert('์ ์ฅ๋์์ต๋๋ค');โ ์ข์ ์์
<button>{t('common.button.save')}</button>alert(t('common.message.saved'));
์ฝ๋ ๋ฆฌ๋ทฐํ ๋ ํ๋์ฝ๋ฉ๋ ํ ์คํธ๋ฅผ ์ฐพ๋ ์ ๊ท์์ ์ฌ์ฉํ๋ฉด ๋์์ด ๋ผ:
// ESLint ๊ท์น์ผ๋ก ํ๋์ฝ๋ฉ ๋ฐฉ์ง
// .eslintrc.js
module.exports = {
rules: {
'no-literal-string': ['error', {
exclude: ['className', 'style', 'type']
}]
}
};
// ๋๋ ์ปค์คํ
๋ฆฐํธ ๊ท์น
function checkHardcodedStrings(code) {
const koreanRegex = /[๊ฐ-ํฃ]+/g;
const matches = code.match(koreanRegex);
if (matches) {
console.warn('Hardcoded Korean strings found:', matches);
}
}
2. ๋ ์ง/์ซ์ ํฌ๋งท ๋ฌด์
const date = '2024-01-15';const price = '$' + amount;โ ์ข์ ์์
const date = formatDate(new Date('2024-01-15'));const price = formatCurrency(amount, 'USD');
3. ๋ฒ์ญ ํค ์ค๋ณต
๊ฐ์ ํค๋ฅผ ์ฌ๋ฌ ํ์ผ์ ์ ์ํ๋ฉด ๋์ค์ ์ด๋ค ๊ฒ ์ฌ์ฉ๋๋์ง ํท๊ฐ๋ ค. ๋ค์์คํ์ด์ค๋ฅผ ๋ช ํํ ๊ตฌ๋ถํด์ผ ํด. ๐
// ์ค๋ณต ์ฒดํฌ ์คํฌ๋ฆฝํธ
function findDuplicateKeys(localesPath) {
const allKeys = {};
const duplicates = [];
// ๋ชจ๋ JSON ํ์ผ ์ฝ๊ธฐ
const files = glob.sync(`${localesPath}/**/*.json`);
files.forEach(file => {
const content = JSON.parse(fs.readFileSync(file, 'utf8'));
const keys = flattenObject(content);
Object.keys(keys).forEach(key => {
if (allKeys[key]) {
duplicates.push({
key,
files: [allKeys[key], file]
});
} else {
allKeys[key] = file;
}
});
});
return duplicates;
}
4. ๋ฌธ๋งฅ ๋ฌด์ํ ๋ฒ์ญ
"Close"๋ฅผ ๋ฌด์กฐ๊ฑด "๋ซ๊ธฐ"๋ก ๋ฒ์ญํ๋ฉด "๊ฐ๊น์ด"์ด๋ผ๋ ์๋ฏธ์ผ ๋ ์ด์ํด์ ธ. ์ปจํ ์คํธ๋ฅผ ๋ช ์ํด์ผ ํด.
// ๋์ ์์
{
"close": "๋ซ๊ธฐ"
}
// ์ข์ ์์
{
"button": {
"close": "๋ซ๊ธฐ"
},
"distance": {
"close": "๊ฐ๊น์ด"
},
"relationship": {
"close": "์น๋ฐํ"
}
}
// ๋๋ ์ปจํ
์คํธ ์ฌ์ฉ
{
"close_button": "๋ซ๊ธฐ",
"close_distance": "๊ฐ๊น์ด"
}
5. ์ฑ๋ฅ ์ต์ ํ ๋ฌด์
๋ชจ๋ ๋ฒ์ญ์ ํ ๋ฒ์ ๋ก๋ํ๋ฉด ์ด๊ธฐ ๋ก๋ฉ์ด ๋๋ ค์ ธ. ํ์ํ ๊ฒ๋ง ๋ก๋ํ๋ ๊ฒ ์ค์ํด. โก
- โ ์ฝ๋ ์คํ๋ฆฌํ : ํ์ด์ง๋ณ๋ก ๋ฒ์ญ ํ์ผ ๋ถ๋ฆฌ
- โ ์ง์ฐ ๋ก๋ฉ: ์ด๊ธฐ ํ๋ฉด์ ๋ถํ์ํ ๋ฒ์ญ ์ง์ฐ
- โ ์บ์ฑ: ๋ฒ์ญ ํ์ผ ์ ๊ทน์ ์ผ๋ก ์บ์ฑ
- โ CDN: ์ ์ ๋ฒ์ญ ํ์ผ์ CDN์์ ์ ๊ณต
- โ ์์ถ: JSON ํ์ผ Gzip/Brotli ์์ถ
๐ฏ ๋ง๋ฌด๋ฆฌํ๋ฉฐ
์, ์ฌ๊ธฐ๊น์ง ์ฝ์๋ค๋ฉด ์ ๋ง ๋๋จํด! ๐ ์น ๊ตญ์ ํ๋ ์ฒ์์ ๋ณต์กํด ๋ณด์ด์ง๋ง, ์ฒด๊ณ์ ์ผ๋ก ์ ๊ทผํ๋ฉด ์ถฉ๋ถํ ๊ตฌํํ ์ ์์ด.
ํต์ฌ์ ์ฒ์๋ถํฐ ๊ตญ์ ํ๋ฅผ ์ผ๋์ ๋๊ณ ์ค๊ณํ๋ ๊ฑฐ์ผ. ๋์ค์ ์ถ๊ฐํ๋ ค๋ฉด ์ ์ฒด ์ฝ๋๋ฅผ ๋ค์ ๋ง๋ค์ด์ผ ํ ์๋ ์๊ฑฐ๋ . ํนํ ์ฌ๋ฅ๋ท์ฒ๋ผ ๊ธ๋ก๋ฒ ์์ฅ์ ๋ชฉํ๋ก ํ๋ ํ๋ซํผ์ด๋ผ๋ฉด ๋์ฑ ์ค์ํด.
2. ๋ฒ์ญ ๊ด๋ฆฌ: ์ ๋ฌธ ๋๊ตฌ ํ์ฉ์ผ๋ก ํจ์จ์ฑ ํฅ์
3. UI/UX: ์ธ์ด๋ณ ํน์ฑ ๊ณ ๋ คํ ๋์์ธ
4. ์ฑ๋ฅ: ๋ถํ ๋ก๋ฉ๊ณผ ์บ์ฑ์ผ๋ก ์ต์ ํ
5. SEO: hreflang๊ณผ ๊ตฌ์กฐํ๋ ๋ฐ์ดํฐ ํ์ฉ
6. ํ ์คํธ: ์๋ํ๋ ๊ฒ์ฆ์ผ๋ก ํ์ง ๋ณด์ฅ
๊ตญ์ ํ๋ ๋จ์ํ ๊ธฐ์ ์ ์ธ ๋ฌธ์ ๊ฐ ์๋๋ผ ์ฌ์ฉ์ ๊ฒฝํ์ ๋ฌธ์ ์ผ. ์ ์ธ๊ณ ์ฌ์ฉ์๋ค์ด ์์ ์ ์ธ์ด๋ก ํธํ๊ฒ ์๋น์ค๋ฅผ ์ด์ฉํ ์ ์๊ฒ ๋ง๋๋ ๊ฒ, ๊ทธ๊ฒ ์ง์ ํ ๊ธ๋ก๋ฒ ์๋น์ค์ง. ๐
์ฒ์์ ์ด๋ ค์ ๋ณด์ฌ๋ ํ๋์ฉ ์ ์ฉํ๋ค ๋ณด๋ฉด ์ด๋์ ์์ฐ์ค๋ฝ๊ฒ ๋ค๊ตญ์ด ์ง์์ด ๋์ด ์์ ๊ฑฐ์ผ. ํ์ดํ ! ๐ช
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.