Add English skill locale support (#223)
feat: add English skill locale support with SKILL_en.md
This commit is contained in:
+26
-4
@@ -326,8 +326,30 @@ def _install_skill():
|
||||
import shutil
|
||||
import importlib.resources
|
||||
|
||||
def _is_english_locale(value: str) -> bool:
|
||||
normalized = value.strip().lower()
|
||||
return normalized.startswith("en") or normalized.startswith("english")
|
||||
|
||||
def _skill_resource_name() -> str:
|
||||
locale_candidates = (
|
||||
os.environ.get("AGENT_REACH_LANG", ""),
|
||||
os.environ.get("LC_ALL", ""),
|
||||
os.environ.get("LC_MESSAGES", ""),
|
||||
os.environ.get("LANG", ""),
|
||||
)
|
||||
if any(_is_english_locale(candidate) for candidate in locale_candidates):
|
||||
return "SKILL_en.md"
|
||||
return "SKILL.md"
|
||||
|
||||
def _read_skill_markdown(skill_pkg):
|
||||
resource_name = _skill_resource_name()
|
||||
try:
|
||||
return skill_pkg.joinpath(resource_name).read_text(encoding="utf-8")
|
||||
except FileNotFoundError:
|
||||
return skill_pkg.joinpath("SKILL.md").read_text(encoding="utf-8")
|
||||
|
||||
def _copy_skill_dir(target: str) -> bool:
|
||||
"""Copy entire skill directory (SKILL.md + references/)."""
|
||||
"""Copy entire skill directory (locale-specific SKILL.md + references/)."""
|
||||
try:
|
||||
# Clear existing installation
|
||||
if os.path.exists(target):
|
||||
@@ -337,13 +359,13 @@ def _install_skill():
|
||||
# Get skill directory from package (with fallback for editable installs)
|
||||
try:
|
||||
skill_pkg = importlib.resources.files("agent_reach").joinpath("skill")
|
||||
skill_md = skill_pkg.joinpath("SKILL.md").read_text(encoding="utf-8")
|
||||
skill_md = _read_skill_markdown(skill_pkg)
|
||||
except Exception:
|
||||
from pathlib import Path
|
||||
skill_pkg = Path(__file__).resolve().parent / "skill"
|
||||
skill_md = (skill_pkg / "SKILL.md").read_text(encoding="utf-8")
|
||||
skill_md = _read_skill_markdown(skill_pkg)
|
||||
|
||||
# Copy SKILL.md
|
||||
# Copy SKILL.md using the selected locale file
|
||||
with open(os.path.join(target, "SKILL.md"), "w", encoding="utf-8") as f:
|
||||
f.write(skill_md)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user