Accessibility & i18n
Build inclusive web applications with proper accessibility (A11y) and internationalization (i18n) support for global audiences.
WCAG 웹 접근성 기초
WCAG 2.1 핵심 4대 원칙과 접근성의 본질적 가치 이해
접근성이란?
Web Accessibility (A11y)
접근성은 단순히 장애를 위한 것이 아닙니다. 다양한 상황(저조도, 소음, 터치 제한, 모바일 환경 등)에서 모든 사용자가 제품의 기능을 동등하게 활용할 수 있게 하는 것입니다.
WCAG 2.1 핵심 4대 원칙
Perceivable
모든 사용자가 콘텐츠를 인지할 수 있어야 함
- ✓대체 텍스트 제공 (이미지, 비디오 등)
- ✓명도 대비(contrast) 4.5:1 이상 준수
- ✓텍스트는 선택 가능하고 확대 가능해야 함
- ✓자막 및 오디오 설명 제공
명도 대비 체커
WCAG AA 기준: 일반 텍스트 4.5:1, 큰 텍스트(18px+) 3:1 이상
접근성 테스트 도구
가장 강력한 자동화 도구
Chrome 내장 성능/접근성 검사
시각적 접근성 평가
스크린리더 실제 테스트
시맨틱 HTML - 최강의 접근성 도구
접근성의 80%는 HTML을 올바르게 사용하는 것만으로 해결됩니다
시맨틱 태그의 중요성
왜 시맨틱 HTML인가?
시맨틱 HTML은 스크린리더와 검색 엔진이 페이지 구조를 이해하는 기반입니다. <div>와 <span>만 사용하면 보조 기술이 콘텐츠의 의미를 파악할 수 없습니다.
Interactive: Good vs Bad
<!-- Good: Semantic HTML -->
<header>
<nav>
<a href="/">Home</a>
<a href="/about">About</a>
</nav>
</header>
<main>
<article>
<h1>Article Title</h1>
<p>Article content...</p>
</article>
</main>
<footer>
© 2024 My Site
</footer>핵심 시맨틱 요소
<button><div onclick>클릭 가능한 액션
<a href><span onclick>페이지 이동 링크
<label for><span>폼 필드 레이블
<nav><div class="nav">내비게이션 영역
<main><div class="main">주요 콘텐츠 영역
<header>/<footer><div>페이지/섹션 헤더/푸터
폼 접근성
<!-- Accessible Form Pattern -->
<form>
<fieldset>
<legend>Personal Information</legend>
<div>
<label for="name">Name (required)</label>
<input
type="text"
id="name"
name="name"
required
aria-describedby="name-hint"
/>
<span id="name-hint">Enter your full name</span>
</div>
<div>
<label for="email">Email</label>
<input
type="email"
id="email"
name="email"
aria-invalid="true"
aria-describedby="email-error"
/>
<span id="email-error" role="alert">
Please enter a valid email address
</span>
</div>
</fieldset>
<button type="submit">Submit</button>
</form>- • for와 id로 레이블 연결 필수
- • fieldset과 legend로 그룹화
- • aria-describedby로 힌트/에러 연결
Heading 계층 구조
⚠️ h1 → h3처럼 레벨을 건너뛰지 마세요. 스크린리더 사용자는 heading 목록으로 페이지를 탐색합니다.
ARIA의 올바른 사용
HTML을 먼저 쓰고, ARIA는 없는 기능을 보완하는 기술
ARIA의 첫 번째 규칙
ARIA의 첫 번째 규칙
"ARIA를 사용하지 않아도 된다면, 사용하지 마세요."
네이티브 HTML 요소가 이미 접근성을 제공합니다. ARIA는 HTML로 표현할 수 없는 기능(예: 커스텀 컴포넌트)에만 사용하세요. ARIA를 남용하면 접근성이 악화됩니다.
자주 쓰는 ARIA 속성
role요소의 역할 정의
role="dialog", role="alert", role="tablist"
aria-label접근 가능한 이름 제공
aria-label="Close menu"
aria-labelledby다른 요소의 ID로 이름 참조
aria-labelledby="modal-title"
aria-describedby추가 설명 연결
aria-describedby="password-hint"
aria-expanded확장/축소 상태
aria-expanded="true"
aria-live동적 콘텐츠 알림
aria-live="polite"
Interactive: aria-expanded
Interactive: aria-live
버튼을 클릭하면 스크린리더가 알림을 읽어줍니다:
<div
role="status"
aria-live="polite"
aria-atomic="true"
>
{notification}
</div>모달 다이얼로그 패턴
// Accessible Modal Pattern
<div
role="dialog"
aria-modal="true"
aria-labelledby="modal-title"
aria-describedby="modal-description"
>
<h2 id="modal-title">Confirm Delete</h2>
<p id="modal-description">
Are you sure you want to delete this item?
</p>
<button>Cancel</button>
<button>Delete</button>
</div>
// Required behaviors:
// 1. Focus trap inside modal
// 2. ESC key closes modal
// 3. Return focus to trigger on close
// 4. Background content hidden from ATARIA 안티패턴
<div role="button">Click</div><button>Click</button>네이티브 요소에 이미 시맨틱이 있습니다
aria-hidden="true" on focusable element먼저 요소를 탭 순서에서 제거합니다보이지 않지만 포커스 가능한 요소가 만들어집니다
aria-label on <div> without role적절한 role을 추가하거나 네이티브 요소를 사용합니다aria-label은 특정 role에서만 동작합니다
포커스 관리
React SPA에서 가장 자주 깨지는 접근성 포인트
포커스 관리가 필요한 경우
포커스를 관리해야 하는 경우
- 라우트 이동 시: 새 페이지의 첫 번째 heading으로 focus 이동
- 모달 열릴 때:
- 모달 내부 첫 요소로 focus 이동
- 탭 이동이 모달 밖으로 빠져나가지 않도록 trap
- 닫히면 기존 focus 위치로 복귀
- 동적 콘텐츠: 새로 추가된 콘텐츠로 focus 이동
Interactive: Focus Trap Modal
모달이 열리면 Tab 키로 탐색해보세요. Focus가 모달 안에 갇힙니다(trap).
Focus Indicator Tracker
Focus Trap 구현
// React Focus Trap Hook
import { useEffect, useRef } from 'react';
function useFocusTrap(isActive: boolean) {
const containerRef = useRef<HTMLElement>(null);
useEffect(() => {
if (!isActive || !containerRef.current) return;
const focusable = containerRef.current.querySelectorAll(
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
);
const first = focusable[0] as HTMLElement;
const last = focusable[focusable.length - 1] as HTMLElement;
// Focus first element
first?.focus();
const handleTab = (e: KeyboardEvent) => {
if (e.key !== 'Tab') return;
if (e.shiftKey && document.activeElement === first) {
e.preventDefault();
last?.focus();
} else if (!e.shiftKey && document.activeElement === last) {
e.preventDefault();
first?.focus();
}
};
document.addEventListener('keydown', handleTab);
return () => document.removeEventListener('keydown', handleTab);
}, [isActive]);
return containerRef;
}라이브러리 추천
focus-trap-react경량 Focus Trap 라이브러리
Modal, DropdownReact AriaAdobe의 접근성 컴포넌트
Full A11y SuiteRadix UI접근성 내장 컴포넌트
Headless UI@reach/ui접근성 우선 컴포넌트
Modal, Tabs, etc.국제화(i18n) 기초
글로벌 서비스를 위한 다국어 지원 아키텍처
국제화의 핵심 요소
텍스트 번역
지역별 포맷 (MM/DD vs DD/MM)
1,000 vs 1.000, $100 vs 100원
아랍어, 히브리어 등
1 item vs 2 items
UTC, KST, PST 등
Interactive: 다국어 전환
안녕하세요
Kim님, 환영합니다!
koICU Message Format
업계 표준
ICU Message Format은 복수형, 선택형 메시지 처리의 업계 표준입니다.
// ICU Message Format Examples
// Pluralization
{count, plural,
=0 {No items}
one {# item}
other {# items}
}
// Select
{gender, select,
male {He likes this}
female {She likes this}
other {They like this}
}
// Nested
{count, plural,
=0 {No messages}
one {{name} sent you a message}
other {{name} sent you # messages}
}Next.js i18n 구조
// App Router: [locale]/layout.tsx
import { getDictionary } from './dictionaries';
export default async function Layout({
children,
params: { locale }
}: {
children: React.ReactNode;
params: { locale: string };
}) {
const dict = await getDictionary(locale);
return (
<html lang={locale}>
<body>
<I18nProvider dictionary={dict} locale={locale}>
{children}
</I18nProvider>
</body>
</html>
);
}
// dictionaries.ts
const dictionaries = {
en: () => import('./dictionaries/en.json').then((m) => m.default),
ko: () => import('./dictionaries/ko.json').then((m) => m.default),
};
export const getDictionary = async (locale: string) =>
dictionaries[locale as keyof typeof dictionaries]();번역 파일 관리 전략
Namespace 기반 분리 (권장)
번역 누락 체크
Jest + JSON Schema를 활용해 번역 키 누락을 CI에서 자동 검증하세요.
i18n 라이브러리 비교
| 라이브러리 | 특징 | 적합한 경우 |
|---|---|---|
| react-intl | ICU 완벽 지원, FormatJS | 대규모 엔터프라이즈 |
| i18next | 유연한 플러그인 시스템 | 범용적 사용 |
| next-intl | Next.js 최적화 | Next.js 프로젝트 |
JavaScript Intl API
브라우저 내장 국제화 API로 날짜, 숫자, 통화 포맷팅
Intl API Overview
Built-in Internationalization
JavaScript의 Intl 객체는 브라우저에 내장된 강력한 국제화 API입니다. 라이브러리 없이도 날짜, 숫자, 통화, 복수형 등을 로케일에 맞게 포맷팅할 수 있습니다.
Interactive: 로케일별 포맷팅
NumberFormat
DateTimeFormat
RelativeTimeFormat
Intl.NumberFormat
// Basic number formatting
new Intl.NumberFormat('de-DE').format(1234567.89)
// → "1.234.567,89"
new Intl.NumberFormat('en-US').format(1234567.89)
// → "1,234,567.89"
// Currency formatting
new Intl.NumberFormat('ko-KR', {
style: 'currency',
currency: 'KRW'
}).format(15000)
// → "₩15,000"
new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(99.99)
// → "$99.99"
// Percentage
new Intl.NumberFormat('en-US', {
style: 'percent',
minimumFractionDigits: 1
}).format(0.856)
// → "85.6%"
// Compact notation
new Intl.NumberFormat('en-US', {
notation: 'compact',
compactDisplay: 'short'
}).format(1500000)
// → "1.5M"Intl.DateTimeFormat
// Date formatting
new Intl.DateTimeFormat('ko-KR').format(new Date())
// → "2024. 1. 15."
new Intl.DateTimeFormat('en-US', {
dateStyle: 'full',
timeStyle: 'long'
}).format(new Date())
// → "Monday, January 15, 2024 at 3:30:00 PM GMT+9"
// Custom format
new Intl.DateTimeFormat('en-US', {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
timeZone: 'Asia/Seoul'
}).format(new Date())
// Intl.RelativeTimeFormat
new Intl.RelativeTimeFormat('ko', { numeric: 'auto' })
.format(-1, 'day')
// → "어제"
new Intl.RelativeTimeFormat('en', { numeric: 'auto' })
.format(-1, 'day')
// → "yesterday"기타 유용한 Intl API
Intl.ListFormatIntl.PluralRulesIntl.CollatorIntl.SegmenterRTL (Right-to-Left) 지원
아랍어, 히브리어 등 RTL 언어를 위한 필수 기능
RTL이 필요한 언어
RTL 언어
약 4억 명 이상의 사용자가 RTL 언어를 사용합니다. 글로벌 서비스라면 반드시 고려해야 합니다.
Interactive: LTR vs RTL
홍길동
프론트엔드 개발자
왼쪽에서 오른쪽으로 읽는 텍스트의 예시입니다.
dir="ltr" - 텍스트 방향, margin, padding, 정렬 모두 변경됨CSS Logical Properties
방향에 독립적인 CSS
CSS Logical Properties를 사용하면 LTR/RTL을 자동으로 처리합니다. left/right 대신 start/end를 사용하세요.
✗ Physical (Avoid)
✓ Logical (Use)
Logical Properties 매핑
| Physical | Logical | LTR | RTL |
|---|---|---|---|
| left | inline-start | left | right |
| right | inline-end | right | left |
| margin-left | margin-inline-start | left | right |
| padding-right | padding-inline-end | right | left |
| border-left | border-inline-start | left | right |
| text-align: left | text-align: start | left | right |
Tailwind CSS RTL 지원
// tailwind.config.js
module.exports = {
// Enable RTL variants
plugins: [
require('tailwindcss-rtl'),
],
}
// Usage with RTL plugin
<div className="ms-4"> {/* margin-inline-start */}
<div className="me-4"> {/* margin-inline-end */}
<div className="ps-4"> {/* padding-inline-start */}
<div className="pe-4"> {/* padding-inline-end */}
<div className="start-0"> {/* inset-inline-start */}
<div className="end-0"> {/* inset-inline-end */}
// Or use built-in Tailwind v3+ logical properties
<div className="text-start"> {/* text-align: start */}
<div className="text-end"> {/* text-align: end */}
<div className="float-start"> {/* float: inline-start */}
<div className="float-end"> {/* float: inline-end */}