Repository navigation
Conversation
The Cloak persistent context was launched with a hardcoded locale="zh-CN", so every site the browser rendered appeared in Chinese regardless of the user's own language. The launch code already reads other runtime settings from the Agent Reach config (see the proxy option), so the locale belongs there too. The locale can now be set with the browser_locale config key or the BROWSER_LOCALE environment variable, e.g. en-US or de-DE. The default stays zh-CN, so existing setups keep their current behaviour. Note this is the locale of the rendered web pages. It is separate from AGENT_REACH_LANG, which selects the language of the CLI output. Validation: - pytest -q - 480 passed - ruff check agent_reach tests - all checks passed - live check on this machine: agent-reach check reddit --text passes 2/2 with browser_locale=en-US
|
+1, hit the same thing on Linux: the Instagram login window came up entirely in Chinese for a Turkish-locale user. Two things from trying this against 1.6.0:
def _system_locale() -> str:
for var in ("AGENT_REACH_LANG", "LC_ALL", "LC_MESSAGES", "LANG"):
v = os.environ.get(var, "").split(".")[0].split("@")[0].strip()
if v and v not in ("C", "POSIX"):
return v.replace("_", "-")
return "zh-CN"
Happy to send this as a follow-up PR on top of this one if that's easier to review separately. |
Problem
The Cloak persistent context is launched with a hardcoded locale:
Every page the browser renders therefore appears in Chinese — including
Reddit, where the login form and the whole UI came up in Chinese for a user
whose own language is not Chinese. There is no way to change it: the setting
is not exposed through the config file, the environment, or any CLI flag.
Change
The launch code already reads runtime settings from the Agent Reach config
(the proxy option is resolved the same way), so the locale belongs there too.
Users set it with the
browser_localeconfig key or theBROWSER_LOCALEenvironment variable:
The default stays
zh-CN, so existing setups keep their currentbehaviour and nothing changes for current users.
Scope
This is the locale of the rendered web pages. It is separate from
AGENT_REACH_LANG, which selects the language of the CLI output(see #595). The two are complementary and do not overlap.
Tests
tests/test_browser_locale.pycovers the default, the config key, the envvar, and the blank-value case. The new tests fail against the unchanged
source (
assert 'zh-CN' == 'en-US') and pass with the change.Validation
Live check on this machine with
browser_locale=en-US:Measured in the running browser before and after the change:
Notes
path is untouched.
removed.