@learnpack/learnpack 5.0.283 → 5.0.285

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/ui/app.tar.gz CHANGED
Binary file
@@ -7,15 +7,37 @@ import { spawn } from "child_process";
7
7
  import { ExportOptions, CourseMetadata, EpubMetadata } from "./types";
8
8
  import { downloadS3Folder, getCourseMetadata } from "./shared";
9
9
 
10
- const replaceQuestionsFromMarkdown = (markdown: string) => {
10
+ const getLocalizedText = (language: string) => {
11
+ const translations = {
12
+ en: "Write your answer here",
13
+ es: "Escribe tu respuesta aquí",
14
+ fr: "Écrivez votre réponse ici",
15
+ de: "Schreiben Sie Ihre Antwort hier",
16
+ it: "Scrivi la tua risposta qui",
17
+ pt: "Escreva sua resposta aqui",
18
+ ja: "ここに答えを書いてください",
19
+ ko: "여기에 답을 작성하세요",
20
+ zh: "在这里写下你的答案",
21
+ ar: "اكتب إجابتك هنا",
22
+ ru: "Напишите свой ответ здесь",
23
+ };
24
+
25
+ return translations[language as keyof typeof translations] || translations.en;
26
+ };
27
+
28
+ const replaceQuestionsFromMarkdown = (
29
+ markdown: string,
30
+ language: string = "en"
31
+ ) => {
11
32
  // Search for all code blocks like this (No breaking lines sensitive)
12
33
  // ```question some parameters
13
34
  // some text
14
35
  // ```
15
36
  const questionRegex = /```question([\s\S]*?)```/g;
37
+ const localizedText = getLocalizedText(language);
16
38
  return markdown.replace(
17
39
  questionRegex,
18
- '<div type="text" class="open-question">Right your answer here</div>'
40
+ `<div type="text" class="open-question">${localizedText}</div>`
19
41
  );
20
42
  };
21
43
 
@@ -234,7 +256,8 @@ async function processExercises(
234
256
  console.log("Processing markdown file:", relativeFilePath);
235
257
  const processedContent = processMarkdownContent(
236
258
  fullPath,
237
- learnAssetsDir
259
+ learnAssetsDir,
260
+ language
238
261
  );
239
262
 
240
263
  const processedMarkdownPath = path.join(
@@ -288,7 +311,8 @@ async function processExercises(
288
311
  // Process markdown content for EPUB conversion
289
312
  function processMarkdownContent(
290
313
  markdownPath: string,
291
- learnAssetsDir?: string
314
+ learnAssetsDir?: string,
315
+ language: string = "en"
292
316
  ): string {
293
317
  let markdownContent = fs.readFileSync(markdownPath, "utf-8");
294
318
 
@@ -335,7 +359,7 @@ function processMarkdownContent(
335
359
  }
336
360
  }
337
361
 
338
- markdownContent = replaceQuestionsFromMarkdown(markdownContent);
362
+ markdownContent = replaceQuestionsFromMarkdown(markdownContent, language);
339
363
  markdownContent = replaceMermaidFromMarkdown(markdownContent);
340
364
  markdownContent = cleanQuizOptions(markdownContent);
341
365