Advanced

Internationalization (i18n)

Multilingual support in gh-please

Internationalization (i18n)

gh-please supports multilingual output with automatic system language detection.

Supported Languages

  • Korean (ko) - Full support
  • English (en) - Default and fallback

Automatic Language Detection

The CLI automatically detects your system language from environment variables:

  1. LANG
  2. LANGUAGE
  3. LC_ALL

If any variable starts with ko, Korean messages are displayed. Otherwise, English is used.

Examples

Korean Output

LANG=ko_KR.UTF-8 gh please issue sub-issue list 123

Output:

πŸ” μƒμœ„ 이슈 #123 κ°€μ Έμ˜€λŠ” 쀑...
βœ… μ„±κ³΅μ μœΌλ‘œ ν•˜μœ„ 이슈λ₯Ό μ‘°νšŒν–ˆμŠ΅λ‹ˆλ‹€.

μƒμœ„ 이슈 #123의 ν•˜μœ„ 이슈:
βœ… #124 - 검증 둜직 μΆ”κ°€ (CLOSED)
πŸ”΅ #125 - ν…ŒμŠ€νŠΈ μ—…λ°μ΄νŠΈ (OPEN)

English Output

LANG=en_US.UTF-8 gh please issue sub-issue list 123

Output:

πŸ” Getting parent issue #123...
βœ… Successfully retrieved sub-issues.

Sub-issues of #123:
βœ… #124 - Add validation (CLOSED)
πŸ”΅ #125 - Update tests (OPEN)

Command Messages

All user-facing messages are internationalized:

Success Messages

// Korean
msg.success.subIssueCreated(101, 100)
// "βœ… ν•˜μœ„ 이슈 #101이 μ„±κ³΅μ μœΌλ‘œ μƒμ„±λ˜κ³  #100에 μ—°κ²°λ˜μ—ˆμŠ΅λ‹ˆλ‹€."

// English
msg.success.subIssueCreated(101, 100)
// "βœ… Sub-issue #101 created and linked to #100 successfully."

Error Messages

// Korean
msg.error.issueNotFound(123)
// "❌ 이슈 #123을 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."

// English
msg.error.issueNotFound(123)
// "❌ Issue #123 not found."

Progress Messages

// Korean
msg.progress.gettingIssue(123)
// "πŸ” 이슈 #123 κ°€μ Έμ˜€λŠ” 쀑..."

// English
msg.progress.gettingIssue(123)
// "πŸ” Getting issue #123..."

Implementation

Message Structure

Messages are organized by command group:

// src/lib/i18n.ts
export function getIssueMessages(lang: Language) {
  return {
    progress: {
      gettingParentIssue: (num: number) =>
        lang === 'ko'
          ? `πŸ” μƒμœ„ 이슈 #${num} κ°€μ Έμ˜€λŠ” 쀑...`
          : `πŸ” Getting parent issue #${num}...`,
    },
    success: {
      subIssueCreated: (child: number, parent: number) =>
        lang === 'ko'
          ? `βœ… ν•˜μœ„ 이슈 #${child}이 μ„±κ³΅μ μœΌλ‘œ μƒμ„±λ˜κ³  #${parent}에 μ—°κ²°λ˜μ—ˆμŠ΅λ‹ˆλ‹€.`
          : `βœ… Sub-issue #${child} created and linked to #${parent} successfully.`,
    },
    error: {
      issueNotFound: (num: number) =>
        lang === 'ko'
          ? `❌ 이슈 #${num}을 찾을 수 μ—†μŠ΅λ‹ˆλ‹€.`
          : `❌ Issue #${num} not found.`,
    },
  }
}

Usage in Commands

import { detectSystemLanguage, getIssueMessages } from '../../lib/i18n'

const lang = detectSystemLanguage()
const msg = getIssueMessages(lang)

console.log(msg.progress.gettingParentIssue(123))

Coverage

Internationalized

βœ… All command output messages βœ… Success messages βœ… Error messages βœ… Progress indicators βœ… Help text and descriptions

Not Internationalized

⚠️ GitHub API URLs ⚠️ Git output ⚠️ JSON/XML structured output ⚠️ Technical error stack traces

Force Language

You can force a specific language by setting the environment variable:

# Force Korean
LANG=ko_KR.UTF-8 gh please issue sub-issue list 123

# Force English
LANG=en_US.UTF-8 gh please issue sub-issue list 123

# Also works with LANGUAGE
LANGUAGE=ko gh please issue sub-issue list 123

Adding New Languages

To add support for a new language:

  1. Update the Language type in src/types.ts:
    export type Language = 'ko' | 'en' | 'ja' // Add 'ja' for Japanese
    
  2. Update language detection in src/lib/i18n.ts:
    export function detectSystemLanguage(): Language {
      const lang = process.env.LANG || process.env.LANGUAGE || process.env.LC_ALL || 'en'
      if (lang.startsWith('ko'))
        return 'ko'
      if (lang.startsWith('ja'))
        return 'ja' // Add Japanese
      return 'en'
    }
    
  3. Add translations to message functions:
    export function getIssueMessages(lang: Language) {
      return {
        progress: {
          gettingParentIssue: (num: number) => {
            if (lang === 'ko')
              return `πŸ” μƒμœ„ 이슈 #${num} κ°€μ Έμ˜€λŠ” 쀑...`
            if (lang === 'ja')
              return `πŸ” θ¦ͺγ‚€γ‚·γƒ₯γƒΌ #${num} を取得中...`
            return `πŸ” Getting parent issue #${num}...`
          },
        },
      }
    }