Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("invalid language code")
ErrInvalid indicates an invalid language code was specified.
Functions ¶
func BaseCode ¶
BaseCode extracts the ISO 639-1 base language code from a locale. OpenAI's transcription API only accepts base codes, not regional variants. Examples: "pt-BR" -> "pt", "zh-CN" -> "zh", "en" -> "en"
func DisplayName ¶
DisplayName returns a human-readable name for a language code. Lookup order: exact locale match -> base language -> original code. Returns empty string for empty input. Used in the restructuring prompt instruction.
func IsEnglish ¶
IsEnglish returns true if the language code represents English. Used to skip the output language instruction when output is English (since templates are already in English).
func Normalize ¶
Normalize normalizes a language code to lowercase with hyphen separator. Converts underscores to hyphens and lowercases the entire string. Does not trim whitespace or validate format. Examples: "pt-BR" -> "pt-br", "pt_BR" -> "pt-br", "PT-BR" -> "pt-br"
func Validate ¶
Validate checks if the language code is valid. Accepts ISO 639-1 codes (e.g., "en", "fr") or locales with valid base (e.g., "pt-BR", "zh-CN"). Only the base code is validated; regional suffixes are ignored. Returns nil for empty string (auto-detect mode). Returns ErrInvalid if the base language is not recognized.
Types ¶
This section is empty.