Skip to content

fix: localize default custom mode text (@Positiveoo1)#8193

Open
Positiveoo1 wants to merge 1 commit into
monkeytypegame:masterfrom
Positiveoo1:fix/custom-mode-language-default
Open

fix: localize default custom mode text (@Positiveoo1)#8193
Positiveoo1 wants to merge 1 commit into
monkeytypegame:masterfrom
Positiveoo1:fix/custom-mode-language-default

Conversation

@Positiveoo1

Copy link
Copy Markdown
Contributor

Fixes #8192.
Custom mode now uses words from the selected language when the custom text is still the untouched default. User-entered custom text is preserved and does not change when switching languages.

Copilot AI review requested due to automatic review settings July 4, 2026 15:35
@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Jul 4, 2026
@github-actions github-actions Bot added the waiting for review Pull requests that require a review before continuing label Jul 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes custom-mode default text localization: when the stored custom text is still the untouched default, the generated word list now comes from the currently selected language; user-entered custom text remains unchanged.

Changes:

  • Pass language.words into custom-text retrieval for custom mode word generation.
  • Add “untouched default” detection in CustomText.getText(languageWords?) to substitute language words.
  • Add Vitest coverage for default-vs-user-custom behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
frontend/src/ts/test/words-generator.ts Uses language word list for custom mode when custom text is default.
frontend/src/ts/test/custom-text.ts Adds default-text detection + optional localization behavior in getText.
frontend/tests/test/custom-text.spec.ts Tests default localization + preserving user custom text.

Comment thread frontend/src/ts/test/custom-text.ts Outdated
Comment on lines +79 to +84
export function getText(languageWords?: string[]): string[] {
const text = customTextSettings.get().text;
if (languageWords !== undefined && isDefaultCustomText(text)) {
return languageWords.slice(0, text.length);
}
return text;
Comment on lines +72 to +83
function isDefaultCustomText(text: string[]): boolean {
return (
text.length === defaultCustomText.length &&
text.every((word, index) => word === defaultCustomText[index])
);
}

export function getText(languageWords?: string[]): string[] {
const text = customTextSettings.get().text;
if (languageWords !== undefined && isDefaultCustomText(text)) {
return languageWords.slice(0, text.length);
}
@Positiveoo1 Positiveoo1 force-pushed the fix/custom-mode-language-default branch from 8761105 to 545f08c Compare July 4, 2026 16:27
@Positiveoo1 Positiveoo1 requested a review from Copilot July 4, 2026 16:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

frontend/src/ts/test/custom-text.ts:104

  • userEditedSettingsText is set unconditionally in setText. Several code paths call CustomText.setText(...) without the user actually changing the text (eg URL settings loader, challenges, and the Custom Text modal save flow). That permanently flips the flag and will stop getEffectiveText from localizing the untouched default in those scenarios, so the issue can still reproduce after any such flow.

Consider decoupling the flag from setText (eg add setText(txt, { markUserEdited: boolean }) / setTextFromUserInput, or only set the flag from the UI when the text field is dirty).

export function setText(txt: string[]): void {
  const currentSettings = customTextSettings.get();
  userEditedSettingsText.set(true);
  customTextSettings.set({
    ...currentSettings,
    text: txt,
    limit: { value: txt.length, mode: currentSettings.limit.mode },
  });

Comment on lines 50 to 54
const defaultCustomTextSettings: CustomTextSettings = {
text: ["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"],
text: defaultCustomText,
mode: "repeat",
limit: { value: 9, mode: "word" },
pipeDelimiter: false,
@Positiveoo1 Positiveoo1 force-pushed the fix/custom-mode-language-default branch from 545f08c to 93c3173 Compare July 4, 2026 16:43
@fehmer

fehmer commented Jul 4, 2026

Copy link
Copy Markdown
Member

hi @Positiveoo1, thank you for your contribution.

I wouldn't say this is an issue to fix. The custom mode doesnt really have a language. The default text "the quick brown fox" is just a placeholder. Once you defined a custom text you'll never see it again.

We could think about removing the language from the custom text

  • remove from the test notice
  • default it to english on the test result
  • don't show the globe icon on the account page test result list
  • adjust the filtering on the account page to ignore the language for custom tests

@Miodec what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend User interface or web stuff waiting for review Pull requests that require a review before continuing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display on "custom" mode in another language

4 participants