fix(settings): map unknown UI locales to en-US for commit prompts

Portuguese and other interface languages have no commit prompt catalog; sending pt-BR made settings fail to deserialize.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
leokunandCursor committed 2026-09-15 21:31:00 +08:00
1 parent c0d5f9a815
commit 127cf8b883
5 files changed
+56 -12

No files matched your search

+6 -5
View File
@@ -149,13 +149,11 @@ pub async fn update_pricing_settings(
}
fn requested_commit_locale(headers: &HeaderMap) -> CommitPromptLocale {
match headers
headers
.get(header::ACCEPT_LANGUAGE)
.and_then(|value| value.to_str().ok())
{
Some(value) if value.eq_ignore_ascii_case("zh-CN") => CommitPromptLocale::ZhCn,
_ => CommitPromptLocale::EnUs,
}
.map(CommitPromptLocale::from_interface_language)
.unwrap_or(CommitPromptLocale::EnUs)
}
#[cfg(test)]
@@ -170,5 +168,8 @@ mod tests {
headers.insert(header::ACCEPT_LANGUAGE, "en-US".parse().unwrap());
assert_eq!(requested_commit_locale(&headers), CommitPromptLocale::EnUs);
headers.insert(header::ACCEPT_LANGUAGE, "pt-BR".parse().unwrap());
assert_eq!(requested_commit_locale(&headers), CommitPromptLocale::EnUs);
}
}