mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-05 04:07:36 +08:00
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:
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { api, pluginText, type CommitSettingsView } from "../../shared/api";
|
||||
import { commitPromptLocale } from "../../i18n/runtime";
|
||||
import { useI18n } from "../../i18n/store";
|
||||
import { useAppStore } from "../../shared/store/appStore";
|
||||
import { Button } from "../../shared/ui/Button";
|
||||
@@ -33,11 +34,12 @@ export function CommitSettingsCard() {
|
||||
void (async () => {
|
||||
try {
|
||||
let loaded = await api.commitSettings(locale);
|
||||
if (!loaded.prompt.trim() && loaded.prompt_locale !== locale) {
|
||||
const promptLocale = commitPromptLocale(locale);
|
||||
if (!loaded.prompt.trim() && loaded.prompt_locale !== promptLocale) {
|
||||
loaded = await api.setCommitSettings({
|
||||
model_id: loaded.model_id,
|
||||
prompt: "",
|
||||
prompt_locale: locale,
|
||||
prompt_locale: promptLocale,
|
||||
});
|
||||
}
|
||||
if (active) {
|
||||
@@ -97,7 +99,7 @@ export function CommitSettingsCard() {
|
||||
return api.setCommitSettings({
|
||||
model_id: modelId,
|
||||
prompt: normalizedPrompt,
|
||||
prompt_locale: locale,
|
||||
prompt_locale: commitPromptLocale(locale),
|
||||
});
|
||||
},
|
||||
[view, locale],
|
||||
|
||||
@@ -3,6 +3,12 @@ import enUS from "./locales/en-US.json";
|
||||
import ptBR from "./locales/pt-BR.json";
|
||||
|
||||
export type Locale = "zh-CN" | "en-US" | "pt-BR";
|
||||
export type CommitPromptLocale = "zh-CN" | "en-US";
|
||||
|
||||
export function commitPromptLocale(locale: Locale): CommitPromptLocale {
|
||||
return locale === "zh-CN" ? "zh-CN" : "en-US";
|
||||
}
|
||||
|
||||
export type TranslationValue = string | number;
|
||||
export type TranslationParams = Readonly<Record<string, TranslationValue>>;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { AdRuntime } from "../shell/ads/types";
|
||||
import type { Locale } from "../i18n/runtime";
|
||||
import type { CommitPromptLocale, Locale } from "../i18n/runtime";
|
||||
|
||||
export type ModelType = "openai" | "anthropic";
|
||||
|
||||
@@ -154,7 +154,7 @@ export interface DesktopSettings {
|
||||
export interface CommitSettings {
|
||||
model_id: string;
|
||||
prompt: string;
|
||||
prompt_locale: Locale;
|
||||
prompt_locale: CommitPromptLocale;
|
||||
}
|
||||
|
||||
export interface CommitSettingsView extends CommitSettings {
|
||||
|
||||
Reference in New Issue
Block a user