Ver3.0 ๐ JavaScript ๊ตญ์ ํ์ Intl ๊ฐ์ฒด๋ก ์ ์ธ๊ณ์ ์ํตํ๊ธฐ

๐ JavaScript ๊ตญ์ ํ์ Intl ๊ฐ์ฒด๋ก ์ ์ธ๊ณ์ ์ํตํ๊ธฐ
๋ค๊ตญ์ด ์ง์, ์ด์ ์ด๋ ต์ง ์์์! ์น๊ตฌ์ฒ๋ผ ์ฝ๊ฒ ์๋ ค๋๋ฆด๊ฒ์ ๐
๐ฏ ์ ๊ตญ์ ํ๊ฐ ์ค์ํ ๊น์?
์ฌ๋ฌ๋ถ, ํน์ ํด์ธ ์ฌ์ดํธ ๋ค์ด๊ฐ๋ค๊ฐ ๋ ์ง๊ฐ ์ด์ํ๊ฒ ํ์๋๊ฑฐ๋, ๊ฐ๊ฒฉ์ด ๋ฌ๋ฌ๋ก๋ง ๋์์ ๋นํฉํ ์ ์์ผ์ ๊ฐ์? ๐ค์์ฆ ์น ์๋น์ค๋ ๊ตญ๊ฒฝ์ด ์์์์. ํ๊ตญ์์ ๋ง๋ ์๋น์ค๊ฐ ๋ฏธ๊ตญ, ์ผ๋ณธ, ์ ๋ฝ์์๋ ์ฌ์ฉ๋๋ ๊ฒ ๋น์ฐํ ์๋์์. ๊ทธ๋ฐ๋ฐ ๋ฌธ์ ๋ ๊ฐ ๋๋ผ๋ง๋ค ๋ ์ง ํ๊ธฐ๋ฒ๋ ๋ค๋ฅด๊ณ , ์ซ์ ํ๊ธฐ๋ฒ๋ ๋ค๋ฅด๊ณ , ํตํ ๋จ์๋ ๋ค๋ฅด๋ค๋ ๊ฑฐ์ฃ !
์๋ฅผ ๋ค์ด๋ณผ๊น์?
- ํ๊ตญ: 2024๋ 1์ 15์ผ, 1,234,567์
- ๋ฏธ๊ตญ: January 15, 2024, $1,234,567.00
- ๋ ์ผ: 15. Januar 2024, 1.234.567,00 โฌ
๊ฐ์ ์ ๋ณด์ธ๋ฐ ํํ ๋ฐฉ์์ด ์์ ํ ๋ค๋ฅด์ฃ ? ์ด๊ฑธ ์ผ์ผ์ด ์ฝ๋ฉ์ผ๋ก ์ฒ๋ฆฌํ๋ ค๋ฉด... ์์๋ง ํด๋ ๋จธ๋ฆฌ๊ฐ ์ํ์ ๐ต
๋ฐ๋ก ์ด๋ด ๋ ํ์ํ ๊ฒ ๊ตญ์ ํ(Internationalization, i18n)์์! ๊ทธ๋ฆฌ๊ณ JavaScript๋ ์ด๋ฅผ ์ํด ๊ฐ๋ ฅํ ๋ฌด๊ธฐ์ธ Intl ๊ฐ์ฒด๋ฅผ ์ ๊ณตํฉ๋๋ค.
๐ Intl ๊ฐ์ฒด๋ ๋ฌด์์ธ๊ฐ์?
Intl์ ECMAScript Internationalization API์ ๋ค์์คํ์ด์ค์์. ์ฝ๊ฒ ๋งํ๋ฉด, JavaScript๊ฐ ๊ธฐ๋ณธ์ผ๋ก ์ ๊ณตํ๋ ๊ตญ์ ํ ๋๊ตฌ ์ธํธ๋ผ๊ณ ๋ณด์๋ฉด ๋ผ์! ๐ ๏ธIntl ๊ฐ์ฒด๋ ์ฌ๋ฌ ๊ฐ์ง ์์ฑ์(Constructor)๋ฅผ ์ ๊ณตํ๋๋ฐ, ๊ฐ๊ฐ ํน์ ๋ชฉ์ ์ ๋ง๊ฒ ์ค๊ณ๋์ด ์์ด์:
2๏ธโฃ Intl.NumberFormat - ์ซ์ ํ์ํ
3๏ธโฃ Intl.Collator - ๋ฌธ์์ด ๋น๊ต ๋ฐ ์ ๋ ฌ
4๏ธโฃ Intl.PluralRules - ๋ณต์ํ ๊ท์น ์ฒ๋ฆฌ
5๏ธโฃ Intl.RelativeTimeFormat - ์๋์ ์๊ฐ ํํ
6๏ธโฃ Intl.ListFormat - ๋ชฉ๋ก ํ์ํ
7๏ธโฃ Intl.DisplayNames - ์ธ์ด, ์ง์ญ, ํตํ ์ด๋ฆ ํ์
8๏ธโฃ Intl.Locale - ๋ก์ผ์ผ ์ ๋ณด ๊ด๋ฆฌ
๐ Intl.DateTimeFormat - ๋ ์ง์ ์๊ฐ ๋ง์คํฐํ๊ธฐ
๋ ์ง ํ์์ ๋๋ผ๋ง๋ค ์ ๋ง ์ฒ์ฐจ๋ง๋ณ์ด์์. ๋ฏธ๊ตญ์ ์/์ผ/๋ ์์๊ณ , ํ๊ตญ์ ๋ /์/์ผ ์์์ฃ . ์ด๊ฑธ ์๋์ผ๋ก ์ฒ๋ฆฌํ๋ฉด ๋ฒ๊ทธ ์ฒ๊ตญ์ด ๋ ์ ์์ด์! ๐ฑ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ
// ํ๊ตญ์ด๋ก ๋ ์ง ํ์
const date = new Date('2024-01-15');
const koFormatter = new Intl.DateTimeFormat('ko-KR');
console.log(koFormatter.format(date));
// ์ถ๋ ฅ: 2024. 1. 15.
// ์์ด(๋ฏธ๊ตญ)๋ก ๋ ์ง ํ์
const enFormatter = new Intl.DateTimeFormat('en-US');
console.log(enFormatter.format(date));
// ์ถ๋ ฅ: 1/15/2024
// ๋
์ผ์ด๋ก ๋ ์ง ํ์
const deFormatter = new Intl.DateTimeFormat('de-DE');
console.log(deFormatter.format(date));
// ์ถ๋ ฅ: 15.1.2024
์ต์ ์ผ๋ก ์ธ๋ฐํ๊ฒ ์กฐ์ ํ๊ธฐ
DateTimeFormat์ ๋ค์ํ ์ต์ ์ ์ ๊ณตํด์. ์ํ๋ ๋๋ก ์ปค์คํฐ๋ง์ด์งํ ์ ์๋ต๋๋ค!const date = new Date('2024-01-15T14:30:00');
// ๊ธด ํ์์ผ๋ก ํ์
const longFormatter = new Intl.DateTimeFormat('ko-KR', {
year: 'numeric',
month: 'long',
day: 'numeric',
weekday: 'long'
});
console.log(longFormatter.format(date));
// ์ถ๋ ฅ: 2024๋
1์ 15์ผ ์์์ผ
// ์๊ฐ ํฌํจ
const timeFormatter = new Intl.DateTimeFormat('ko-KR', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false
});
console.log(timeFormatter.format(date));
// ์ถ๋ ฅ: 2024. 01. 15. 14:30:00
// ๋ฏธ๊ตญ ์คํ์ผ (12์๊ฐ์ )
const usTimeFormatter = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
hour12: true
});
console.log(usTimeFormatter.format(date));
// ์ถ๋ ฅ: January 15, 2024 at 2:30 PM
์น ์ ํ๋ฆฌ์ผ์ด์ ์ ๊ฐ๋ฐํ ๋๋ ์ฌ์ฉ์์ ๋ธ๋ผ์ฐ์ ๋ก์ผ์ผ์ ์๋์ผ๋ก ๊ฐ์งํด์ ์ฌ์ฉํ๋ ๊ฒ ์ข์์.
navigator.language๋ฅผ ํ์ฉํ๋ฉด ๋ฉ๋๋ค!const userLocale = navigator.language || 'ko-KR';
const formatter = new Intl.DateTimeFormat(userLocale);
์ฃผ์ ์ต์ ์ ๋ฆฌ
| ์ต์ | ๊ฐ๋ฅํ ๊ฐ | ์ค๋ช |
|---|---|---|
| year | numeric, 2-digit | ์ฐ๋ ํ์ ๋ฐฉ์ |
| month | numeric, 2-digit, long, short, narrow | ์ ํ์ ๋ฐฉ์ |
| day | numeric, 2-digit | ์ผ ํ์ ๋ฐฉ์ |
| weekday | long, short, narrow | ์์ผ ํ์ ๋ฐฉ์ |
| hour | numeric, 2-digit | ์๊ฐ ํ์ ๋ฐฉ์ |
| minute | numeric, 2-digit | ๋ถ ํ์ ๋ฐฉ์ |
| second | numeric, 2-digit | ์ด ํ์ ๋ฐฉ์ |
| hour12 | true, false | 12์๊ฐ์ /24์๊ฐ์ ์ ํ |
| timeZone | IANA ์๊ฐ๋ ์ด๋ฆ | ํ์ํ ์๊ฐ๋ (์: 'Asia/Seoul') |
๐ฐ Intl.NumberFormat - ์ซ์์ ํตํ ๋ค๋ฃจ๊ธฐ
์ซ์ ํ๊ธฐ๋ฒ๋ ๋๋ผ๋ง๋ค ๋ฌ๋ผ์. ์ฒ ๋จ์ ๊ตฌ๋ถ์๊ฐ ์ผํ์ธ ๋๋ผ๋ ์๊ณ , ์ ์ธ ๋๋ผ๋ ์์ฃ . ์์์ ๋ ๋ง์ฐฌ๊ฐ์ง์์! ๐ธ๊ธฐ๋ณธ ์ซ์ ํ์ํ
const number = 1234567.89;
// ํ๊ตญ
const koNumber = new Intl.NumberFormat('ko-KR');
console.log(koNumber.format(number));
// ์ถ๋ ฅ: 1,234,567.89
// ๋
์ผ (์ฒ ๋จ์ ์ , ์์์ ์ผํ)
const deNumber = new Intl.NumberFormat('de-DE');
console.log(deNumber.format(number));
// ์ถ๋ ฅ: 1.234.567,89
// ์ธ๋ (ํน์ดํ ์ฒ ๋จ์ ๊ตฌ๋ถ)
const inNumber = new Intl.NumberFormat('en-IN');
console.log(inNumber.format(number));
// ์ถ๋ ฅ: 12,34,567.89
ํตํ ํ์ํ
์ ์์๊ฑฐ๋ ์ฌ์ดํธ๋ฅผ ๋ง๋ ๋ค๋ฉด ํตํ ํ์๋ ํ์๊ฒ ์ฃ ? Intl.NumberFormat์ด ์๋ฒฝํ๊ฒ ์ง์ํฉ๋๋ค!const price = 1234567.89;
// ํ๊ตญ ์ํ
const krwFormatter = new Intl.NumberFormat('ko-KR', {
style: 'currency',
currency: 'KRW'
});
console.log(krwFormatter.format(price));
// ์ถ๋ ฅ: โฉ1,234,568 (์ํ๋ ์์์ ์์)
// ๋ฏธ๊ตญ ๋ฌ๋ฌ
const usdFormatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
});
console.log(usdFormatter.format(price));
// ์ถ๋ ฅ: $1,234,567.89
// ์ ๋ก (๋
์ผ ์คํ์ผ)
const eurFormatter = new Intl.NumberFormat('de-DE', {
style: 'currency',
currency: 'EUR'
});
console.log(eurFormatter.format(price));
// ์ถ๋ ฅ: 1.234.567,89 โฌ
// ์ผ๋ณธ ์ํ
const jpyFormatter = new Intl.NumberFormat('ja-JP', {
style: 'currency',
currency: 'JPY'
});
console.log(jpyFormatter.format(price));
// ์ถ๋ ฅ: ยฅ1,234,568
ํผ์ผํธ์ ๋จ์ ํ์
// ํผ์ผํธ ํ์
const percentFormatter = new Intl.NumberFormat('ko-KR', {
style: 'percent',
minimumFractionDigits: 2,
maximumFractionDigits: 2
});
console.log(percentFormatter.format(0.1234));
// ์ถ๋ ฅ: 12.34%
// ๋จ์ ํ์ (ํฌ๋ก๋ฏธํฐ)
const unitFormatter = new Intl.NumberFormat('ko-KR', {
style: 'unit',
unit: 'kilometer',
unitDisplay: 'long'
});
console.log(unitFormatter.format(1234.5));
// ์ถ๋ ฅ: 1,234.5ํฌ๋ก๋ฏธํฐ
// ๋จ์ ํ์ (๋ฉ๊ฐ๋ฐ์ดํธ)
const mbFormatter = new Intl.NumberFormat('en-US', {
style: 'unit',
unit: 'megabyte',
unitDisplay: 'short'
});
console.log(mbFormatter.format(1024));
// ์ถ๋ ฅ: 1,024 MB
์์์ ์๋ฆฟ์ ์ ์ด
const number = 1234.56789;
// ์์์ 2์๋ฆฌ๋ก ์ ํ
const formatter1 = new Intl.NumberFormat('ko-KR', {
minimumFractionDigits: 2,
maximumFractionDigits: 2
});
console.log(formatter1.format(number));
// ์ถ๋ ฅ: 1,234.57 (๋ฐ์ฌ๋ฆผ๋จ)
// ์ต์ 3์๋ฆฌ, ์ต๋ 5์๋ฆฌ
const formatter2 = new Intl.NumberFormat('ko-KR', {
minimumFractionDigits: 3,
maximumFractionDigits: 5
});
console.log(formatter2.format(number));
// ์ถ๋ ฅ: 1,234.56789
console.log(formatter2.format(1234.5));
// ์ถ๋ ฅ: 1,234.500 (์ต์ 3์๋ฆฌ ๋ณด์ฅ)
๐ค Intl.Collator - ๋ฌธ์์ด ์ ๋ ฌ์ ๋ฌ์ธ
๋ฌธ์์ด์ ์ ๋ ฌํ ๋ ๋จ์ํ ์ํ๋ฒณ ์์๋ก๋ง ํ๋ฉด ์ ๋ผ์. ๊ฐ ์ธ์ด๋ง๋ค ์ ๋ ฌ ๊ท์น์ด ๋ค๋ฅด๊ฑฐ๋ ์! ์๋ฅผ ๋ค์ด ๋ ์ผ์ด์ 'รค'๋ 'a' ๋ค์์ ์์ผ ํ๊ณ , ์ค์จ๋ด์ด์์๋ 'รถ'๊ฐ ์ํ๋ฒณ ๋์ ์์นํด์. ๐๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ
const names = ['๊น์ฒ ์', '์ด์ํฌ', '๋ฐ๋ฏผ์', '์ต์งํ'];
// ํ๊ตญ์ด ์ ๋ ฌ
const koCollator = new Intl.Collator('ko-KR');
const sortedKo = names.sort(koCollator.compare);
console.log(sortedKo);
// ์ถ๋ ฅ: ['๊น์ฒ ์', '๋ฐ๋ฏผ์', '์ด์ํฌ', '์ต์งํ']
// ๋
์ผ์ด ๋จ์ด ์ ๋ ฌ
const germanWords = ['รpfel', 'Birnen', 'Apfel', 'รsterreich'];
const deCollator = new Intl.Collator('de-DE');
const sortedDe = germanWords.sort(deCollator.compare);
console.log(sortedDe);
// ์ถ๋ ฅ: ['Apfel', 'รpfel', 'Birnen', 'รsterreich']
๋์๋ฌธ์ ๊ตฌ๋ถ ์ต์
const words = ['apple', 'Apple', 'APPLE', 'banana'];
// ๋์๋ฌธ์ ๊ตฌ๋ถ (๊ธฐ๋ณธ๊ฐ)
const sensitiveCollator = new Intl.Collator('en-US', {
sensitivity: 'variant'
});
console.log(words.sort(sensitiveCollator.compare));
// ์ถ๋ ฅ: ['APPLE', 'Apple', 'apple', 'banana']
// ๋์๋ฌธ์ ๋ฌด์
const insensitiveCollator = new Intl.Collator('en-US', {
sensitivity: 'base'
});
console.log(words.sort(insensitiveCollator.compare));
// ์ถ๋ ฅ: ['apple', 'Apple', 'APPLE', 'banana']
์ซ์๊ฐ ํฌํจ๋ ๋ฌธ์์ด ์ ๋ ฌ
const files = ['file1.txt', 'file10.txt', 'file2.txt', 'file20.txt'];
// ์ผ๋ฐ ์ ๋ ฌ (๋ฌธ์์ด๋ก ์ทจ๊ธ)
console.log(files.sort());
// ์ถ๋ ฅ: ['file1.txt', 'file10.txt', 'file2.txt', 'file20.txt']
// ๐ฑ 10์ด 2๋ณด๋ค ์์ ์๋ฒ๋ฆผ!
// ์ซ์ ์ธ์ ์ ๋ ฌ
const numericCollator = new Intl.Collator('en-US', {
numeric: true
});
console.log(files.sort(numericCollator.compare));
// ์ถ๋ ฅ: ['file1.txt', 'file2.txt', 'file10.txt', 'file20.txt']
// ๐ ์ฌ๋ฐ๋ฅธ ์์!
numeric: true ์ต์
์ ์ ๋ง ์ ์ฉํฉ๋๋ค!
โฐ Intl.RelativeTimeFormat - ์๋์ ์๊ฐ ํํ
"3์ผ ์ ", "2์๊ฐ ํ" ๊ฐ์ ์๋์ ์๊ฐ ํํ, ์ง์ ๊ตฌํํ๋ ค๋ฉด ๋ณต์กํ์ฃ ? RelativeTimeFormat์ด ํด๊ฒฐํด์ค๋๋ค! โ// ํ๊ตญ์ด
const rtfKo = new Intl.RelativeTimeFormat('ko-KR', {
numeric: 'auto'
});
console.log(rtfKo.format(-1, 'day')); // ์ด์
console.log(rtfKo.format(0, 'day')); // ์ค๋
console.log(rtfKo.format(1, 'day')); // ๋ด์ผ
console.log(rtfKo.format(-3, 'day')); // 3์ผ ์
console.log(rtfKo.format(2, 'week')); // 2์ฃผ ํ
console.log(rtfKo.format(-5, 'month')); // 5๊ฐ์ ์
console.log(rtfKo.format(1, 'year')); // 1๋
ํ
// ์์ด
const rtfEn = new Intl.RelativeTimeFormat('en-US', {
numeric: 'auto'
});
console.log(rtfEn.format(-1, 'day')); // yesterday
console.log(rtfEn.format(0, 'day')); // today
console.log(rtfEn.format(1, 'day')); // tomorrow
console.log(rtfEn.format(-3, 'day')); // 3 days ago
console.log(rtfEn.format(2, 'week')); // in 2 weeks
์คํ์ผ ์ต์
const value = -3;
const unit = 'day';
// long ์คํ์ผ (๊ธฐ๋ณธ๊ฐ)
const rtfLong = new Intl.RelativeTimeFormat('ko-KR', {
style: 'long'
});
console.log(rtfLong.format(value, unit));
// ์ถ๋ ฅ: 3์ผ ์
// short ์คํ์ผ
const rtfShort = new Intl.RelativeTimeFormat('ko-KR', {
style: 'short'
});
console.log(rtfShort.format(value, unit));
// ์ถ๋ ฅ: 3์ผ ์
// narrow ์คํ์ผ
const rtfNarrow = new Intl.RelativeTimeFormat('ko-KR', {
style: 'narrow'
});
console.log(rtfNarrow.format(value, unit));
// ์ถ๋ ฅ: 3์ผ์
์ค์ ์์ : ๊ฒ์๊ธ ์์ฑ ์๊ฐ ํ์
function getRelativeTime(date, locale = 'ko-KR') {
const now = new Date();
const diff = date - now;
const seconds = Math.floor(diff / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
const weeks = Math.floor(days / 7);
const months = Math.floor(days / 30);
const years = Math.floor(days / 365);
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });
if (Math.abs(years) > 0) return rtf.format(years, 'year');
if (Math.abs(months) > 0) return rtf.format(months, 'month');
if (Math.abs(weeks) > 0) return rtf.format(weeks, 'week');
if (Math.abs(days) > 0) return rtf.format(days, 'day');
if (Math.abs(hours) > 0) return rtf.format(hours, 'hour');
if (Math.abs(minutes) > 0) return rtf.format(minutes, 'minute');
return rtf.format(seconds, 'second');
}
// ์ฌ์ฉ ์
const postDate = new Date('2024-01-12');
console.log(getRelativeTime(postDate));
// ์ถ๋ ฅ: 3์ผ ์ (ํ์ฌ ๋ ์ง ๊ธฐ์ค)
๐ Intl.ListFormat - ๋ชฉ๋ก ํ์ํ
๋ฐฐ์ด์ ์์ฐ์ค๋ฌ์ด ๋ฌธ์ฅ์ผ๋ก ๋ง๋ค์ด์ฃผ๋ ๊ธฐ๋ฅ์ด์์. "์ฌ๊ณผ, ๋ฐ๋๋, ๊ทธ๋ฆฌ๊ณ ์ค๋ ์ง" ๊ฐ์ ํํ์ ์๋์ผ๋ก ๋ง๋ค์ด์ค์! ๐๐๐const fruits = ['์ฌ๊ณผ', '๋ฐ๋๋', '์ค๋ ์ง'];
// ํ๊ตญ์ด - ์ ์์ฌ ์คํ์ผ
const listKo = new Intl.ListFormat('ko-KR', {
style: 'long',
type: 'conjunction'
});
console.log(listKo.format(fruits));
// ์ถ๋ ฅ: ์ฌ๊ณผ, ๋ฐ๋๋ ๋ฐ ์ค๋ ์ง
// ์์ด - ์ ์์ฌ ์คํ์ผ
const listEn = new Intl.ListFormat('en-US', {
style: 'long',
type: 'conjunction'
});
console.log(listEn.format(fruits));
// ์ถ๋ ฅ: ์ฌ๊ณผ, ๋ฐ๋๋, and ์ค๋ ์ง
// ์ ํ์ง ์คํ์ผ (or)
const listOr = new Intl.ListFormat('ko-KR', {
type: 'disjunction'
});
console.log(listOr.format(fruits));
// ์ถ๋ ฅ: ์ฌ๊ณผ, ๋ฐ๋๋ ๋๋ ์ค๋ ์ง
๋ค์ํ ์คํ์ผ
const items = ['HTML', 'CSS', 'JavaScript'];
// long ์คํ์ผ
const longList = new Intl.ListFormat('ko-KR', {
style: 'long',
type: 'conjunction'
});
console.log(longList.format(items));
// ์ถ๋ ฅ: HTML, CSS ๋ฐ JavaScript
// short ์คํ์ผ
const shortList = new Intl.ListFormat('ko-KR', {
style: 'short',
type: 'conjunction'
});
console.log(shortList.format(items));
// ์ถ๋ ฅ: HTML, CSS, JavaScript
// narrow ์คํ์ผ
const narrowList = new Intl.ListFormat('ko-KR', {
style: 'narrow',
type: 'conjunction'
});
console.log(narrowList.format(items));
// ์ถ๋ ฅ: HTML, CSS, JavaScript
2๏ธโฃ ์ ํ๋ ์ต์ ํ์: "์ฌ์ด์ฆ M, L ๋ฐ XL ์ ํ๋จ"
3๏ธโฃ ํ๊ทธ ๋ชฉ๋ก: "JavaScript, React ๋ฐ Node.js"
4๏ธโฃ ์ฐธ์ฌ์ ๋ชฉ๋ก: "๊น์ฒ ์, ์ด์ํฌ ๊ทธ๋ฆฌ๊ณ ๋ฐ๋ฏผ์"
๐ท๏ธ Intl.DisplayNames - ์ด๋ฆ ํ์ํ๊ธฐ
์ธ์ด ์ด๋ฆ, ๊ตญ๊ฐ ์ด๋ฆ, ํตํ ์ด๋ฆ ๋ฑ์ ํ์งํ๋ ํํ๋ก ํ์ํด์ฃผ๋ ๊ธฐ๋ฅ์ด์์. ์ฝ๋๋ง ์๋ฉด ์๋์ผ๋ก ์ด๋ฆ์ ๊ฐ์ ธ์ฌ ์ ์์ด์! ๐์ธ์ด ์ด๋ฆ ํ์
// ํ๊ตญ์ด๋ก ์ธ์ด ์ด๋ฆ ํ์
const languageNamesKo = new Intl.DisplayNames(['ko-KR'], {
type: 'language'
});
console.log(languageNamesKo.of('en')); // ์์ด
console.log(languageNamesKo.of('ko')); // ํ๊ตญ์ด
console.log(languageNamesKo.of('ja')); // ์ผ๋ณธ์ด
console.log(languageNamesKo.of('zh')); // ์ค๊ตญ์ด
console.log(languageNamesKo.of('fr')); // ํ๋์ค์ด
// ์์ด๋ก ์ธ์ด ์ด๋ฆ ํ์
const languageNamesEn = new Intl.DisplayNames(['en-US'], {
type: 'language'
});
console.log(languageNamesEn.of('ko')); // Korean
console.log(languageNamesEn.of('ja')); // Japanese
๊ตญ๊ฐ/์ง์ญ ์ด๋ฆ ํ์
// ํ๊ตญ์ด๋ก ๊ตญ๊ฐ ์ด๋ฆ ํ์
const regionNamesKo = new Intl.DisplayNames(['ko-KR'], {
type: 'region'
});
console.log(regionNamesKo.of('KR')); // ๋ํ๋ฏผ๊ตญ
console.log(regionNamesKo.of('US')); // ๋ฏธ๊ตญ
console.log(regionNamesKo.of('JP')); // ์ผ๋ณธ
console.log(regionNamesKo.of('CN')); // ์ค๊ตญ
console.log(regionNamesKo.of('GB')); // ์๊ตญ
// ์์ด๋ก ๊ตญ๊ฐ ์ด๋ฆ ํ์
const regionNamesEn = new Intl.DisplayNames(['en-US'], {
type: 'region'
});
console.log(regionNamesEn.of('KR')); // South Korea
console.log(regionNamesEn.of('JP')); // Japan
ํตํ ์ด๋ฆ ํ์
// ํ๊ตญ์ด๋ก ํตํ ์ด๋ฆ ํ์
const currencyNamesKo = new Intl.DisplayNames(['ko-KR'], {
type: 'currency'
});
console.log(currencyNamesKo.of('KRW')); // ๋ํ๋ฏผ๊ตญ ์
console.log(currencyNamesKo.of('USD')); // ๋ฏธ๊ตญ ๋ฌ๋ฌ
console.log(currencyNamesKo.of('EUR')); // ์ ๋ก
console.log(currencyNamesKo.of('JPY')); // ์ผ๋ณธ ์
console.log(currencyNamesKo.of('GBP')); // ์๊ตญ ํ์ด๋
// ์์ด๋ก ํตํ ์ด๋ฆ ํ์
const currencyNamesEn = new Intl.DisplayNames(['en-US'], {
type: 'currency'
});
console.log(currencyNamesEn.of('KRW')); // South Korean Won
console.log(currencyNamesEn.of('EUR')); // Euro
โ ๊ตญ๊ฐ ์ ํ ํผ
โ ํตํ ์ ํ ์ต์
โ ์ฌ์ฉ์ ํ๋กํ์ ๊ตญ์ /์ธ์ด ํ์
โ ๋ค๊ตญ์ด ์ค์ ํ์ด์ง
ํ๋์ฝ๋ฉ๋ ๋ฒ์ญ ๋ฐ์ดํฐ๋ฅผ ์ ์งํ ํ์๊ฐ ์์ด์ ์ ๋ง ํธํด์! ๐
๐ฒ Intl.PluralRules - ๋ณต์ํ ๊ท์น ์ฒ๋ฆฌ
์์ด์์๋ "1 apple", "2 apples"์ฒ๋ผ ๋ณต์ํ์ด ๊ฐ๋จํ์ง๋ง, ๋ค๋ฅธ ์ธ์ด๋ค์ ํจ์ฌ ๋ณต์กํด์. ๋ฌ์์์ด๋ ๋ณต์ํ ๊ท์น์ด 3๊ฐ์ง๋ ๋๊ณ , ์๋์ด๋ 6๊ฐ์ง๋ ๋ผ์! ๐ต// ์์ด ๋ณต์ํ ๊ท์น
const prEn = new Intl.PluralRules('en-US');
console.log(prEn.select(0)); // other
console.log(prEn.select(1)); // one
console.log(prEn.select(2)); // other
console.log(prEn.select(5)); // other
// ํ๊ตญ์ด ๋ณต์ํ ๊ท์น (ํญ์ other)
const prKo = new Intl.PluralRules('ko-KR');
console.log(prKo.select(0)); // other
console.log(prKo.select(1)); // other
console.log(prKo.select(2)); // other
// ๋ฌ์์์ด ๋ณต์ํ ๊ท์น (๋ณต์กํจ!)
const prRu = new Intl.PluralRules('ru-RU');
console.log(prRu.select(1)); // one
console.log(prRu.select(2)); // few
console.log(prRu.select(5)); // many
console.log(prRu.select(21)); // one
์ค์ ์์ : ๋์ ๋ฉ์์ง ์์ฑ
function getItemMessage(count, locale = 'ko-KR') {
const pr = new Intl.PluralRules(locale);
const rule = pr.select(count);
const messages = {
'ko-KR': {
other: `${count}๊ฐ์ ํญ๋ชฉ`
},
'en-US': {
one: `${count} item`,
other: `${count} items`
},
'ru-RU': {
one: `${count} ะฟัะตะดะผะตั`,
few: `${count} ะฟัะตะดะผะตัะฐ`,
many: `${count} ะฟัะตะดะผะตัะพะฒ`
}
};
return messages[locale][rule];
}
console.log(getItemMessage(1, 'en-US')); // 1 item
console.log(getItemMessage(5, 'en-US')); // 5 items
console.log(getItemMessage(1, 'ru-RU')); // 1 ะฟัะตะดะผะตั
console.log(getItemMessage(2, 'ru-RU')); // 2 ะฟัะตะดะผะตัะฐ
console.log(getItemMessage(5, 'ru-RU')); // 5 ะฟัะตะดะผะตัะพะฒ
โข one: 1๊ฐ์ผ ๋
โข two: 2๊ฐ์ผ ๋ (์จ์ผ์ค์ด ๋ฑ)
โข few: ์์์ผ ๋ (๋ฌ์์์ด, ํด๋๋์ด ๋ฑ)
โข many: ๋ค์์ผ ๋ (๋ฌ์์์ด, ํด๋๋์ด ๋ฑ)
โข other: ๊ทธ ์ธ ๋ชจ๋ ๊ฒฝ์ฐ
์ธ์ด๋ง๋ค ์ฌ์ฉํ๋ ๊ท์น์ด ๋ค๋ฅด๋ ์ฃผ์ํ์ธ์!
๐ Intl.Locale - ๋ก์ผ์ผ ์ ๋ณด ๊ด๋ฆฌ
๋ก์ผ์ผ(Locale)์ ์ธ์ด์ ์ง์ญ ์ ๋ณด๋ฅผ ๋ด๊ณ ์๋ ์๋ณ์์์. 'ko-KR'์ ํ๊ตญ์ด-๋ํ๋ฏผ๊ตญ, 'en-US'๋ ์์ด-๋ฏธ๊ตญ์ ์๋ฏธํ์ฃ . Intl.Locale ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๋ฉด ์ด๋ฐ ์ ๋ณด๋ฅผ ์ฝ๊ฒ ๋ค๋ฃฐ ์ ์์ด์! ๐บ๏ธ// ๋ก์ผ์ผ ๊ฐ์ฒด ์์ฑ
const locale = new Intl.Locale('ko-KR');
console.log(locale.language); // ko
console.log(locale.region); // KR
console.log(locale.baseName); // ko-KR
// ์ต์
๊ณผ ํจ๊ป ์์ฑ
const localeWithOptions = new Intl.Locale('ko-KR', {
calendar: 'gregory',
numberingSystem: 'latn',
hourCycle: 'h23'
});
console.log(localeWithOptions.calendar); // gregory
console.log(localeWithOptions.numberingSystem); // latn
console.log(localeWithOptions.hourCycle); // h23
// ์์ด ๋ก์ผ์ผ
const enLocale = new Intl.Locale('en-US');
console.log(enLocale.language); // en
console.log(enLocale.region); // US
๋ก์ผ์ผ ์ ๋ณด ํ์ฅ
// ๊ธฐ๋ณธ ๋ก์ผ์ผ์์ ํ์ฅ
const baseLocale = new Intl.Locale('ko');
const extendedLocale = new Intl.Locale(baseLocale, {
region: 'KR',
script: 'Hang'
});
console.log(extendedLocale.toString()); // ko-Hang-KR
// ๋ค์ํ ์์ฑ ํ์ธ
const detailedLocale = new Intl.Locale('zh-Hans-CN-u-ca-chinese-nu-hanidec');
console.log(detailedLocale.language); // zh
console.log(detailedLocale.script); // Hans
console.log(detailedLocale.region); // CN
console.log(detailedLocale.calendar); // chinese
console.log(detailedLocale.numberingSystem); // hanidec
๐ ์ค์ ํ๋ก์ ํธ: ๋ค๊ตญ์ด ์ผํ๋ชฐ ๋ง๋ค๊ธฐ
์, ์ด์ ๋ฐฐ์ด ๊ฑธ ์ข ํฉํด์ ์ค์ ํ๋ก์ ํธ์ ์ ์ฉํด๋ณผ๊น์? ๊ฐ๋จํ ๋ค๊ตญ์ด ์ผํ๋ชฐ ์์ ๋ฅผ ๋ง๋ค์ด๋ณด๊ฒ ์ต๋๋ค! ๐class MultilingualShop {
constructor(locale = 'ko-KR') {
this.locale = locale;
this.currencyMap = {
'ko-KR': 'KRW',
'en-US': 'USD',
'ja-JP': 'JPY',
'de-DE': 'EUR'
};
}
// ๊ฐ๊ฒฉ ํ์ํ
formatPrice(price) {
const currency = this.currencyMap[this.locale] || 'USD';
const formatter = new Intl.NumberFormat(this.locale, {
style: 'currency',
currency: currency
});
return formatter.format(price);
}
// ๋ ์ง ํ์ํ
formatDate(date) {
const formatter = new Intl.DateTimeFormat(this.locale, {
year: 'numeric',
month: 'long',
day: 'numeric'
});
return formatter.format(date);
}
// ๋ฐฐ์ก ์์ ์ผ ํ์
formatDeliveryTime(days) {
const rtf = new Intl.RelativeTimeFormat(this.locale, {
numeric: 'auto'
});
return rtf.format(days, 'day');
}
// ์ฌ๊ณ ์๋ ๋ฉ์์ง
formatStockMessage(count) {
const pr = new Intl.PluralRules(this.locale);
const rule = pr.select(count);
const messages = {
'ko-KR': {
other: `์ฌ๊ณ ${count}๊ฐ ๋จ์`
},
'en-US': {
one: `${count} item left`,
other: `${count} items left`
},
'ja-JP': {
other: `ๅจๅบซ${count}ๅ`
}
};
return messages[this.locale]?.[rule] || `${count} items`;
}
// ์ํ ์ ๋ณด ํ์
displayProduct(product) {
return {
name: product.name,
price: this.formatPrice(product.price),
releaseDate: this.formatDate(product.releaseDate),
delivery: this.formatDeliveryTime(product.deliveryDays),
stock: this.formatStockMessage(product.stock)
};
}
}
// ์ฌ์ฉ ์์
const product = {
name: 'JavaScript ์๋ฒฝ ๊ฐ์ด๋',
price: 35000,
releaseDate: new Date('2024-01-15'),
deliveryDays: 2,
stock: 15
};
// ํ๊ตญ์ด ๋ฒ์
const shopKo = new MultilingualShop('ko-KR');
console.log(shopKo.displayProduct(product));
/* ์ถ๋ ฅ:
{
name: 'JavaScript ์๋ฒฝ ๊ฐ์ด๋',
price: 'โฉ35,000',
releaseDate: '2024๋
1์ 15์ผ',
delivery: '๋ชจ๋ ',
stock: '์ฌ๊ณ 15๊ฐ ๋จ์'
}
*/
// ์์ด ๋ฒ์
const shopEn = new MultilingualShop('en-US');
console.log(shopEn.displayProduct(product));
/* ์ถ๋ ฅ:
{
name: 'JavaScript ์๋ฒฝ ๊ฐ์ด๋',
price: '$35,000.00',
releaseDate: 'January 15, 2024',
delivery: 'in 2 days',
stock: '15 items left'
}
*/
// ์ผ๋ณธ์ด ๋ฒ์
const shopJp = new MultilingualShop('ja-JP');
console.log(shopJp.displayProduct(product));
/* ์ถ๋ ฅ:
{
name: 'JavaScript ์๋ฒฝ ๊ฐ์ด๋',
price: 'ยฅ35,000',
releaseDate: '2024ๅนด1ๆ15ๆฅ',
delivery: '2ๆฅๅพ',
stock: 'ๅจๅบซ15ๅ'
}
*/
๐ผ ์ฌ๋ฅ๋ท์์ ๊ตญ์ ํ ๊ธฐ์ ๋ฐฐ์ฐ๊ณ ๋๋๊ธฐ
์ฌ๋ฌ๋ถ, ์ด๋ ๊ฒ ๊ฐ๋ ฅํ ๊ตญ์ ํ ๊ธฐ์ ์ ๋ฐฐ์ฐ์ จ๋๋ฐ, ํน์ ๋ ๊น์ด ๊ณต๋ถํ๊ณ ์ถ๊ฑฐ๋ ๋ค๋ฅธ ์ฌ๋๋ค๊ณผ ์ง์์ ๋๋๊ณ ์ถ์ผ์ ๊ฐ์? ๐ค์ฌ๋ฅ๋ท์ ๋ค์ํ ํ๋ก๊ทธ๋๋ฐ ์ฌ๋ฅ์ ๊ฑฐ๋ํ๊ณ ๊ณต์ ํ๋ ํ๋ซํผ์ด์์. JavaScript ๊ตญ์ ํ ๊ฐ์ ์ ๋ฌธ ๊ธฐ์ ์ ๋ฐฐ์ฐ๊ณ ์ถ๋ค๋ฉด, ์ฌ๋ฅ๋ท์์ ์ ๋ฌธ๊ฐ๋ฅผ ์ฐพ์๋ณผ ์ ์์ด์. ๋ฐ๋๋ก ์ฌ๋ฌ๋ถ์ด ์ด ๋ถ์ผ์ ์์ ์๋ค๋ฉด, ์ฌ๋ฅ๋ท์ ํตํด ๋ค๋ฅธ ๊ฐ๋ฐ์๋ค์๊ฒ ๊ฐ๋ฅด์ณ์ฃผ๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ด์ฃ ! ๐ก
ํนํ ์ค๋ฌด์์ ๋ค๊ตญ์ด ์น์ฌ์ดํธ๋ฅผ ๊ฐ๋ฐํด๋ณธ ๊ฒฝํ์ด ์๋ค๋ฉด, ๊ทธ ๋ ธํ์ฐ๋ฅผ ๋๋๋ ๊ฒ๋ง์ผ๋ก๋ ๋ง์ ์ฌ๋๋ค์๊ฒ ๋์์ด ๋ ๊ฑฐ์์. ํจ๊ป ์ฑ์ฅํ๋ ๊ฐ๋ฐ์ ์ปค๋ฎค๋ํฐ, ๋ฉ์ง์ง ์๋์? ๐
๐ฏ ์ฑ๋ฅ ์ต์ ํ ํ
Intl ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ ๋ ์ฑ๋ฅ์ ๊ณ ๋ คํ๋ ๊ฒ๋ ์ค์ํด์. ๋ช ๊ฐ์ง ํ์ ์๋ ค๋๋ฆด๊ฒ์! โก1. ํฌ๋งทํฐ ์ฌ์ฌ์ฉํ๊ธฐ
// โ ๋์ ์: ๋งค๋ฒ ์๋ก ์์ฑ
function formatPrices(prices) {
return prices.map(price => {
const formatter = new Intl.NumberFormat('ko-KR', {
style: 'currency',
currency: 'KRW'
});
return formatter.format(price);
});
}
// โ
์ข์ ์: ํ ๋ฒ๋ง ์์ฑํ๊ณ ์ฌ์ฌ์ฉ
function formatPricesOptimized(prices) {
const formatter = new Intl.NumberFormat('ko-KR', {
style: 'currency',
currency: 'KRW'
});
return prices.map(price => formatter.format(price));
}
// ์ฑ๋ฅ ๋น๊ต
const prices = Array.from({ length: 1000 }, (_, i) => i * 1000);
console.time('๋์ ์');
formatPrices(prices);
console.timeEnd('๋์ ์');
console.time('์ข์ ์');
formatPricesOptimized(prices);
console.timeEnd('์ข์ ์');
// ์ข์ ์๊ฐ ํจ์ฌ ๋น ๋ฆ
๋๋ค!
2. ์ฑ๊ธํค ํจํด ํ์ฉ
// ํฌ๋งทํฐ ์บ์ฑ ํด๋์ค
class FormatterCache {
constructor() {
this.cache = new Map();
}
getNumberFormatter(locale, options) {
const key = `${locale}-${JSON.stringify(options)}`;
if (!this.cache.has(key)) {
this.cache.set(
key,
new Intl.NumberFormat(locale, options)
);
}
return this.cache.get(key);
}
getDateFormatter(locale, options) {
const key = `date-${locale}-${JSON.stringify(options)}`;
if (!this.cache.has(key)) {
this.cache.set(
key,
new Intl.DateTimeFormat(locale, options)
);
}
return this.cache.get(key);
}
}
// ์ ์ญ ์ธ์คํด์ค
const formatterCache = new FormatterCache();
// ์ฌ์ฉ
function formatPrice(price, locale = 'ko-KR') {
const formatter = formatterCache.getNumberFormatter(locale, {
style: 'currency',
currency: 'KRW'
});
return formatter.format(price);
}
function formatDate(date, locale = 'ko-KR') {
const formatter = formatterCache.getDateFormatter(locale, {
year: 'numeric',
month: 'long',
day: 'numeric'
});
return formatter.format(date);
}
- โ Intl ๊ฐ์ฒด ์์ฑ์ ๋น์ฉ์ด ํฐ ์์ ์ด์์
- โ ๊ฐ๋ฅํ ํ ์ฌ์ฌ์ฉํ์ธ์
- โ ์บ์ฑ์ ํ์ฉํ๋ฉด ์ฑ๋ฅ์ด ํฌ๊ฒ ํฅ์๋ผ์
- โ ํนํ ๋ฐ๋ณต๋ฌธ ์์์๋ ์ ๋ ๋งค๋ฒ ์์ฑํ์ง ๋ง์ธ์!
๐ ํํ ์ค์์ ํด๊ฒฐ ๋ฐฉ๋ฒ
์ค๋ฌด์์ ์์ฃผ ๋ฐ์ํ๋ ์ค์๋ค์ ์ ๋ฆฌํด๋ดค์ด์. ๋ฏธ๋ฆฌ ์๊ณ ์์ผ๋ฉด ์ฝ์ง์ ์ค์ผ ์ ์์ด์! ๐1. ์๋ชป๋ ๋ก์ผ์ผ ์ฝ๋ ์ฌ์ฉ
// โ ์๋ชป๋ ์
try {
const formatter = new Intl.NumberFormat('korean');
// RangeError: Invalid language tag: korean
} catch (e) {
console.error(e);
}
// โ
์ฌ๋ฐ๋ฅธ ์
const formatter = new Intl.NumberFormat('ko-KR');
// ๋ก์ผ์ผ ์ ํจ์ฑ ๊ฒ์ฌ
function isValidLocale(locale) {
try {
new Intl.NumberFormat(locale);
return true;
} catch (e) {
return false;
}
}
console.log(isValidLocale('ko-KR')); // true
console.log(isValidLocale('korean')); // false
2. ํตํ ์ฝ๋ ๋๋ฝ
// โ ์๋ฌ ๋ฐ์
try {
const formatter = new Intl.NumberFormat('ko-KR', {
style: 'currency'
// currency ์ต์
์ด ์์!
});
} catch (e) {
console.error(e);
// TypeError: Currency code is required with currency style.
}
// โ
์ฌ๋ฐ๋ฅธ ์
const formatter = new Intl.NumberFormat('ko-KR', {
style: 'currency',
currency: 'KRW' // ๋ฐ๋์ ํ์!
});
3. ํ์์กด ์ฒ๋ฆฌ ์ค์
// ์๋ฒ์์ ๋ฐ์ UTC ์๊ฐ
const utcDate = new Date('2024-01-15T14:30:00Z');
// โ ๋ก์ปฌ ์๊ฐ์ผ๋ก ํ์๋จ
const formatter1 = new Intl.DateTimeFormat('ko-KR', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit'
});
console.log(formatter1.format(utcDate));
// ์ถ๋ ฅ: 2024. 01. 15. 23:30 (ํ๊ตญ ์๊ฐ์ผ๋ก ๋ณํ๋จ)
// โ
ํน์ ํ์์กด์ผ๋ก ํ์
const formatter2 = new Intl.DateTimeFormat('ko-KR', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
timeZone: 'UTC' // UTC๋ก ๊ณ ์
});
console.log(formatter2.format(utcDate));
// ์ถ๋ ฅ: 2024. 01. 15. 14:30
// ๋ค๋ฅธ ํ์์กด์ผ๋ก ํ์
const formatter3 = new Intl.DateTimeFormat('ko-KR', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
timeZone: 'America/New_York'
});
console.log(formatter3.format(utcDate));
// ์ถ๋ ฅ: 2024. 01. 15. 09:30 (๋ด์ ์๊ฐ)
4. ๋ธ๋ผ์ฐ์ ํธํ์ฑ ๋ฏธํ์ธ
// ๊ธฐ๋ฅ ์ง์ ์ฌ๋ถ ํ์ธ
function checkIntlSupport() {
const support = {
DateTimeFormat: typeof Intl.DateTimeFormat !== 'undefined',
NumberFormat: typeof Intl.NumberFormat !== 'undefined',
Collator: typeof Intl.Collator !== 'undefined',
PluralRules: typeof Intl.PluralRules !== 'undefined',
RelativeTimeFormat: typeof Intl.RelativeTimeFormat !== 'undefined',
ListFormat: typeof Intl.ListFormat !== 'undefined',
DisplayNames: typeof Intl.DisplayNames !== 'undefined'
};
return support;
}
const support = checkIntlSupport();
console.log(support);
// ํด๋ฐฑ ์ฒ๋ฆฌ
function formatPrice(price, locale = 'ko-KR') {
if (typeof Intl.NumberFormat !== 'undefined') {
const formatter = new Intl.NumberFormat(locale, {
style: 'currency',
currency: 'KRW'
});
return formatter.format(price);
} else {
// ํด๋ฐฑ: ๊ฐ๋จํ ํ์
return `โฉ${price.toLocaleString()}`;
}
}
โข PluralRules, RelativeTimeFormat: Chrome 63+, Firefox 58+, Safari 13+
โข ListFormat: Chrome 72+, Firefox 78+, Safari 14.1+
โข DisplayNames: Chrome 81+, Firefox 86+, Safari 14.1+
๊ตฌํ ๋ธ๋ผ์ฐ์ ๋ฅผ ์ง์ํด์ผ ํ๋ค๋ฉด ํด๋ฆฌํ(polyfill)์ ์ฌ์ฉํ๊ฑฐ๋ ํด๋ฐฑ ๋ก์ง์ ๊ตฌํํ์ธ์!
๐ ์ค์ ํ์ฉ ์ฌ๋ก
์ด๋ก ์ ์ถฉ๋ถํ ๋ฐฐ์ ์ผ๋, ์ด์ ์ค์ ๋ก ์ด๋ป๊ฒ ํ์ฉ๋๋์ง ๊ตฌ์ฒด์ ์ธ ์์ ๋ค์ ์ดํด๋ณผ๊น์? ๐ผ์ฌ๋ก 1: ๋ค๊ตญ์ด ๋ธ๋ก๊ทธ ์์คํ
class BlogPost {
constructor(locale = 'ko-KR') {
this.locale = locale;
this.dateFormatter = new Intl.DateTimeFormat(locale, {
year: 'numeric',
month: 'long',
day: 'numeric'
});
this.rtf = new Intl.RelativeTimeFormat(locale, {
numeric: 'auto'
});
}
formatPublishDate(date) {
return this.dateFormatter.format(date);
}
getTimeAgo(date) {
const now = new Date();
const diffInSeconds = Math.floor((date - now) / 1000);
const diffInMinutes = Math.floor(diffInSeconds / 60);
const diffInHours = Math.floor(diffInMinutes / 60);
const diffInDays = Math.floor(diffInHours / 24);
if (Math.abs(diffInDays) > 0) {
return this.rtf.format(diffInDays, 'day');
} else if (Math.abs(diffInHours) > 0) {
return this.rtf.format(diffInHours, 'hour');
} else if (Math.abs(diffInMinutes) > 0) {
return this.rtf.format(diffInMinutes, 'minute');
} else {
return this.rtf.format(diffInSeconds, 'second');
}
}
formatReadingTime(minutes) {
const pr = new Intl.PluralRules(this.locale);
const rule = pr.select(minutes);
const messages = {
'ko-KR': {
other: `${minutes}๋ถ ์์`
},
'en-US': {
one: `${minutes} minute read`,
other: `${minutes} minutes read`
},
'ja-JP': {
other: `${minutes}ๅใง่ชญใใพใ`
}
};
return messages[this.locale]?.[rule] || `${minutes} min`;
}
render(post) {
return {
title: post.title,
publishDate: this.formatPublishDate(post.publishDate),
timeAgo: this.getTimeAgo(post.publishDate),
readingTime: this.formatReadingTime(post.readingMinutes),
views: this.formatViews(post.views)
};
}
formatViews(count) {
const formatter = new Intl.NumberFormat(this.locale, {
notation: 'compact',
compactDisplay: 'short'
});
return formatter.format(count);
}
}
// ์ฌ์ฉ ์์
const post = {
title: 'JavaScript ๊ตญ์ ํ ์๋ฒฝ ๊ฐ์ด๋',
publishDate: new Date('2024-01-10'),
readingMinutes: 15,
views: 12500
};
const blogKo = new BlogPost('ko-KR');
console.log(blogKo.render(post));
/* ์ถ๋ ฅ:
{
title: 'JavaScript ๊ตญ์ ํ ์๋ฒฝ ๊ฐ์ด๋',
publishDate: '2024๋
1์ 10์ผ',
timeAgo: '5์ผ ์ ',
readingTime: '15๋ถ ์์',
views: '1.3๋ง'
}
*/
const blogEn = new BlogPost('en-US');
console.log(blogEn.render(post));
/* ์ถ๋ ฅ:
{
title: 'JavaScript ๊ตญ์ ํ ์๋ฒฝ ๊ฐ์ด๋',
publishDate: 'January 10, 2024',
timeAgo: '5 days ago',
readingTime: '15 minutes read',
views: '13K'
}
*/
์ฌ๋ก 2: ๋ค๊ตญ์ด ๋์๋ณด๋
class Dashboard {
constructor(locale = 'ko-KR') {
this.locale = locale;
this.currency = this.getCurrencyForLocale(locale);
}
getCurrencyForLocale(locale) {
const currencyMap = {
'ko-KR': 'KRW',
'en-US': 'USD',
'ja-JP': 'JPY',
'de-DE': 'EUR',
'en-GB': 'GBP'
};
return currencyMap[locale] || 'USD';
}
formatRevenue(amount) {
const formatter = new Intl.NumberFormat(this.locale, {
style: 'currency',
currency: this.currency,
notation: 'compact',
maximumFractionDigits: 1
});
return formatter.format(amount);
}
formatPercentage(value) {
const formatter = new Intl.NumberFormat(this.locale, {
style: 'percent',
minimumFractionDigits: 1,
maximumFractionDigits: 1,
signDisplay: 'exceptZero'
});
return formatter.format(value);
}
formatUserCount(count) {
const formatter = new Intl.NumberFormat(this.locale, {
notation: 'compact',
compactDisplay: 'short'
});
return formatter.format(count);
}
formatGrowthRate(current, previous) {
const growth = (current - previous) / previous;
return this.formatPercentage(growth);
}
renderStats(data) {
return {
revenue: this.formatRevenue(data.revenue),
revenueGrowth: this.formatGrowthRate(data.revenue, data.previousRevenue),
users: this.formatUserCount(data.users),
userGrowth: this.formatGrowthRate(data.users, data.previousUsers),
conversionRate: this.formatPercentage(data.conversionRate)
};
}
}
// ์ฌ์ฉ ์์
const dashboardData = {
revenue: 5420000,
previousRevenue: 4800000,
users: 125000,
previousUsers: 98000,
conversionRate: 0.0342
};
const dashKo = new Dashboard('ko-KR');
console.log(dashKo.renderStats(dashboardData));
/* ์ถ๋ ฅ:
{
revenue: 'โฉ542๋ง',
revenueGrowth: '+12.9%',
users: '13๋ง',
userGrowth: '+27.6%',
conversionRate: '3.4%'
}
*/
const dashEn = new Dashboard('en-US');
console.log(dashEn.renderStats(dashboardData));
/* ์ถ๋ ฅ:
{
revenue: '$5.4M',
revenueGrowth: '+12.9%',
users: '125K',
userGrowth: '+27.6%',
conversionRate: '3.4%'
}
*/
์ฌ๋ก 3: ์ด๋ฒคํธ ์์ฝ ์์คํ
class EventBooking {
constructor(locale = 'ko-KR', timeZone = 'Asia/Seoul') {
this.locale = locale;
this.timeZone = timeZone;
}
formatEventDate(date) {
const formatter = new Intl.DateTimeFormat(this.locale, {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
timeZone: this.timeZone,
timeZoneName: 'short'
});
return formatter.format(date);
}
formatDuration(minutes) {
const hours = Math.floor(minutes / 60);
const mins = minutes % 60;
const parts = [];
if (hours > 0) {
const hourFormatter = new Intl.NumberFormat(this.locale, {
style: 'unit',
unit: 'hour',
unitDisplay: 'long'
});
parts.push(hourFormatter.format(hours));
}
if (mins > 0) {
const minFormatter = new Intl.NumberFormat(this.locale, {
style: 'unit',
unit: 'minute',
unitDisplay: 'long'
});
parts.push(minFormatter.format(mins));
}
const listFormatter = new Intl.ListFormat(this.locale, {
style: 'long',
type: 'conjunction'
});
return listFormatter.format(parts);
}
formatAttendees(names) {
const listFormatter = new Intl.ListFormat(this.locale, {
style: 'long',
type: 'conjunction'
});
return listFormatter.format(names);
}
formatPrice(price) {
const currencyMap = {
'ko-KR': 'KRW',
'en-US': 'USD',
'ja-JP': 'JPY'
};
const currency = currencyMap[this.locale] || 'USD';
const formatter = new Intl.NumberFormat(this.locale, {
style: 'currency',
currency: currency
});
return formatter.format(price);
}
renderEvent(event) {
return {
title: event.title,
date: this.formatEventDate(event.date),
duration: this.formatDuration(event.durationMinutes),
attendees: this.formatAttendees(event.attendees),
price: this.formatPrice(event.price)
};
}
}
// ์ฌ์ฉ ์์
const event = {
title: 'JavaScript ๊ตญ์ ํ ์ํฌ์ต',
date: new Date('2024-02-15T14:00:00'),
durationMinutes: 150,
attendees: ['๊น์ฒ ์', '์ด์ํฌ', '๋ฐ๋ฏผ์'],
price: 50000
};
const bookingKo = new EventBooking('ko-KR', 'Asia/Seoul');
console.log(bookingKo.renderEvent(event));
/* ์ถ๋ ฅ:
{
title: 'JavaScript ๊ตญ์ ํ ์ํฌ์ต',
date: '2024๋
2์ 15์ผ ๋ชฉ์์ผ ์คํ 2:00 GMT+9',
duration: '2์๊ฐ ๋ฐ 30๋ถ',
attendees: '๊น์ฒ ์, ์ด์ํฌ ๋ฐ ๋ฐ๋ฏผ์',
price: 'โฉ50,000'
}
*/
const bookingEn = new EventBooking('en-US', 'America/New_York');
console.log(bookingEn.renderEvent(event));
/* ์ถ๋ ฅ:
{
title: 'JavaScript ๊ตญ์ ํ ์ํฌ์ต',
date: 'Thursday, February 15, 2024 at 12:00 AM EST',
duration: '2 hours and 30 minutes',
attendees: '๊น์ฒ ์, ์ด์ํฌ, and ๋ฐ๋ฏผ์',
price: '$50,000.00'
}
*/
2๏ธโฃ ์ฌ์ฉ์ ์ ํธ๋ ์กด์ค: ๋ธ๋ผ์ฐ์ ์ค์ ์ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ฌ์ฉ
3๏ธโฃ ํ์์กด ๋ช ์: ๋ ์ง/์๊ฐ ํ์ ์ ํ์์กด ์ ๋ณด ํฌํจ
4๏ธโฃ ํด๋ฐฑ ์ ๊ณต: ์ง์ํ์ง ์๋ ๋ก์ผ์ผ์ ๋ํ ๋๋น์ฑ ๋ง๋ จ
5๏ธโฃ ํ ์คํธ ์ฒ ์ ํ: ๋ค์ํ ๋ก์ผ์ผ์์ ํ ์คํธ ํ์!
๐ง ์ ์ฉํ ํฌํผ ํจ์ ๋ชจ์
์ค๋ฌด์์ ์์ฃผ ์ฌ์ฉํ๋ ์ ํธ๋ฆฌํฐ ํจ์๋ค์ ๋ชจ์๋ดค์ด์. ๋ณต์ฌํด์ ๋ฐ๋ก ์ฌ์ฉํ์ ๋ ์ข์์! ๐// ๊ตญ์ ํ ์ ํธ๋ฆฌํฐ ํด๋์ค
class I18nUtils {
// ์ฌ์ฉ์ ๋ก์ผ์ผ ๊ฐ์ง
static getUserLocale() {
return navigator.language ||
navigator.userLanguage ||
'en-US';
}
// ๋ก์ผ์ผ ์ ํจ์ฑ ๊ฒ์ฌ
static isValidLocale(locale) {
try {
new Intl.DateTimeFormat(locale);
return true;
} catch {
return false;
}
}
// ์ง์ ๊ฐ๋ฅํ ๋ก์ผ์ผ ์ฐพ๊ธฐ
static getSupportedLocale(requestedLocales, availableLocales) {
const requested = Array.isArray(requestedLocales)
? requestedLocales
: [requestedLocales];
for (const locale of requested) {
if (availableLocales.includes(locale)) {
return locale;
}
// ์ธ์ด ์ฝ๋๋ง ๋งค์นญ ์๋ (ko-KR -> ko)
const language = locale.split('-')[0];
const match = availableLocales.find(
available => available.startsWith(language)
);
if (match) return match;
}
return availableLocales[0]; // ๊ธฐ๋ณธ๊ฐ
}
// ์ซ์๋ฅผ ์ฝ๊ธฐ ์ฌ์ด ํํ๋ก
static formatCompactNumber(number, locale = 'ko-KR') {
return new Intl.NumberFormat(locale, {
notation: 'compact',
compactDisplay: 'short'
}).format(number);
}
// ํ์ผ ํฌ๊ธฐ ํ์ํ
static formatFileSize(bytes, locale = 'ko-KR') {
const units = ['byte', 'kilobyte', 'megabyte', 'gigabyte', 'terabyte'];
let size = bytes;
let unitIndex = 0;
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024;
unitIndex++;
}
return new Intl.NumberFormat(locale, {
style: 'unit',
unit: units[unitIndex],
unitDisplay: 'short',
maximumFractionDigits: 2
}).format(size);
}
// ๋ ์ง ๋ฒ์ ํ์ํ
static formatDateRange(startDate, endDate, locale = 'ko-KR') {
const formatter = new Intl.DateTimeFormat(locale, {
year: 'numeric',
month: 'long',
day: 'numeric'
});
return formatter.formatRange(startDate, endDate);
}
// ํตํ ๋ณํ ๋ฐ ํ์ํ
static formatCurrency(amount, fromCurrency, toCurrency, locale = 'ko-KR') {
// ์ค์ ๋ก๋ ํ์จ API๋ฅผ ์ฌ์ฉํด์ผ ํฉ๋๋ค
// ์ฌ๊ธฐ์๋ ์์๋ก ๊ฐ๋จํ ๊ตฌํ
const formatter = new Intl.NumberFormat(locale, {
style: 'currency',
currency: toCurrency
});
return formatter.format(amount);
}
// ์๋ ์๊ฐ (์ค๋งํธ ๋ฒ์ )
static formatSmartRelativeTime(date, locale = 'ko-KR') {
const now = new Date();
const diff = date - now;
const absDiff = Math.abs(diff);
const minute = 60 * 1000;
const hour = 60 * minute;
const day = 24 * hour;
const week = 7 * day;
const month = 30 * day;
const year = 365 * day;
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });
if (absDiff < minute) {
return rtf.format(Math.round(diff / 1000), 'second');
} else if (absDiff < hour) {
return rtf.format(Math.round(diff / minute), 'minute');
} else if (absDiff < day) {
return rtf.format(Math.round(diff / hour), 'hour');
} else if (absDiff < week) {
return rtf.format(Math.round(diff / day), 'day');
} else if (absDiff < month) {
return rtf.format(Math.round(diff / week), 'week');
} else if (absDiff < year) {
return rtf.format(Math.round(diff / month), 'month');
} else {
return rtf.format(Math.round(diff / year), 'year');
}
}
// ์ ๋ ฌ ํจ์ ์์ฑ
static createSorter(locale = 'ko-KR', options = {}) {
const collator = new Intl.Collator(locale, options);
return (a, b) => collator.compare(a, b);
}
}
// ์ฌ์ฉ ์์
console.log(I18nUtils.getUserLocale());
// ์ถ๋ ฅ: ko-KR (์ฌ์ฉ์ ๋ธ๋ผ์ฐ์ ์ค์ ์ ๋ฐ๋ผ)
console.log(I18nUtils.formatCompactNumber(1234567));
// ์ถ๋ ฅ: 123๋ง
console.log(I18nUtils.formatFileSize(1536000));
// ์ถ๋ ฅ: 1.46MB
const start = new Date('2024-01-15');
const end = new Date('2024-01-20');
console.log(I18nUtils.formatDateRange(start, end));
// ์ถ๋ ฅ: 2024๋
1์ 15์ผ~20์ผ
const pastDate = new Date(Date.now() - 2 * 60 * 60 * 1000);
console.log(I18nUtils.formatSmartRelativeTime(pastDate));
// ์ถ๋ ฅ: 2์๊ฐ ์
const names = ['์ต์งํ', '๊น์ฒ ์', '์ด์ํฌ', '๋ฐ๋ฏผ์'];
const sorter = I18nUtils.createSorter('ko-KR');
console.log(names.sort(sorter));
// ์ถ๋ ฅ: ['๊น์ฒ ์', '๋ฐ๋ฏผ์', '์ด์ํฌ', '์ต์งํ']
๐ ํ์ต ๋ก๋๋งต๊ณผ ์ถ๊ฐ ๋ฆฌ์์ค
์ฌ๊ธฐ๊น์ง ์ค์๋๋ผ ์๊ณ ๋ง์ผ์ จ์ด์! ๐ ์ด์ ์ด๋ป๊ฒ ๋ ๊ณต๋ถํ๋ฉด ์ข์์ง ๋ก๋๋งต์ ์๋ ค๋๋ฆด๊ฒ์.โข Intl.DateTimeFormat ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ ๋ง์คํฐ
โข Intl.NumberFormat์ผ๋ก ์ซ์/ํตํ ํ์ํ
โข ๋ก์ผ์ผ ๊ฐ๋ ์ดํดํ๊ธฐ
โข ๊ฐ๋จํ ๋ค๊ตญ์ด ํ์ด์ง ๋ง๋ค์ด๋ณด๊ธฐ
๐ฟ ์ค๊ธ (2-4์ฃผ)
โข Intl.RelativeTimeFormat ํ์ฉ
โข Intl.ListFormat๊ณผ Intl.DisplayNames ์ฌ์ฉ
โข ์ฑ๋ฅ ์ต์ ํ ๊ธฐ๋ฒ ์ ์ฉ
โข ์ค์ ํ๋ก์ ํธ์ ์ ์ฉํด๋ณด๊ธฐ
๐ณ ๊ณ ๊ธ (4์ฃผ ์ด์)
โข Intl.Collator๋ก ๋ณต์กํ ์ ๋ ฌ ๊ตฌํ
โข Intl.PluralRules๋ก ๋ค๊ตญ์ด ๋ฉ์์ง ์์คํ ๊ตฌ์ถ
โข ํ์์กด ์ฒ๋ฆฌ ์๋ฒฝ ์ดํด
โข ๋๊ท๋ชจ ๋ค๊ตญ์ด ์ ํ๋ฆฌ์ผ์ด์ ์ค๊ณ
์ถ์ฒ ํ์ต ์๋ฃ
โข ECMAScript Internationalization API Specification
โข Unicode CLDR (Common Locale Data Repository)
๐ ๏ธ ์ ์ฉํ ๋๊ตฌ
โข BCP 47 Language Tag Lookup
โข IANA Time Zone Database
โข ISO 4217 Currency Codes
๐ป ์ค์ต ํ๋ก์ ํธ ์์ด๋์ด
โข ๋ค๊ตญ์ด ๋ธ๋ก๊ทธ ํ๋ซํผ
โข ๊ตญ์ ์ ์์๊ฑฐ๋ ์ฌ์ดํธ
โข ๊ธ๋ก๋ฒ ์ด๋ฒคํธ ์์ฝ ์์คํ
โข ๋ค๊ตญ์ด ๋์๋ณด๋
โข ๊ตญ์ ๊ธ์ต ๊ณ์ฐ๊ธฐ
๐ก ๋ง์น๋ฉฐ
์! ์ ๋ง ๊ธด ์ฌ์ ์ด์์ฃ ? ๐ ํ์ง๋ง ์ด์ ์ฌ๋ฌ๋ถ์ JavaScript ๊ตญ์ ํ์ ๊ฑฐ์ ๋ชจ๋ ๊ฒ์ ์๊ฒ ๋์ จ์ด์!Intl ๊ฐ์ฒด๋ ์ ๋ง ๊ฐ๋ ฅํ ๋๊ตฌ์์. ์์ ์๋ ๋ค๊ตญ์ด ์ง์์ ์ํด ๋ณต์กํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ ์ง์ ๊ตฌํํด์ผ ํ์ง๋ง, ์ด์ ๋ ๋ธ๋ผ์ฐ์ ๊ฐ ๊ธฐ๋ณธ์ผ๋ก ์ ๊ณตํ๋ API๋ง์ผ๋ก๋ ์ถฉ๋ถํ ํ๋ฅญํ ๋ค๊ตญ์ด ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ง๋ค ์ ์์ด์. ๐
โ Intl.NumberFormat: ์ซ์, ํตํ, ํผ์ผํธ, ๋จ์ ํ์ํ
โ Intl.RelativeTimeFormat: "3์ผ ์ " ๊ฐ์ ์๋ ์๊ฐ ํํ
โ Intl.ListFormat: ๋ฐฐ์ด์ ์์ฐ์ค๋ฌ์ด ๋ฌธ์ฅ์ผ๋ก
โ Intl.DisplayNames: ์ธ์ด, ๊ตญ๊ฐ, ํตํ ์ด๋ฆ ํ์
โ Intl.Collator: ์ธ์ด๋ณ ์ ๋ ฌ ๊ท์น ์ ์ฉ
โ Intl.PluralRules: ๋ณต์ํ ๊ท์น ์ฒ๋ฆฌ
โ ์ฑ๋ฅ ์ต์ ํ: ํฌ๋งทํฐ ์ฌ์ฌ์ฉ๊ณผ ์บ์ฑ
โ ๋ธ๋ผ์ฐ์ ํธํ์ฑ: ํด๋ฐฑ ์ฒ๋ฆฌ ํ์
ํน์ ๋ ๊ถ๊ธํ ์ ์ด ์๊ฑฐ๋, ์ค๋ฌด์์ ๋งํ๋ ๋ถ๋ถ์ด ์๋ค๋ฉด ๊ฐ๋ฐ์ ์ปค๋ฎค๋ํฐ๋ ์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ์์ ๋์์ ๊ตฌํ๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ด์์. ํจ๊ป ์ฑ์ฅํ๋ ๊ฐ๋ฐ์๊ฐ ๋์ด๋ด์! ๐
์ฌ๋ฌ๋ถ์ ์ฝ๋๊ฐ ์ ์ธ๊ณ ์ด๋์๋ ์๋ฒฝํ๊ฒ ์๋ํ๊ธธ ๋ฐ๋ผ๋ฉฐ, ์ด๋ง ๊ธ์ ๋ง์น ๊ฒ์. ํ์ดํ ! ๐
๐ Happy Internationalizing! ๐
์ ์ธ๊ณ๊ฐ ์ฌ๋ฌ๋ถ์ ๋ฌด๋์ ๋๋ค!
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.