Engineering
go-i18n avatar

go-i18n

Manage Go CLI i18n rules, locale file structures, env-based language detection, and string key naming conventions for the Skills-X ecosystem.

Introduction

The go-i18n skill provides a standardized framework for managing internationalization within the Skills-X CLI. It is designed for developers who need to add user-facing strings, translate CLI output, or update existing language files while maintaining repository consistency. By centralizing language detection and translation logic, this skill ensures that all CLI commands support dynamic language switching, essential for global accessibility in developer toolchains.

  • Automates language detection priority using SKILLS_LANG, LANG, and LC_ALL environment variables.

  • Defines strict key naming conventions using category prefixes like app_, cmd_, list_, init_, and err_ to prevent collision and maintain readability.

  • Implements a dual-file locale system (zh.yaml and en.yaml) that must be kept in sync for every new string addition.

  • Integrates with Go embed directives to bundle translation data directly into the binary at build time, ensuring fast, dependency-free runtime performance.

  • Provides helper functions i18n.T and i18n.Tf for simple string retrieval and formatted message injection.

  • Always initialize the i18n module early in the application startup sequence using i18n.MustInit().

  • Add new translations to both zh.yaml and en.yaml simultaneously; missing keys will return the raw key name, which acts as a built-in debug mechanism.

  • Strictly avoid mixing Chinese and English within a single translation key; split strings into separate components if necessary.

  • Remember to execute a full rebuild (make build) after modifying any YAML configuration to ensure changes are correctly embedded.

  • Use the provided test commands with the SKILLS_LANG environment variable to verify that strings correctly switch between supported locales before merging.

Repository Stats

Stars
18
Forks
1
Open Issues
0
Language
Go
Default Branch
main
Sync Status
Idle
Last Synced
May 3, 2026, 05:42 PM
View on GitHub