diff --git a/frontend/src/ts/controllers/quotes-controller.ts b/frontend/src/ts/controllers/quotes-controller.ts index a1e884753..fea73bbbd 100644 --- a/frontend/src/ts/controllers/quotes-controller.ts +++ b/frontend/src/ts/controllers/quotes-controller.ts @@ -2,8 +2,9 @@ import { randomElementFromArray, shuffle } from "../utils/misc"; import { subscribe } from "../observables/config-event"; import * as DB from "../db"; -interface Quote { +interface JsonQuote { text: string; + britishText?: string; source: string; length: number; id: number; @@ -11,7 +12,7 @@ interface Quote { interface QuoteData { language: string; - quotes: Quote[]; + quotes: JsonQuote[]; groups: number[][]; } @@ -63,9 +64,10 @@ class QuotesController { }; // Transform JSON Quote schema to MonkeyTypes Quote schema - data.quotes.forEach((quote: Quote) => { + data.quotes.forEach((quote: JsonQuote) => { const monkeyTypeQuote: MonkeyTypes.Quote = { text: quote.text, + britishText: quote.britishText, source: quote.source, length: quote.length, id: quote.id, diff --git a/frontend/src/ts/test/words-generator.ts b/frontend/src/ts/test/words-generator.ts index 4752173c2..9c13757b2 100644 --- a/frontend/src/ts/test/words-generator.ts +++ b/frontend/src/ts/test/words-generator.ts @@ -311,10 +311,11 @@ async function applyBritishEnglishToWord( word: string, previousWord: string ): Promise { - if (Config.britishEnglish && /english/.test(Config.language)) { - word = await BritishEnglish.replace(word, previousWord); - } - return word; + if (!Config.britishEnglish) return word; + if (!/english/.test(Config.language)) return word; + if (Config.mode === "quote" && TestWords.randomQuote.britishText) return word; + + return await BritishEnglish.replace(word, previousWord); } function applyLazyModeToWord( @@ -591,7 +592,12 @@ async function generateQuoteWords( rq.text = rq.text.replace(/( *(\r\n|\r|\n) *)/g, "\n "); rq.text = rq.text.replace(/…/g, "..."); rq.text = rq.text.trim(); - rq.textSplit = rq.text.split(" "); + + if (rq.britishText && Config.britishEnglish) { + rq.textSplit = rq.britishText.split(" "); + } else { + rq.textSplit = rq.text.split(" "); + } TestWords.setRandomQuote(rq); diff --git a/frontend/src/ts/types/types.d.ts b/frontend/src/ts/types/types.d.ts index 1f1801f76..6a6d7dbeb 100644 --- a/frontend/src/ts/types/types.d.ts +++ b/frontend/src/ts/types/types.d.ts @@ -801,6 +801,7 @@ declare namespace MonkeyTypes { interface Quote { text: string; + britishText?: string; source: string; length: number; id: number;