locale

package
v1.5.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package locale provides cross-platform language detection and translation.

Detection priority:

  1. CCL_LANG environment variable
  2. ~/.ccl/config.yaml lang field
  3. OS-level language setting (via environment on Unix, Win32 API on Windows)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaudeCodeLanguageName added in v1.5.7

func ClaudeCodeLanguageName(code string) string

ClaudeCodeLanguageName maps a ccl locale to the natural-language name that Claude Code's `language` setting expects (e.g. "中文" for zh-CN). This lives in locale — the package that owns language display names — because internal/ packages outside locale must not hold Chinese string literals.

func Current

func Current() string

Current returns the current full locale code (e.g. "zh-CN", "en-US").

func IsChinese

func IsChinese() bool

IsChinese returns true when the current language is a Chinese variant.

func SetLanguage

func SetLanguage(code string) string

SetLanguage overrides the language at runtime and returns the canonical form.

func T

func T(zh, en string) string

T returns the Chinese or English string based on the current language. Call: T("中文文本", "English text")

func Tf

func Tf(zhPattern, enPattern string, args ...any) string

Tf is like T but supports fmt.Sprintf formatting. Call: Tf("中文 %s 模板", "English %s template", arg)

Types

type LanguageManager

type LanguageManager struct {
	// contains filtered or unexported fields
}

LanguageManager manages the current language and provides translations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL