l-min-components 1.7.1536 → 1.7.1537

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.7.1536",
3
+ "version": "1.7.1537",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -331,84 +331,7 @@ const AppMainLayout = ({ children }) => {
331
331
 
332
332
  // const currentPlan = userPlanData?.data?.current_plan;
333
333
  const planState = userPlanData?.data?.state;
334
- const wordBank = [
335
- "Sign out",
336
- "Learning",
337
- "Community",
338
- "Fun",
339
- "Duet",
340
- "Speech",
341
- "Settings",
342
- "Notifications",
343
- "Hello",
344
- "API",
345
- "Documentation",
346
- "Reports",
347
- "Created",
348
- "Report",
349
- "Dictionary",
350
- "What's your language?",
351
- "Add account",
352
- "Developer accounts",
353
- "Developer",
354
- "Search",
355
- "Get started",
356
- "Sign in",
357
- "Sorry, you can’t access your account on a mobile browser.",
358
- "We know it's inconvenient. For better user accessibility, login with a desktop device or via our mobile app.",
359
- "Download on google play",
360
- "Download on apple store",
361
- "Help",
362
- "10% off your next subscription purchase?",
363
- "Let's go!",
364
- "Get a discount when you upgrade to a custom plan and unlock a new world of building.",
365
- "Contact us",
366
- "Get more API calls for less with our custom plan",
367
- "Upgrade now for a 10% discount.",
368
- "Build the future with Learngual!",
369
- "Choose our custom plans for more calls and better flexibility.",
370
- "We know it's inconvenient. For better user accessibility, login with a desktop device.",
371
- // Additional text from codebase analysis - ONLY actual strings found
372
- "Student",
373
- "Instructor account",
374
- "Enterprise account",
375
- "Student account",
376
- "Dashboard",
377
- "Courses",
378
- "My courses",
379
- "Manage courses",
380
- "Manage report",
381
- "Manage teams",
382
- "Manage student",
383
- "Messages",
384
- "Announcements",
385
- "File manager",
386
- "Library",
387
- "Add on",
388
- "Contracts",
389
- "Demo",
390
- "Explore",
391
- "Connect",
392
- "Select affiliate",
393
- "Search affiliates",
394
- "Affiliates",
395
- "GRACE PERIOD",
396
- "ACTIVE",
397
- "Oops!",
398
- "Select plans",
399
- "Renew subscription",
400
- "Instructor",
401
- "profile",
402
- "account photo",
403
- "Search by Name / Email / Username",
404
- "Text",
405
- "add",
406
- "Ready",
407
- "play",
408
- // expired instructor
409
- "You haven’t been added to an enterprise account yet",
410
- "This account will be active once an enterprise assigns you as an instructor.",
411
- ];
334
+
412
335
  const {
413
336
  setDefaultLang,
414
337
  defaultLang,
@@ -1,9 +1,15 @@
1
1
  import React, { useCallback, useContext, useEffect, useState } from "react";
2
2
  import useAxios from "axios-hooks";
3
3
 
4
+ // Global cache for master translations
5
+ if (!window.translationCache) {
6
+ window.translationCache = {};
7
+ }
8
+
4
9
  const environment = window.location.hostname.includes("staging")
5
10
  ? "learngual-bucket"
6
11
  : "learngual-production";
12
+ const CACHE_DURATION = 60 * 60 * 1000; // 1 hour in milliseconds
7
13
  const S3_BASE_URL = `https://${environment}.sfo3.digitaloceanspaces.com/${environment}/media/media/`;
8
14
 
9
15
  const useTranslation = (initialSentences = []) => {
@@ -11,9 +17,6 @@ const useTranslation = (initialSentences = []) => {
11
17
 
12
18
  useEffect(() => {
13
19
  if (value) {
14
- console.log("====================================");
15
- console.log(value, "bfr");
16
- console.log("====================================");
17
20
  setDefaultLang(value);
18
21
  }
19
22
  }, [value]);
@@ -64,9 +67,17 @@ const useTranslation = (initialSentences = []) => {
64
67
  };
65
68
 
66
69
  /**
67
- * Fetch master translations from S3
70
+ * Fetch master translations from S3 with caching
68
71
  */
69
- const getMasterTranslations = async () => {
72
+ const getMasterTranslationsWithCache = async () => {
73
+ const now = Date.now();
74
+ const cached = window.translationCache.master;
75
+
76
+ // Check if cache is valid and not expired
77
+ if (cached && cached.data && cached.expires > now) {
78
+ return cached.data;
79
+ }
80
+
70
81
  try {
71
82
  // Fetch from S3 - master JSON contains all languages
72
83
  const response = await fetch(
@@ -85,9 +96,22 @@ const useTranslation = (initialSentences = []) => {
85
96
 
86
97
  console.log(masterTranslations, "MASTER");
87
98
 
99
+ // Cache in memory (single cache for all languages since JSON contains all)
100
+ window.translationCache.master = {
101
+ data: masterTranslations,
102
+ timestamp: now,
103
+ expires: now + CACHE_DURATION,
104
+ };
105
+
88
106
  return masterTranslations;
89
107
  } catch (error) {
90
108
  console.error("Failed to fetch master translations:", error);
109
+
110
+ // Fallback to cached data if available (even if expired)
111
+ if (cached && cached.data) {
112
+ return cached.data;
113
+ }
114
+
91
115
  throw error;
92
116
  }
93
117
  };
@@ -123,8 +147,8 @@ const useTranslation = (initialSentences = []) => {
123
147
  // Step 1: Fire-and-forget translation request to backend
124
148
  sendTranslationRequestToBackend(language, words);
125
149
 
126
- // Step 2: Get master translations from S3
127
- const masterTranslations = await getMasterTranslations();
150
+ // Step 2: Get master translations (cached or fresh from S3)
151
+ const masterTranslations = await getMasterTranslationsWithCache();
128
152
 
129
153
  // Step 3: Extract only the translations we need
130
154
  const relevantTranslations = extractRelevantTranslations(
@@ -1,4 +1,78 @@
1
1
  [
2
+ "Sign out",
3
+ "Learning",
4
+ "Community",
5
+ "Fun",
6
+ "Duet",
7
+ "Speech",
8
+ "Settings",
9
+ "Notifications",
10
+ "Hello",
11
+ "API",
12
+ "Documentation",
13
+ "Reports",
14
+ "Created",
15
+ "Report",
16
+ "Dictionary",
17
+ "What's your language?",
18
+ "Add account",
19
+ "Developer accounts",
20
+ "Developer",
21
+ "Search",
22
+ "Get started",
23
+ "Sign in",
24
+ "Sorry, you can’t access your account on a mobile browser.",
25
+ "We know it's inconvenient. For better user accessibility, login with a desktop device or via our mobile app.",
26
+ "Download on google play",
27
+ "Download on apple store",
28
+ "Help",
29
+ "10% off your next subscription purchase?",
30
+ "Let's go!",
31
+ "Get a discount when you upgrade to a custom plan and unlock a new world of building.",
32
+ "Contact us",
33
+ "Get more API calls for less with our custom plan",
34
+ "Upgrade now for a 10% discount.",
35
+ "Build the future with Learngual!",
36
+ "Choose our custom plans for more calls and better flexibility.",
37
+ "We know it's inconvenient. For better user accessibility, login with a desktop device.",
38
+ "Student",
39
+ "Instructor account",
40
+ "Enterprise account",
41
+ "Student account",
42
+ "Dashboard",
43
+ "Courses",
44
+ "My courses",
45
+ "Manage courses",
46
+ "Manage report",
47
+ "Manage teams",
48
+ "Manage student",
49
+ "Messages",
50
+ "Announcements",
51
+ "File manager",
52
+ "Library",
53
+ "Add on",
54
+ "Contracts",
55
+ "Demo",
56
+ "Explore",
57
+ "Connect",
58
+ "Select affiliate",
59
+ "Search affiliates",
60
+ "Affiliates",
61
+ "GRACE PERIOD",
62
+ "ACTIVE",
63
+ "Oops!",
64
+ "Select plans",
65
+ "Renew subscription",
66
+ "Instructor",
67
+ "profile",
68
+ "account photo",
69
+ "Search by Name / Email / Username",
70
+ "Text",
71
+ "add",
72
+ "Ready",
73
+ "play",
74
+ "You haven’t been added to an enterprise account yet",
75
+ "This account will be active once an enterprise assigns you as an instructor.",
2
76
  "(decibel level)",
3
77
  "(Raw Format)",
4
78
  "(WAV)",
@@ -101,7 +175,6 @@
101
175
  "email",
102
176
  "Email",
103
177
  "email address",
104
- "Email: **********oe@gmail.com",
105
178
  "Emoji",
106
179
  "English",
107
180
  "Enter role name",