Skip to content
API Reference

@hua-labs/i18n-core

v1.0.0-alpha

타입 안전한 국제화 시스템. SSR 지원, 네임스페이스 기반.

Installation

pnpm add @hua-labs/i18n-core

Main Exports

import {
  // Hooks
  useTranslation,      // Main translation hook
  useLanguage,         // Language state hook

  // Provider
  I18nProvider,        // Context provider

  // Store
  createI18nStore,     // Create i18n store (Zustand)

  // Types
  type Language,
  type TranslationNamespace,
  type I18nConfig,
} from '@hua-labs/i18n-core';

useTranslation Hook

const { t, language, setLanguage, isLoading } = useTranslation();

// Basic translation
t("common:greeting")  // "Hello"

// With namespace
t("docs:components.button.title")  // "Button"

// With interpolation
t("common:welcome", { name: "John" })  // "Welcome, John!"

// Change language
setLanguage("ko");

Translation File Structure

public/
└── translations/
    ├── en/
       ├── common.json
       └── docs.json
    └── ko/
        ├── common.json
        └── docs.json

Configuration

// hua-ux.config.ts
export default {
  i18n: {
    defaultLanguage: "en",
    supportedLanguages: ["en", "ko", "ja"],
    namespaces: ["common", "docs", "errors"],
    translationsPath: "/translations",
    ssr: true,
  },
}

Features

  • SSR Support - 서버에서 번역 프리로드
  • Namespace 기반 - 번역 파일 분리 관리
  • Auto language detection - 브라우저 언어 감지
  • Persistent - localStorage에 언어 설정 저장
  • TypeScript - 타입 안전한 번역 키

상세 API 문서는 별도 문서 사이트에서 제공 예정.