From b69f11bdd1a9223d69c8aeccf58081e0ecbf72a2 Mon Sep 17 00:00:00 2001 From: Jacky Sun Date: Thu, 19 Sep 2024 09:29:55 -0700 Subject: [PATCH] MWPW-157450: Localization Enhancements for quiz-entry block needed --- libs/blocks/quiz-entry/quiz-entry.js | 4 +++- libs/blocks/quiz-entry/quizoption.js | 9 +++++---- libs/blocks/quiz-entry/utils.js | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/libs/blocks/quiz-entry/quiz-entry.js b/libs/blocks/quiz-entry/quiz-entry.js index 294a7cc18f..5ffecb10ed 100644 --- a/libs/blocks/quiz-entry/quiz-entry.js +++ b/libs/blocks/quiz-entry/quiz-entry.js @@ -3,6 +3,7 @@ import { getQuizEntryData, handleNext, handleSelections } from './utils.js'; import { mlField, getMLResults } from './mlField.js'; import { GetQuizOption } from './quizoption.js'; import { quizPopover, getSuggestions } from './quizPopover.js'; +import { getConfig } from '../../utils/utils.js'; export const locationWrapper = { redirect: (url) => { @@ -343,7 +344,8 @@ const App = ({ if (!dataLoaded || !selectedQuestion) return null; - return html`
+ const { locale } = getConfig(); + return html`

${quizLists.strings[selectedQuestion.questions].heading}

${quizLists.strings[selectedQuestion.questions]['sub-head']}

diff --git a/libs/blocks/quiz-entry/quizoption.js b/libs/blocks/quiz-entry/quizoption.js index 83a3e710f0..031d1ff0c5 100644 --- a/libs/blocks/quiz-entry/quizoption.js +++ b/libs/blocks/quiz-entry/quizoption.js @@ -1,6 +1,7 @@ import { html, useState, useEffect } from '../../deps/htm-preact.js'; import { getSwipeDistance, getSwipeDirection } from '../carousel/carousel.js'; import { createTag } from '../../utils/utils.js'; +import { removeLeftToRightMark } from '../quiz/utils.js'; export const OptionCard = ({ text, title, image, icon, iconTablet, iconDesktop, options, @@ -18,13 +19,13 @@ export const OptionCard = ({ const getIconHtml = () => html`
- ${iconDesktop && html``} - ${iconTablet && html``} - + ${iconDesktop && html``} + ${iconTablet && html``} +
`; - const imageHtml = image ? html`
` : null; + const imageHtml = image ? html`
` : null; const titleHtml = title ? html`

${title}

` : null; const textHtml = text ? html`

${text}

` : null; diff --git a/libs/blocks/quiz-entry/utils.js b/libs/blocks/quiz-entry/utils.js index dfca985432..787b4ee79a 100644 --- a/libs/blocks/quiz-entry/utils.js +++ b/libs/blocks/quiz-entry/utils.js @@ -1,4 +1,4 @@ -import { getNormalizedMetadata } from '../quiz/utils.js'; +import { getNormalizedMetadata, getLocalizedURL } from '../quiz/utils.js'; export async function fetchJson(path) { const response = await fetch(path); @@ -104,8 +104,8 @@ export const handleSelections = (prevSelections, selectedQuestion, selections) = export async function getQuizEntryData(el) { const blockData = getNormalizedMetadata(el); - const dataPath = blockData.data.text; - const quizPath = blockData.quiz.text; + const dataPath = getLocalizedURL(blockData.data.text); + const quizPath = getLocalizedURL(blockData.quiz.text); const maxQuestions = Number(blockData.maxquestions?.text) || 10; const analyticsType = blockData.analyticstype?.text; const analyticsQuiz = blockData.analyticsquiz?.text;