Skip to Content
14주차 · 접근성 & i18n

Accessibility & i18n

Build inclusive web applications with proper accessibility (A11y) and internationalization (i18n) support for global audiences.

WCAG 웹 접근성 기초

A11y

WCAG 2.1 핵심 4대 원칙과 접근성의 본질적 가치 이해

접근성이란?

Web Accessibility (A11y)

접근성은 단순히 장애를 위한 것이 아닙니다. 다양한 상황(저조도, 소음, 터치 제한, 모바일 환경 등)에서 모든 사용자가 제품의 기능을 동등하게 활용할 수 있게 하는 것입니다.

🌓저조도 환경
🔇소음 환경
🤚일시적 장애
📱모바일 사용

WCAG 2.1 핵심 4대 원칙

POUR 원칙
👁️

Perceivable

모든 사용자가 콘텐츠를 인지할 수 있어야 함

  • ✓대체 텍스트 제공 (이미지, 비디오 등)
  • ✓명도 대비(contrast) 4.5:1 이상 준수
  • ✓텍스트는 선택 가능하고 확대 가능해야 함
  • ✓자막 및 오디오 설명 제공

명도 대비 체커

명도 대비 데모
Aa
#767676 on #FFFFFF
✓ 4.54:1 (WCAG AA)
Aa
#999999 on #FFFFFF
✗ 2.85:1 (Fail)

WCAG AA 기준: 일반 텍스트 4.5:1, 큰 텍스트(18px+) 3:1 이상

접근성 테스트 도구

axe DevToolsEssential

가장 강력한 자동화 도구

LighthouseBuilt-in

Chrome 내장 성능/접근성 검사

WAVEVisual

시각적 접근성 평가

VoiceOver/NVDAManual

스크린리더 실제 테스트

시맨틱 HTML - 최강의 접근성 도구

HTML

접근성의 80%는 HTML을 올바르게 사용하는 것만으로 해결됩니다

시맨틱 태그의 중요성

왜 시맨틱 HTML인가?

시맨틱 HTML은 스크린리더와 검색 엔진이 페이지 구조를 이해하는 기반입니다. <div>와 <span>만 사용하면 보조 기술이 콘텐츠의 의미를 파악할 수 없습니다.

Interactive: Good vs Bad

Toggle to Compare
<!-- 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>
✓ 스크린리더가 landmark로 인식, 키보드 네비게이션 가능

핵심 시맨틱 요소

<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 - Page Title
h2 - Main Section 1
h3 - Subsection 1.1
h3 - Subsection 1.2
h2 - Main Section 2
h3 - Subsection 2.1

⚠️ h1 → h3처럼 레벨을 건너뛰지 마세요. 스크린리더 사용자는 heading 목록으로 페이지를 탐색합니다.

ARIA의 올바른 사용

WAI-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

아코디언 패턴
aria-expanded는 스크린리더에게 현재 요소가 확장되었는지 축소되었는지 알려줍니다. 토글 버튼, 아코디언, 드롭다운 메뉴 등에 필수적입니다.
aria-expanded="false"

Interactive: aria-live

Live Region 데모

버튼을 클릭하면 스크린리더가 알림을 읽어줍니다:

알림이 여기에 표시됩니다...
<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 AT

ARIA 안티패턴

✗<div role="button">Click</div>
✓<button>Click</button>

네이티브 요소에 이미 시맨틱이 있습니다

✗aria-hidden="true" on focusable element
✓먼저 요소를 탭 순서에서 제거합니다

보이지 않지만 포커스 가능한 요소가 만들어집니다

✗aria-label on <div> without role
✓적절한 role을 추가하거나 네이티브 요소를 사용합니다

aria-label은 특정 role에서만 동작합니다

포커스 관리

Focus

React SPA에서 가장 자주 깨지는 접근성 포인트

포커스 관리가 필요한 경우

포커스를 관리해야 하는 경우

  • 라우트 이동 시: 새 페이지의 첫 번째 heading으로 focus 이동
  • 모달 열릴 때:
    • 모달 내부 첫 요소로 focus 이동
    • 탭 이동이 모달 밖으로 빠져나가지 않도록 trap
    • 닫히면 기존 focus 위치로 복귀
  • 동적 콘텐츠: 새로 추가된 콘텐츠로 focus 이동

Interactive: Focus Trap Modal

클릭하여 모달 열기

모달이 열리면 Tab 키로 탐색해보세요. Focus가 모달 안에 갇힙니다(trap).

Focus Indicator Tracker

Tab 키로 버튼들을 이동해 보세요
포커스 기록:
Tab 키로 버튼을 이동해 보세요...

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, Dropdown
React Aria

Adobe의 접근성 컴포넌트

Full A11y Suite
Radix UI

접근성 내장 컴포넌트

Headless UI
@reach/ui

접근성 우선 컴포넌트

Modal, Tabs, etc.

국제화(i18n) 기초

i18n

글로벌 서비스를 위한 다국어 지원 아키텍처

국제화의 핵심 요소

🌐언어 (Translation)

텍스트 번역

📅날짜/시간

지역별 포맷 (MM/DD vs DD/MM)

💰숫자/통화

1,000 vs 1.000, $100 vs 100원

➡️RTL 지원

아랍어, 히브리어 등

📝복수형

1 item vs 2 items

🕐타임존

UTC, KST, PST 등

Interactive: 다국어 전환

실시간 번역 데모

안녕하세요

Kim님, 환영합니다!

1개의 아이템
현재 로케일: ko

ICU 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 기반 분리 (권장)

locales/
├── en/
│ ├── common.json
│ ├── auth.json
│ └── errors.json
└── ko/
├── common.json
├── auth.json
└── errors.json

번역 누락 체크

Jest + JSON Schema를 활용해 번역 키 누락을 CI에서 자동 검증하세요.

i18n 라이브러리 비교

라이브러리특징적합한 경우
react-intlICU 완벽 지원, FormatJS대규모 엔터프라이즈
i18next유연한 플러그인 시스템범용적 사용
next-intlNext.js 최적화Next.js 프로젝트

JavaScript Intl API

Intl

브라우저 내장 국제화 API로 날짜, 숫자, 통화 포맷팅

Intl API Overview

Built-in Internationalization

JavaScript의 Intl 객체는 브라우저에 내장된 강력한 국제화 API입니다. 라이브러리 없이도 날짜, 숫자, 통화, 복수형 등을 로케일에 맞게 포맷팅할 수 있습니다.

Interactive: 로케일별 포맷팅

로케일을 선택해 차이를 확인하세요

NumberFormat

숫자:1,234,567.89
USD:US$1,234,567.89
KRW:₩1,234,568
EUR:€1,234,567.89

DateTimeFormat

Short:25. 3. 14.
Medium:2025. 3. 14.
Long:2025년 3월 14일
Time:오후 03:30:45

RelativeTimeFormat

어제오늘내일2주 전3개월 후

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.ListFormat
new Intl.ListFormat("en").format(["a", "b", "c"])
→ "a, b, and c"
Intl.PluralRules
new Intl.PluralRules("en").select(1)
→ "one"
Intl.Collator
["ä", "a", "z"].sort(new Intl.Collator("de").compare)
→ ["a", "ä", "z"]
Intl.Segmenter
텍스트를 단어/문장 단위로 분할
→ 텍스트 분석

RTL (Right-to-Left) 지원

RTL

아랍어, 히브리어 등 RTL 언어를 위한 필수 기능

RTL이 필요한 언어

RTL 언어

약 4억 명 이상의 사용자가 RTL 언어를 사용합니다. 글로벌 서비스라면 반드시 고려해야 합니다.

Arabic (العربية) (310M+)
Hebrew (עברית) (9M+)
Persian (فارسی) (110M+)
Urdu (اردو) (70M+)

Interactive: LTR vs RTL

방향 전환
👤

홍길동

프론트엔드 개발자

왼쪽에서 오른쪽으로 읽는 텍스트의 예시입니다.

dir="ltr" - 텍스트 방향, margin, padding, 정렬 모두 변경됨

CSS Logical Properties

방향에 독립적인 CSS

CSS Logical Properties를 사용하면 LTR/RTL을 자동으로 처리합니다. left/right 대신 start/end를 사용하세요.

✗ Physical (Avoid)

margin-left: 1rem;
padding-right: 1rem;
text-align: left;
border-left: 1px solid;

✓ Logical (Use)

margin-inline-start: 1rem;
padding-inline-end: 1rem;
text-align: start;
border-inline-start: 1px solid;

Logical Properties 매핑

PhysicalLogicalLTRRTL
leftinline-startleftright
rightinline-endrightleft
margin-leftmargin-inline-startleftright
padding-rightpadding-inline-endrightleft
border-leftborder-inline-startleftright
text-align: lefttext-align: startleftright

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 */}

RTL 구현 체크리스트

✓<html dir="rtl" lang="ar"> 설정
✓CSS Logical Properties 사용
✓아이콘 방향 미러링 (←→ 화살표 등)
○양방향 텍스트(Bidi) 처리
✓숫자/전화번호는 LTR 유지
○애니메이션 방향 반전
마지막 업데이트