Skip to content

Commit 5ddcc5f

Browse files
hhkaosclaude
andcommitted
fix(editor): exclude the feed's own text language from its translations
renderFeedTranslations let you add a translation in the same language as feed.textLanguage — redundant (translating English to English) and something the event form's own translations section already guards against (excluded from suggestions, and re-checked on add in case someone types the code directly rather than picking a suggestion). Ported the same two-layer guard here, reading textLanguage live via a new getTextLanguage param so it stays correct if the field changes while the view is open. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DrGeVXHTNNdPi7MCgSageG
1 parent 2b1ff60 commit 5ddcc5f

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

apps/editor/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ async function startEditor(repo: string | null): Promise<void> {
439439
renderFeedTranslations(
440440
feedState.translations,
441441
() => ({ title: feedState.title, description: feedState.description }),
442+
() => feedState.textLanguage,
442443
(translations) => {
443444
feedState.translations = translations;
444445
},

apps/editor/src/ui/form.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,6 +1809,7 @@ function renderLanguagePicker(
18091809
export function renderFeedTranslations(
18101810
initial: Record<string, { title: string; description: string }>,
18111811
getOriginal: () => { title: string; description: string },
1812+
getTextLanguage: () => string,
18121813
onChange: (translations: Record<string, { title: string; description: string }>) => void,
18131814
): HTMLElement {
18141815
let translations = { ...initial };
@@ -1909,9 +1910,18 @@ export function renderFeedTranslations(
19091910

19101911
field.append(
19111912
renderLanguagePicker(
1912-
() => Object.keys(translations),
1913+
() => {
1914+
const textLanguage = getTextLanguage();
1915+
return [...(textLanguage ? [textLanguage] : []), ...Object.keys(translations)];
1916+
},
19131917
(lang) => {
1914-
if (lang in translations) return;
1918+
const textLanguage = getTextLanguage();
1919+
const isTextLanguage =
1920+
textLanguage !== "" && lang.toLowerCase() === textLanguage.toLowerCase();
1921+
const exists = Object.keys(translations).some(
1922+
(l) => l.toLowerCase() === lang.toLowerCase(),
1923+
);
1924+
if (isTextLanguage || exists) return;
19151925
translations = { ...translations, [lang]: { title: "", description: "" } };
19161926
renderList();
19171927
commit();

0 commit comments

Comments
 (0)