Conversation
Add metagpt/locale for CLI strings, --language fa / METAGPT_LANG support, config language docs, RoleZero Persian detection, requirement analysis example, and locale tests. Refs FoundationAgents#2113
This was referenced Jul 23, 2026
Author
|
Companion docs PR: #2114 |
There was a problem hiding this comment.
Pull request overview
Adds a lightweight runtime localization layer to MetaGPT to support Persian (Farsi) for CLI/user-facing strings, plus improved RoleZero language detection guidance and examples. This aligns with issue #2113’s “PR 2 — Runtime / CLI” scope (opt-in Persian via config/CLI/env, no gettext/Babel).
Changes:
- Introduces
metagpt/locale/with message catalogs, language alias normalization, and at()translation helper. - Localizes key CLI + human-interaction prompts, and adds
--language/METAGPT_LANGplumbing plus config documentation. - Improves RoleZero language-detection prompt to recognize Persian/Farsi/فارسی, and adds unit tests for alias normalization and message lookup.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/metagpt/test_locale.py |
Adds unit tests for locale normalization + message lookup. |
metagpt/utils/human_interaction.py |
Switches human-interaction prompts/logs to localized message keys. |
metagpt/software_company.py |
Adds CLI --language support and localizes CLI help/errors/config init messages. |
metagpt/roles/di/role_zero.py |
Adds default-language guidance + Persian fallback logic for language detection. |
metagpt/prompts/di/role_zero.py |
Updates detection prompt to recognize Persian/Farsi/فارسی and accept a default language hint. |
metagpt/locale/messages.py |
Defines message catalogs and normalize_language() alias mapping. |
metagpt/locale/__init__.py |
Provides locale initialization + global language state and t() lookup. |
metagpt/actions/analyze_requirements.py |
Adds a Persian example to requirement-analysis prompts. |
config/config2.example.yaml |
Documents language field and Persian aliases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+45
to
+49
| if language: | ||
| config.language = set_language(language) | ||
| else: | ||
| init_locale(config.language) | ||
|
|
Comment on lines
+210
to
+217
| default_language = self.config.language or "English" | ||
| detect_language_prompt = DETECT_LANGUAGE_PROMPT.format( | ||
| requirement=self.planner.plan.goal, | ||
| default_language=default_language, | ||
| ) | ||
| self.respond_language = await self.llm.aask(detect_language_prompt) | ||
| if default_language == "Persian" and self.respond_language.strip().lower() in ("english", ""): | ||
| self.respond_language = "Persian" |
Comment on lines
+4
to
+6
| from metagpt.locale import init_locale, set_language, t | ||
| from metagpt.locale.messages import normalize_language | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Features
metagpt/locale/module for CLI and human-interaction strings--language faCLI flag andMETAGPT_LANGenv var supportlanguagefield inconfig/config2.example.yamltests/metagpt/test_locale.py)Feature Docs
Influence
Result
tests/metagpt/test_locale.pycovers Persian alias normalization and message lookupRefs #2113
Other