@magmamath/students-features 1.3.23-rc.9 → 1.3.23

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.
Files changed (332) hide show
  1. package/dist/commonjs/features/pmProgress/components/chart/chart.helpers.js +1 -0
  2. package/dist/commonjs/features/pmProgress/components/chart/chart.helpers.js.map +1 -1
  3. package/dist/commonjs/features/pmProgress/components/header/StartButton.js +10 -1
  4. package/dist/commonjs/features/pmProgress/components/header/StartButton.js.map +1 -1
  5. package/dist/commonjs/features/pmProgress/components/list/{ListCard.js → DomainCard.js} +10 -22
  6. package/dist/commonjs/features/pmProgress/components/list/DomainCard.js.map +1 -0
  7. package/dist/commonjs/features/pmProgress/components/list/Fluency.js +3 -3
  8. package/dist/commonjs/features/pmProgress/components/list/Fluency.js.map +1 -1
  9. package/dist/commonjs/features/pmProgress/components/list/PmDomainList.js +3 -3
  10. package/dist/commonjs/features/pmProgress/components/list/PmDomainList.js.map +1 -1
  11. package/dist/commonjs/features/pmProgress/components/list/{ListItem.js → StandardItem.js} +5 -5
  12. package/dist/commonjs/features/pmProgress/components/list/StandardItem.js.map +1 -0
  13. package/dist/commonjs/features/pmProgress/components/recs/PmTeacherRecs.js +7 -4
  14. package/dist/commonjs/features/pmProgress/components/recs/PmTeacherRecs.js.map +1 -1
  15. package/dist/commonjs/features/pmProgress/components/standard/StandardTag.js +1 -8
  16. package/dist/commonjs/features/pmProgress/components/standard/StandardTag.js.map +1 -1
  17. package/dist/commonjs/features/pmProgress/shared/pmProgress.helpers.js +1 -1
  18. package/dist/commonjs/features/pmProgress/shared/pmProgress.helpers.js.map +1 -1
  19. package/dist/commonjs/features/voice/index.js +4 -4
  20. package/dist/commonjs/features/voice/index.js.map +1 -1
  21. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js +245 -0
  22. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +1 -0
  23. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +109 -0
  24. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +1 -0
  25. package/dist/commonjs/features/voice/playing/hooks/{useVoiceTranscription.js → useVoiceTranscriptionsDropdown.js} +4 -4
  26. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +1 -0
  27. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +34 -0
  28. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +1 -0
  29. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js +4 -18
  30. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -1
  31. package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js +2 -6
  32. package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
  33. package/dist/commonjs/features/voice/playing/model/{VoiceTranscription.model.js → VoiceTranscriptionsDropdown.model.js} +4 -4
  34. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +1 -0
  35. package/dist/commonjs/features/voice/types.js +1 -6
  36. package/dist/commonjs/features/voice/types.js.map +1 -1
  37. package/dist/commonjs/index.js +0 -12
  38. package/dist/commonjs/index.js.map +1 -1
  39. package/dist/module/features/pmProgress/components/chart/chart.helpers.js +1 -0
  40. package/dist/module/features/pmProgress/components/chart/chart.helpers.js.map +1 -1
  41. package/dist/module/features/pmProgress/components/header/StartButton.js +10 -1
  42. package/dist/module/features/pmProgress/components/header/StartButton.js.map +1 -1
  43. package/dist/module/features/pmProgress/components/list/{ListCard.js → DomainCard.js} +8 -20
  44. package/dist/module/features/pmProgress/components/list/DomainCard.js.map +1 -0
  45. package/dist/module/features/pmProgress/components/list/Fluency.js +3 -3
  46. package/dist/module/features/pmProgress/components/list/Fluency.js.map +1 -1
  47. package/dist/module/features/pmProgress/components/list/PmDomainList.js +3 -3
  48. package/dist/module/features/pmProgress/components/list/PmDomainList.js.map +1 -1
  49. package/dist/module/features/pmProgress/components/list/{ListItem.js → StandardItem.js} +3 -3
  50. package/dist/module/features/pmProgress/components/list/StandardItem.js.map +1 -0
  51. package/dist/module/features/pmProgress/components/recs/PmTeacherRecs.js +7 -4
  52. package/dist/module/features/pmProgress/components/recs/PmTeacherRecs.js.map +1 -1
  53. package/dist/module/features/pmProgress/components/standard/StandardTag.js +2 -9
  54. package/dist/module/features/pmProgress/components/standard/StandardTag.js.map +1 -1
  55. package/dist/module/features/pmProgress/shared/pmProgress.helpers.js +1 -1
  56. package/dist/module/features/pmProgress/shared/pmProgress.helpers.js.map +1 -1
  57. package/dist/module/features/voice/index.js +1 -1
  58. package/dist/module/features/voice/index.js.map +1 -1
  59. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js +238 -0
  60. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +1 -0
  61. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +103 -0
  62. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +1 -0
  63. package/dist/module/features/voice/playing/hooks/{useVoiceTranscription.js → useVoiceTranscriptionsDropdown.js} +2 -2
  64. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +1 -0
  65. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +29 -0
  66. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +1 -0
  67. package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js +4 -18
  68. package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -1
  69. package/dist/module/features/voice/playing/model/VoicePlayer.model.js +2 -6
  70. package/dist/module/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
  71. package/dist/module/features/voice/playing/model/{VoiceTranscription.model.js → VoiceTranscriptionsDropdown.model.js} +2 -2
  72. package/dist/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +1 -0
  73. package/dist/module/features/voice/types.js +0 -5
  74. package/dist/module/features/voice/types.js.map +1 -1
  75. package/dist/module/index.js +0 -1
  76. package/dist/module/index.js.map +1 -1
  77. package/dist/typescript/commonjs/features/pmProgress/components/chart/chart.helpers.d.ts.map +1 -1
  78. package/dist/typescript/commonjs/features/pmProgress/components/header/StartButton.d.ts.map +1 -1
  79. package/dist/typescript/commonjs/features/pmProgress/components/list/{ListCard.d.ts → DomainCard.d.ts} +6 -6
  80. package/dist/typescript/commonjs/features/pmProgress/components/list/DomainCard.d.ts.map +1 -0
  81. package/dist/typescript/commonjs/features/pmProgress/components/list/StandardItem.d.ts +13 -0
  82. package/dist/typescript/commonjs/features/pmProgress/components/list/StandardItem.d.ts.map +1 -0
  83. package/dist/typescript/commonjs/features/pmProgress/components/recs/PmTeacherRecs.d.ts.map +1 -1
  84. package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.helpers.d.ts.map +1 -1
  85. package/dist/typescript/commonjs/features/voice/index.d.ts +1 -1
  86. package/dist/typescript/commonjs/features/voice/index.d.ts.map +1 -1
  87. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +16 -0
  88. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +1 -0
  89. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +12 -0
  90. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +1 -0
  91. package/dist/typescript/commonjs/features/voice/playing/hooks/{useVoiceTranscription.d.ts → useVoiceTranscriptionsDropdown.d.ts} +3 -3
  92. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +1 -0
  93. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +11 -0
  94. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +1 -0
  95. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -1
  96. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +1 -1
  97. package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts +2 -4
  98. package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
  99. package/dist/typescript/commonjs/features/voice/playing/model/{VoiceTranscription.model.d.ts → VoiceTranscriptionsDropdown.model.d.ts} +2 -2
  100. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +1 -0
  101. package/dist/typescript/commonjs/features/voice/types.d.ts +1 -9
  102. package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -1
  103. package/dist/typescript/commonjs/index.d.ts +0 -1
  104. package/dist/typescript/commonjs/index.d.ts.map +1 -1
  105. package/dist/typescript/module/features/pmProgress/components/chart/chart.helpers.d.ts.map +1 -1
  106. package/dist/typescript/module/features/pmProgress/components/header/StartButton.d.ts.map +1 -1
  107. package/dist/typescript/module/features/pmProgress/components/list/{ListCard.d.ts → DomainCard.d.ts} +6 -6
  108. package/dist/typescript/module/features/pmProgress/components/list/DomainCard.d.ts.map +1 -0
  109. package/dist/typescript/module/features/pmProgress/components/list/StandardItem.d.ts +13 -0
  110. package/dist/typescript/module/features/pmProgress/components/list/StandardItem.d.ts.map +1 -0
  111. package/dist/typescript/module/features/pmProgress/components/recs/PmTeacherRecs.d.ts.map +1 -1
  112. package/dist/typescript/module/features/pmProgress/shared/pmProgress.helpers.d.ts.map +1 -1
  113. package/dist/typescript/module/features/voice/index.d.ts +1 -1
  114. package/dist/typescript/module/features/voice/index.d.ts.map +1 -1
  115. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +16 -0
  116. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +1 -0
  117. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +12 -0
  118. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +1 -0
  119. package/dist/typescript/module/features/voice/playing/hooks/{useVoiceTranscription.d.ts → useVoiceTranscriptionsDropdown.d.ts} +3 -3
  120. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +1 -0
  121. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +11 -0
  122. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +1 -0
  123. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -1
  124. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +1 -1
  125. package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts +2 -4
  126. package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
  127. package/dist/typescript/module/features/voice/playing/model/{VoiceTranscription.model.d.ts → VoiceTranscriptionsDropdown.model.d.ts} +2 -2
  128. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +1 -0
  129. package/dist/typescript/module/features/voice/types.d.ts +1 -9
  130. package/dist/typescript/module/features/voice/types.d.ts.map +1 -1
  131. package/dist/typescript/module/index.d.ts +0 -1
  132. package/dist/typescript/module/index.d.ts.map +1 -1
  133. package/package.json +1 -1
  134. package/src/features/pmProgress/components/chart/chart.helpers.ts +1 -0
  135. package/src/features/pmProgress/components/header/StartButton.tsx +11 -1
  136. package/src/features/pmProgress/components/list/{ListCard.tsx → DomainCard.tsx} +12 -19
  137. package/src/features/pmProgress/components/list/Fluency.tsx +3 -3
  138. package/src/features/pmProgress/components/list/PmDomainList.tsx +3 -3
  139. package/src/features/pmProgress/components/list/{ListItem.tsx → StandardItem.tsx} +4 -4
  140. package/src/features/pmProgress/components/recs/PmTeacherRecs.tsx +8 -4
  141. package/src/features/pmProgress/components/standard/StandardTag.tsx +2 -6
  142. package/src/features/pmProgress/shared/pmProgress.helpers.ts +1 -2
  143. package/src/features/voice/index.ts +1 -1
  144. package/src/features/voice/playing/components/VoiceTranscriptionsDropdown.tsx +296 -0
  145. package/src/features/voice/playing/components/VoiceTranscriptionsDropdownItem.tsx +128 -0
  146. package/src/features/voice/playing/hooks/{useVoiceTranscription.ts → useVoiceTranscriptionsDropdown.ts} +2 -2
  147. package/src/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.ts +40 -0
  148. package/src/features/voice/playing/model/TranscriptionsDownloaderModel.ts +5 -12
  149. package/src/features/voice/playing/model/VoicePlayer.model.ts +2 -7
  150. package/src/features/voice/playing/model/{VoiceTranscription.model.ts → VoiceTranscriptionsDropdown.model.ts} +2 -2
  151. package/src/features/voice/types.ts +0 -15
  152. package/src/index.ts +0 -1
  153. package/dist/commonjs/features/pmProgress/components/list/ListCard.js.map +0 -1
  154. package/dist/commonjs/features/pmProgress/components/list/ListItem.js.map +0 -1
  155. package/dist/commonjs/features/translation/constants.js +0 -11
  156. package/dist/commonjs/features/translation/constants.js.map +0 -1
  157. package/dist/commonjs/features/translation/helpers.js +0 -60
  158. package/dist/commonjs/features/translation/helpers.js.map +0 -1
  159. package/dist/commonjs/features/translation/index.js +0 -105
  160. package/dist/commonjs/features/translation/index.js.map +0 -1
  161. package/dist/commonjs/features/translation/model/TranslationModel.js +0 -122
  162. package/dist/commonjs/features/translation/model/TranslationModel.js.map +0 -1
  163. package/dist/commonjs/features/translation/model/TranslationPreprocessor.js +0 -142
  164. package/dist/commonjs/features/translation/model/TranslationPreprocessor.js.map +0 -1
  165. package/dist/commonjs/features/translation/model/TranslationService.js +0 -112
  166. package/dist/commonjs/features/translation/model/TranslationService.js.map +0 -1
  167. package/dist/commonjs/features/translation/preserve/wordsToPreserve.js +0 -314
  168. package/dist/commonjs/features/translation/preserve/wordsToPreserve.js.map +0 -1
  169. package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js +0 -50
  170. package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js.map +0 -1
  171. package/dist/commonjs/features/translation/providers/google/supportedLanguages.js +0 -230
  172. package/dist/commonjs/features/translation/providers/google/supportedLanguages.js.map +0 -1
  173. package/dist/commonjs/features/translation/providers/google.types.js +0 -2
  174. package/dist/commonjs/features/translation/providers/google.types.js.map +0 -1
  175. package/dist/commonjs/features/translation/providers/translation.interface.js +0 -49
  176. package/dist/commonjs/features/translation/providers/translation.interface.js.map +0 -1
  177. package/dist/commonjs/features/translation/types.js +0 -2
  178. package/dist/commonjs/features/translation/types.js.map +0 -1
  179. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js +0 -44
  180. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js.map +0 -1
  181. package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js +0 -135
  182. package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js.map +0 -1
  183. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js +0 -66
  184. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +0 -1
  185. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +0 -59
  186. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +0 -1
  187. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscription.js.map +0 -1
  188. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +0 -37
  189. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +0 -1
  190. package/dist/commonjs/features/voice/playing/model/VoiceTranscription.model.js.map +0 -1
  191. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.js +0 -62
  192. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.js.map +0 -1
  193. package/dist/module/features/pmProgress/components/list/ListCard.js.map +0 -1
  194. package/dist/module/features/pmProgress/components/list/ListItem.js.map +0 -1
  195. package/dist/module/features/translation/constants.js +0 -7
  196. package/dist/module/features/translation/constants.js.map +0 -1
  197. package/dist/module/features/translation/helpers.js +0 -53
  198. package/dist/module/features/translation/helpers.js.map +0 -1
  199. package/dist/module/features/translation/index.js +0 -12
  200. package/dist/module/features/translation/index.js.map +0 -1
  201. package/dist/module/features/translation/model/TranslationModel.js +0 -117
  202. package/dist/module/features/translation/model/TranslationModel.js.map +0 -1
  203. package/dist/module/features/translation/model/TranslationPreprocessor.js +0 -137
  204. package/dist/module/features/translation/model/TranslationPreprocessor.js.map +0 -1
  205. package/dist/module/features/translation/model/TranslationService.js +0 -107
  206. package/dist/module/features/translation/model/TranslationService.js.map +0 -1
  207. package/dist/module/features/translation/preserve/wordsToPreserve.js +0 -310
  208. package/dist/module/features/translation/preserve/wordsToPreserve.js.map +0 -1
  209. package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js +0 -45
  210. package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js.map +0 -1
  211. package/dist/module/features/translation/providers/google/supportedLanguages.js +0 -225
  212. package/dist/module/features/translation/providers/google/supportedLanguages.js.map +0 -1
  213. package/dist/module/features/translation/providers/google.types.js +0 -2
  214. package/dist/module/features/translation/providers/google.types.js.map +0 -1
  215. package/dist/module/features/translation/providers/translation.interface.js +0 -44
  216. package/dist/module/features/translation/providers/translation.interface.js.map +0 -1
  217. package/dist/module/features/translation/types.js +0 -2
  218. package/dist/module/features/translation/types.js.map +0 -1
  219. package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js +0 -38
  220. package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js.map +0 -1
  221. package/dist/module/features/voice/playing/components/VoiceTranscription.js +0 -127
  222. package/dist/module/features/voice/playing/components/VoiceTranscription.js.map +0 -1
  223. package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js +0 -58
  224. package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +0 -1
  225. package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +0 -51
  226. package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +0 -1
  227. package/dist/module/features/voice/playing/hooks/useVoiceTranscription.js.map +0 -1
  228. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +0 -32
  229. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +0 -1
  230. package/dist/module/features/voice/playing/model/VoiceTranscription.model.js.map +0 -1
  231. package/dist/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.js +0 -57
  232. package/dist/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.js.map +0 -1
  233. package/dist/typescript/commonjs/features/pmProgress/components/list/ListCard.d.ts.map +0 -1
  234. package/dist/typescript/commonjs/features/pmProgress/components/list/ListItem.d.ts +0 -13
  235. package/dist/typescript/commonjs/features/pmProgress/components/list/ListItem.d.ts.map +0 -1
  236. package/dist/typescript/commonjs/features/translation/constants.d.ts +0 -5
  237. package/dist/typescript/commonjs/features/translation/constants.d.ts.map +0 -1
  238. package/dist/typescript/commonjs/features/translation/helpers.d.ts +0 -9
  239. package/dist/typescript/commonjs/features/translation/helpers.d.ts.map +0 -1
  240. package/dist/typescript/commonjs/features/translation/index.d.ts +0 -12
  241. package/dist/typescript/commonjs/features/translation/index.d.ts.map +0 -1
  242. package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts +0 -33
  243. package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts.map +0 -1
  244. package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts +0 -34
  245. package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts.map +0 -1
  246. package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts +0 -40
  247. package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts.map +0 -1
  248. package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts +0 -3
  249. package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts.map +0 -1
  250. package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts +0 -17
  251. package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +0 -1
  252. package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts +0 -209
  253. package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts.map +0 -1
  254. package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts +0 -15
  255. package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts.map +0 -1
  256. package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts +0 -30
  257. package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts.map +0 -1
  258. package/dist/typescript/commonjs/features/translation/types.d.ts +0 -27
  259. package/dist/typescript/commonjs/features/translation/types.d.ts.map +0 -1
  260. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts +0 -8
  261. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +0 -1
  262. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts +0 -16
  263. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts.map +0 -1
  264. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +0 -10
  265. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +0 -1
  266. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +0 -12
  267. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +0 -1
  268. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscription.d.ts.map +0 -1
  269. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts +0 -12
  270. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +0 -1
  271. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscription.model.d.ts.map +0 -1
  272. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts +0 -25
  273. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts.map +0 -1
  274. package/dist/typescript/module/features/pmProgress/components/list/ListCard.d.ts.map +0 -1
  275. package/dist/typescript/module/features/pmProgress/components/list/ListItem.d.ts +0 -13
  276. package/dist/typescript/module/features/pmProgress/components/list/ListItem.d.ts.map +0 -1
  277. package/dist/typescript/module/features/translation/constants.d.ts +0 -5
  278. package/dist/typescript/module/features/translation/constants.d.ts.map +0 -1
  279. package/dist/typescript/module/features/translation/helpers.d.ts +0 -9
  280. package/dist/typescript/module/features/translation/helpers.d.ts.map +0 -1
  281. package/dist/typescript/module/features/translation/index.d.ts +0 -12
  282. package/dist/typescript/module/features/translation/index.d.ts.map +0 -1
  283. package/dist/typescript/module/features/translation/model/TranslationModel.d.ts +0 -33
  284. package/dist/typescript/module/features/translation/model/TranslationModel.d.ts.map +0 -1
  285. package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts +0 -34
  286. package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts.map +0 -1
  287. package/dist/typescript/module/features/translation/model/TranslationService.d.ts +0 -40
  288. package/dist/typescript/module/features/translation/model/TranslationService.d.ts.map +0 -1
  289. package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts +0 -3
  290. package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts.map +0 -1
  291. package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts +0 -17
  292. package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +0 -1
  293. package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts +0 -209
  294. package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts.map +0 -1
  295. package/dist/typescript/module/features/translation/providers/google.types.d.ts +0 -15
  296. package/dist/typescript/module/features/translation/providers/google.types.d.ts.map +0 -1
  297. package/dist/typescript/module/features/translation/providers/translation.interface.d.ts +0 -30
  298. package/dist/typescript/module/features/translation/providers/translation.interface.d.ts.map +0 -1
  299. package/dist/typescript/module/features/translation/types.d.ts +0 -27
  300. package/dist/typescript/module/features/translation/types.d.ts.map +0 -1
  301. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts +0 -8
  302. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +0 -1
  303. package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts +0 -16
  304. package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts.map +0 -1
  305. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +0 -10
  306. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +0 -1
  307. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +0 -12
  308. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +0 -1
  309. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscription.d.ts.map +0 -1
  310. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts +0 -12
  311. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +0 -1
  312. package/dist/typescript/module/features/voice/playing/model/VoiceTranscription.model.d.ts.map +0 -1
  313. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts +0 -25
  314. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts.map +0 -1
  315. package/src/features/translation/constants.ts +0 -4
  316. package/src/features/translation/helpers.ts +0 -63
  317. package/src/features/translation/index.ts +0 -30
  318. package/src/features/translation/model/TranslationModel.ts +0 -174
  319. package/src/features/translation/model/TranslationPreprocessor.ts +0 -171
  320. package/src/features/translation/model/TranslationService.ts +0 -148
  321. package/src/features/translation/preserve/wordsToPreserve.ts +0 -87
  322. package/src/features/translation/providers/google/GoogleTranslationProvider.ts +0 -50
  323. package/src/features/translation/providers/google/supportedLanguages.ts +0 -229
  324. package/src/features/translation/providers/google.types.ts +0 -16
  325. package/src/features/translation/providers/translation.interface.ts +0 -63
  326. package/src/features/translation/types.ts +0 -30
  327. package/src/features/voice/playing/components/VoiceTranscriptContent.tsx +0 -37
  328. package/src/features/voice/playing/components/VoiceTranscription.tsx +0 -172
  329. package/src/features/voice/playing/components/VoiceTranscriptionCollapsible.tsx +0 -59
  330. package/src/features/voice/playing/components/VoiceTranscriptionHeaderActions.tsx +0 -62
  331. package/src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts +0 -44
  332. package/src/features/voice/playing/model/VoiceTranscriptionTranslation.model.ts +0 -75
@@ -1,174 +0,0 @@
1
- import {
2
- attach,
3
- combine,
4
- createEffect,
5
- createEvent,
6
- restore,
7
- sample,
8
- split,
9
- Store,
10
- Unit,
11
- } from 'effector'
12
- import { GoogleTranslationProvider } from '../providers/google/GoogleTranslationProvider'
13
- import {
14
- GoogleTranslateProps,
15
- GoogleTranslateResponse,
16
- } from '../providers/google.types'
17
- import { TranslationService } from './TranslationService'
18
- import {
19
- preservedWordsReplacers,
20
- wordsToPreserve,
21
- } from '../preserve/wordsToPreserve'
22
- import {
23
- CHOICES_CACHE_KEY_SUFFIX,
24
- DESCRIPTION_CACHE_KEY_SUFFIX,
25
- GBD_TEXT_CACHE_SUFFIX,
26
- } from '../constants'
27
- import {
28
- TranslatableProblem,
29
- TranslateAllFxParams,
30
- TranslateFxParams,
31
- } from '../types'
32
-
33
- type TranslationModelProps<TProblem extends TranslatableProblem> = {
34
- $problem: Store<TProblem | null>
35
- $problemId: Store<string>
36
- $assignmentId: Store<string>
37
- $currentProblemIndex: Store<number>
38
- $translationLanguageCode: Store<string>
39
- $contentLanguageCode?: Store<string>
40
- $isTranslationLocked: Store<boolean>
41
- languageChanged: Unit<unknown>
42
- api: {
43
- translateRequest: (payload: GoogleTranslateProps) => Promise<GoogleTranslateResponse>
44
- }
45
- getGreatWorkFeedbackText?: () => string
46
- }
47
-
48
- export class TranslationModel<TProblem extends TranslatableProblem = TranslatableProblem> {
49
- private readonly service: TranslationService
50
-
51
- public readonly toggle = createEvent()
52
- public readonly setTranslated = createEvent<boolean>()
53
- public readonly reset = createEvent()
54
-
55
- public readonly $isTranslationActive = restore(this.setTranslated, false).reset(this.reset)
56
- public readonly $isTranslated = this.$isTranslationActive
57
- public readonly $isTranslationPending
58
-
59
- public readonly translateFx
60
- public readonly translateAllFx
61
-
62
- constructor({
63
- $problem,
64
- $problemId,
65
- $assignmentId,
66
- $currentProblemIndex,
67
- $translationLanguageCode,
68
- $contentLanguageCode,
69
- $isTranslationLocked,
70
- languageChanged,
71
- api,
72
- getGreatWorkFeedbackText,
73
- }: TranslationModelProps<TProblem>) {
74
- this.service = new TranslationService({
75
- preserve: {
76
- map: wordsToPreserve,
77
- replacers: preservedWordsReplacers,
78
- },
79
- providers: [new GoogleTranslationProvider({ api })],
80
- onError: () => this.reset(),
81
- })
82
-
83
- this.service.bindCustomCacheKey(
84
- $problemId,
85
- (problemId, { target }) => `${problemId}::${target}`,
86
- )
87
- this.service.bindTargetLanguage($translationLanguageCode)
88
- if ($contentLanguageCode) {
89
- this.service.bindSourceLanguage($contentLanguageCode)
90
- }
91
-
92
- this.translateAllFx = attach({
93
- source: {
94
- problem: $problem,
95
- translationLanguageCode: $translationLanguageCode,
96
- },
97
- mapParams: (_: void, source) => source,
98
- effect: createEffect(({ problem, translationLanguageCode }: TranslateAllFxParams<TProblem>) => {
99
- if (!problem) return
100
-
101
- const promises: Promise<unknown>[] = [
102
- this.service.translate(problem.richDescription || problem.description, {
103
- cacheKeySuffix: DESCRIPTION_CACHE_KEY_SUFFIX,
104
- }),
105
- this.service.translate(problem.answerVariants, {
106
- cacheKeySuffix: CHOICES_CACHE_KEY_SUFFIX,
107
- }),
108
- ]
109
-
110
- if (getGreatWorkFeedbackText) {
111
- promises.push(
112
- this.service.translate(getGreatWorkFeedbackText(), {
113
- cacheKey: `${translationLanguageCode}${GBD_TEXT_CACHE_SUFFIX}`,
114
- }),
115
- )
116
- }
117
-
118
- return Promise.all(promises)
119
- }),
120
- })
121
-
122
- this.translateFx = createEffect(({ cacheKey, text }: TranslateFxParams) => {
123
- return this.service.translate(text, { cacheKey })
124
- })
125
-
126
- this.$isTranslationActive.on(this.translateAllFx.doneData, () => true)
127
- this.$isTranslationActive.on(this.translateAllFx.fail, () => false)
128
-
129
- split({
130
- source: sample({
131
- clock: this.toggle,
132
- source: this.$isTranslationActive,
133
- }),
134
- match: {
135
- on: (isTranslated) => !isTranslated,
136
- off: (isTranslated) => isTranslated,
137
- },
138
- cases: {
139
- on: this.translateAllFx,
140
- off: this.reset,
141
- },
142
- })
143
-
144
- sample({
145
- clock: languageChanged,
146
- fn: () => false,
147
- target: this.setTranslated,
148
- })
149
-
150
- sample({
151
- clock: [$currentProblemIndex, $assignmentId, this.$isTranslationActive],
152
- source: {
153
- isTranslated: this.$isTranslationActive,
154
- isLocked: $isTranslationLocked,
155
- },
156
- filter: ({ isTranslated, isLocked }) => isLocked || isTranslated,
157
- target: this.translateAllFx,
158
- })
159
-
160
- this.$isTranslationPending = combine(
161
- this.translateAllFx.pending,
162
- this.translateFx.pending,
163
- (isAllPending, isOnePending) => isAllPending || isOnePending,
164
- )
165
- }
166
-
167
- public getTranslated<T extends string | string[]>(key: string): T | undefined {
168
- return this.service.getCached<T>(key)
169
- }
170
-
171
- public clearCache() {
172
- this.service.reset()
173
- }
174
- }
@@ -1,171 +0,0 @@
1
- import { LanguageGlossary } from '../providers/translation.interface'
2
- import { maskSegment, replaceMappedTokens } from '../helpers'
3
- import { Replacement } from '../types'
4
-
5
- const KATEX_REGEX = /\$(.+?)\$/g
6
- const NEWLINE_REGEX = /\n/g
7
- const QUOTE_REGEX = /\\(['"])/g
8
- const DOLLAR_REGEX = /\\\$/gm
9
- const COMMA_REGEX = /,/gm
10
- const DOT_REGEX = /\./gm
11
-
12
- const wrapNoTranslate = (content: string) => `<span translate="no">${content}</span>`
13
-
14
- const KATEX_PLACEHOLDER = wrapNoTranslate('{{@}}')
15
- const NEWLINE__PLACEHOLDER = wrapNoTranslate('{{#}}')
16
- const QUOTE_PLACEHOLDER = wrapNoTranslate('{{""}}')
17
- const DOLLAR_PLACEHOLDER = wrapNoTranslate('{{!}}')
18
- const COMMA_PLACEHOLDER = wrapNoTranslate('{{,}}')
19
- const DOT_PLACEHOLDER = wrapNoTranslate('{{.}}')
20
-
21
- const defaultOrderedReplacersMap = [
22
- [DOLLAR_REGEX, DOLLAR_PLACEHOLDER],
23
- [KATEX_REGEX, KATEX_PLACEHOLDER],
24
- [NEWLINE_REGEX, NEWLINE__PLACEHOLDER],
25
- [QUOTE_REGEX, QUOTE_PLACEHOLDER],
26
- [COMMA_REGEX, COMMA_PLACEHOLDER],
27
- [DOT_REGEX, DOT_PLACEHOLDER],
28
- ] as const
29
-
30
- type SetupPreservableProps = {
31
- glossaryToPreserve: LanguageGlossary
32
- preserveWordsReplacers: [RegExp, string][]
33
- }
34
-
35
- export class TranslationKatexPreprocessor {
36
- private static plaintextConverter: (text: string) => string = (text) => text
37
-
38
- public static setPlaintextConverter(converter: (text: string) => string) {
39
- this.plaintextConverter = converter
40
- }
41
-
42
- public static shouldSkipTranslation(text: string | string[] = '') {
43
- if (Array.isArray(text)) {
44
- return text.every(
45
- (t) => this.isMathExpressionOnly(t) || this.isSingleLetter(t) || this.isMathSymbolsOnly(t),
46
- )
47
- }
48
-
49
- return (
50
- this.isMathExpressionOnly(text) || this.isSingleLetter(text) || this.isMathSymbolsOnly(text)
51
- )
52
- }
53
-
54
- public static isMathExpressionOnly(text: string) {
55
- return /^[\d\s+\-*/^=().\\><%!|]+$/.test(text.trim())
56
- }
57
-
58
- public static isSingleLetter(text: string) {
59
- return /^[a-zA-Z]$/.test(text)
60
- }
61
-
62
- public static isMathSymbolsOnly(text: string) {
63
- const plainText = this.plaintextConverter(text)
64
- const cleanedUp = plainText.replace(/(\\\\|\\|\$|\−|\+|\=|\*|kr|pln|€|£|x|y|\{|\}|\÷)/gi, '')
65
- const mathOnlyRegex = /^(?=.*\d)[0-9+\-×÷*/^().\s]+$/u
66
- return cleanedUp.length > 0 && mathOnlyRegex.test(cleanedUp)
67
- }
68
-
69
- private globalTargetLanguage: string | null = null
70
- private preserveWordsMap: LanguageGlossary = {}
71
- private preserveWordsReplacers: [RegExp, string][] = []
72
-
73
- private normalizePlaceholderSpacing(text: string) {
74
- return text
75
- .replace(/\s+(<span[^>]*translate="no"[^>]*>)/g, '$1')
76
- .replace(/(<\/span>)\s+/g, '$1')
77
- }
78
-
79
- public sanitize(text: string): { sanitized: string; replacements: Replacement[] } {
80
- const language = this.globalTargetLanguage ?? ''
81
- const replacements: Replacement[] = []
82
- let sanitizedText = text
83
-
84
- defaultOrderedReplacersMap.forEach(([regex, placeholder]) => {
85
- sanitizedText = maskSegment({
86
- text: sanitizedText,
87
- regex,
88
- placeholder,
89
- replacements,
90
- })
91
- })
92
-
93
- this.preserveWordsReplacers.forEach(([regex, placeholder]) => {
94
- const preserveWordsMapTarget = this.preserveWordsMap[language]
95
-
96
- sanitizedText = maskSegment({
97
- text: sanitizedText,
98
- regex,
99
- placeholder,
100
- replacements,
101
- shouldSkip: (match) =>
102
- this.skipCustomReplacerSanitizeWithoutGlossary(match, preserveWordsMapTarget),
103
- })
104
- })
105
-
106
- return { sanitized: sanitizedText, replacements }
107
- }
108
-
109
- public restore(text: string, replacements: Replacement[]) {
110
- let restored = this.normalizePlaceholderSpacing(text)
111
- replacements.forEach(({ placeholder, original, leftPad, rightPad }) => {
112
- const wrapped = `${leftPad ? ' ' : ''}${original}${rightPad ? ' ' : ''}`
113
- restored = restored.replace(placeholder, wrapped)
114
- })
115
-
116
- return this.applyPreserved(restored)
117
- }
118
-
119
- public sanitizeBatch(texts: string[]): { sanitized: string[]; replacements: Replacement[][] } {
120
- const sanitized: string[] = []
121
- const replacements: Replacement[][] = []
122
-
123
- texts.forEach((t) => {
124
- const { sanitized: s, replacements: r } = this.sanitize(t)
125
- sanitized.push(s)
126
- replacements.push(r)
127
- })
128
-
129
- return { sanitized, replacements }
130
- }
131
-
132
- public restoreBatch(texts: string[], replacementsArray: Replacement[][]) {
133
- return texts.map((t, i) => {
134
- const restored = this.restore(t, replacementsArray[i])
135
- return this.applyPreserved(restored)
136
- })
137
- }
138
-
139
- // Glossaries apply after translation response and do not remove words from payload.
140
- // This replaces words from the string before sending request to API to completely avoid
141
- // translating it. We use it to avoid "context localization" e.g. Google API changes numbers
142
- // when units are passed and target language is from a different region. We must preserve
143
- // words like "miles" and the exact number in this case.
144
- public setupPreservable({ glossaryToPreserve, preserveWordsReplacers }: SetupPreservableProps) {
145
- this.preserveWordsMap = glossaryToPreserve
146
- this.preserveWordsReplacers = preserveWordsReplacers
147
- }
148
-
149
- public setupTarget(language: string) {
150
- this.globalTargetLanguage = language
151
- }
152
-
153
- private skipCustomReplacerSanitizeWithoutGlossary(
154
- match: string,
155
- preserveWordsMapTarget?: Record<string, string>,
156
- ) {
157
- if (!preserveWordsMapTarget) return true
158
-
159
- const normalized = match.toLowerCase()
160
- const glossaryKeys = Object.keys(preserveWordsMapTarget).map((key) => key.toLowerCase())
161
-
162
- return !glossaryKeys.includes(normalized)
163
- }
164
-
165
- private applyPreserved(restored: string) {
166
- const language = this.globalTargetLanguage ?? ''
167
- const preservedMap = this.preserveWordsMap[language]
168
-
169
- return preservedMap ? replaceMappedTokens(restored, preservedMap) : restored
170
- }
171
- }
@@ -1,148 +0,0 @@
1
- import { Store } from 'effector'
2
- import { TranslationKatexPreprocessor } from './TranslationPreprocessor'
3
- import { LanguageGlossary, TranslationProvider } from '../providers/translation.interface'
4
-
5
- type TranslationServiceProps = {
6
- providers: TranslationProvider[]
7
- preserve?: {
8
- map: LanguageGlossary
9
- replacers: [RegExp, string][]
10
- }
11
- onError?: () => void
12
- }
13
-
14
- export type TranslateConfigProps = {
15
- targetLang?: string
16
- sourceLang?: string
17
- cacheKeySuffix?: string
18
- cacheKey?: string
19
- }
20
-
21
- export class TranslationService {
22
- private readonly preprocessor = new TranslationKatexPreprocessor()
23
- private readonly cache = new Map<string, string | string[]>()
24
- private readonly providers: TranslationProvider[] = []
25
- private readonly onError
26
-
27
- private globalTargetLanguage: string | null = null
28
- private sourceLanguage: string | null = null
29
- private customCacheKeyFn: ((text: string | string[], target: string) => string) | null = null
30
-
31
- constructor({ providers, preserve, onError }: TranslationServiceProps) {
32
- this.providers = providers
33
- this.onError = onError
34
-
35
- if (preserve) {
36
- this.preprocessor.setupPreservable({
37
- glossaryToPreserve: preserve.map,
38
- preserveWordsReplacers: preserve.replacers,
39
- })
40
- }
41
- }
42
-
43
- private getTargetLanguage(targetLang?: string) {
44
- const target = targetLang || this.globalTargetLanguage
45
- if (!target) {
46
- throw new Error(
47
- 'Target language is missing, either provide in arguments or use .bindTargetLanguage()',
48
- )
49
- }
50
- return target
51
- }
52
-
53
- private getProvider(target: string) {
54
- const provider = this.providers.find((svc) => svc.isTargetSupported(target))
55
- if (!provider) throw new Error(`This target language: "${target}" is not supported.`)
56
- return provider
57
- }
58
-
59
- private createCacheKey(text: string | string[], target: string, suffix?: string) {
60
- let baseKey: string
61
-
62
- if (this.customCacheKeyFn) {
63
- baseKey = this.customCacheKeyFn(text, target)
64
- } else {
65
- baseKey = Array.isArray(text) ? `${JSON.stringify(text)}::${target}` : `${text}::${target}`
66
- }
67
-
68
- return suffix ? `${baseKey}${suffix}` : baseKey
69
- }
70
-
71
- public translate = async <T extends string | string[]>(
72
- text: T = '' as T,
73
- config?: TranslateConfigProps,
74
- ): Promise<T> => {
75
- const isArrayInput = Array.isArray(text)
76
- const target = this.getTargetLanguage(config?.targetLang) ?? ''
77
-
78
- if (!text.length || TranslationKatexPreprocessor.shouldSkipTranslation(text)) {
79
- const key = config?.cacheKey ?? this.createCacheKey(text, target, config?.cacheKeySuffix)
80
- if (this.cache.has(key)) return this.cache.get(key) as T
81
-
82
- return text
83
- }
84
-
85
- const source = config?.sourceLang ?? this.sourceLanguage ?? undefined
86
- const provider = this.getProvider(target)
87
- const key = config?.cacheKey ?? this.createCacheKey(text, target, config?.cacheKeySuffix)
88
-
89
- if (this.cache.has(key)) return this.cache.get(key) as T
90
-
91
- let translated: string | string[]
92
-
93
- if (isArrayInput) {
94
- const { sanitized, replacements } = this.preprocessor.sanitizeBatch(text)
95
- const response = await provider.requestBatch(sanitized, target, source)
96
- translated = this.preprocessor.restoreBatch(response, replacements)
97
- } else {
98
- const { sanitized, replacements } = this.preprocessor.sanitize(text)
99
- const response = await provider.request(sanitized, target, source)
100
- translated = this.preprocessor.restore(response, replacements)
101
- }
102
-
103
- this.cache.set(key, translated)
104
-
105
- return translated as T
106
- }
107
-
108
- public bindTargetLanguage<T extends string>(
109
- store: Store<T>,
110
- callback?: (value: T) => string,
111
- ): this {
112
- store.watch((t) => {
113
- const value = callback ? callback(t) : t
114
- this.globalTargetLanguage = value
115
- this.preprocessor.setupTarget(value)
116
- })
117
-
118
- return this
119
- }
120
-
121
- public bindSourceLanguage<T extends string>(store: Store<T>): this {
122
- store.watch((value) => {
123
- this.sourceLanguage = value
124
- })
125
-
126
- return this
127
- }
128
-
129
- public bindCustomCacheKey<T extends string>(
130
- store: Store<T>,
131
- callback: (value: T, input: { text: string | string[]; target: string }) => string,
132
- ): this {
133
- store.watch((t) => {
134
- this.customCacheKeyFn = (text: string | string[], target: string) =>
135
- callback(t, { text, target })
136
- })
137
-
138
- return this
139
- }
140
-
141
- public getCached<T extends string | string[]>(key: string): T | undefined {
142
- return this.cache.get(key) as T | undefined
143
- }
144
-
145
- public reset() {
146
- this.cache.clear()
147
- }
148
- }
@@ -1,87 +0,0 @@
1
- export const wordsToPreserve: Record<string, Record<string, string>> = {
2
- es: { mile: 'milla', miles: 'millas' },
3
- hy: { mile: 'մղոն', miles: 'մղոններ' },
4
- fr: { mile: 'mille', miles: 'milles' },
5
- ru: { mile: 'миля', miles: 'мили' },
6
- ar: { mile: 'ميل', miles: 'أميال' },
7
- is: { mile: 'míla', miles: 'mílur' },
8
- ja: { mile: 'マイル', miles: 'マイル' },
9
- 'zh-Hans': { mile: '英里', miles: '英里' },
10
- af: { mile: 'myl', miles: 'myls' },
11
- ko: { mile: '마일', miles: '마일' },
12
- de: { mile: 'Meile', miles: 'Meilen' },
13
- zu: { mile: 'ileyili', miles: 'amayela' },
14
- 'zh-Hant': { mile: '英里', miles: '英里' },
15
- it: { mile: 'miglio', miles: 'miglia' },
16
- ht: { mile: 'miy', miles: 'miy' },
17
- hi: { mile: 'मील', miles: 'मील' },
18
- pt: { mile: 'milha', miles: 'milhas' },
19
- sq: { mile: 'milje', miles: 'milje' },
20
- el: { mile: 'μίλι', miles: 'μίλια' },
21
- pl: { mile: 'mila', miles: 'mile' },
22
- te: { mile: 'మైలు', miles: 'మైలు‌లు' },
23
- am: { mile: 'ማይል', miles: 'ማይሎች' },
24
- ta: { mile: 'மைல்', miles: 'மைல்கள்' },
25
- vi: { mile: 'dặm', miles: 'dặm' },
26
- uk: { mile: 'миля', miles: 'милі' },
27
- haw: { mile: 'maila', miles: 'maila' },
28
- sv: { mile: 'mile', miles: 'miles' },
29
- bn: { mile: 'মাইল', miles: 'মাইল' },
30
- tl: { mile: 'milya', miles: 'milya' },
31
- ga: { mile: 'míle', miles: 'míleanna' },
32
- nl: { mile: 'mijl', miles: 'mijlen' },
33
- ur: { mile: 'میل', miles: 'میل' },
34
- ee: { mile: 'maili', miles: 'maili' },
35
- en: { mile: 'mile', miles: 'miles' },
36
- az: { mile: 'mil', miles: 'mil' },
37
- gu: { mile: 'માઈલ', miles: 'માઈલ્સ' },
38
- ml: { mile: 'മൈൽ', miles: 'മൈലുകൾ' },
39
- pa: { mile: 'ਮਾਈਲ', miles: 'ਮਾਈਲਾਂ' },
40
- as: { mile: 'মাইল', miles: 'মাইল' },
41
- bm: { mile: 'maili', miles: 'maili' },
42
- he: { mile: 'מייל', miles: 'מיילים' },
43
- fa: { mile: 'مایل', miles: 'مایل‌ها' },
44
- fi: { mile: 'maili', miles: 'mailia' },
45
- tr: { mile: 'mil', miles: 'mil' },
46
- da: { mile: 'mil', miles: 'mil' },
47
- bg: { mile: 'миля', miles: 'мили' },
48
- xh: { mile: 'imayile', miles: 'iimayile' },
49
- yi: { mile: 'מייל', miles: 'מיילן' },
50
- ps: { mile: 'مایل', miles: 'مایلونه' },
51
- mr: { mile: 'मैल', miles: 'मैले' },
52
- eu: { mile: 'mila', miles: 'milak' },
53
- bs: { mile: 'milja', miles: 'milje' },
54
- cs: { mile: 'míle', miles: 'míle' },
55
- yo: { mile: 'maili', miles: 'maili' },
56
- ak: { mile: 'maili', miles: 'maili' },
57
- ro: { mile: 'milă', miles: 'mile' },
58
- mn: { mile: 'миль', miles: 'миль' },
59
- bho: { mile: 'माइल', miles: 'माइल्स' },
60
- ka: { mile: 'მილი', miles: 'მილი' },
61
- ca: { mile: 'milla', miles: 'milles' },
62
- be: { mile: 'міля', miles: 'мілі' },
63
- sw: { mile: 'maili', miles: 'maili' },
64
- eo: { mile: 'mejlo', miles: 'mejloj' },
65
- th: { mile: 'ไมล์', miles: 'ไมล์' },
66
- ay: { mile: 'maili', miles: 'maili' },
67
- doi: { mile: 'माइल', miles: 'माइल्स' },
68
- hr: { mile: 'milja', miles: 'milje' },
69
- sm: { mile: 'maila', miles: 'maila' },
70
- kn: { mile: 'ಮೈಲು', miles: 'ಮೈಲುಗಳು' },
71
- et: { mile: 'miil', miles: 'miilid' },
72
- ceb: { mile: 'milya', miles: 'milya' },
73
- ig: { mile: 'maịlụ', miles: 'maịlụ' },
74
- ne: { mile: 'माइल', miles: 'माइलहरू' },
75
- uz: { mile: 'mil', miles: 'mil' },
76
- cy: { mile: 'filltir', miles: 'mili' },
77
- }
78
-
79
- const MILE_REGEX = /mile/gm
80
- const MILE_PLACEHOLDER = '__!{21_37_70}!__'
81
- const MILES_REGEX = /miles/gm
82
- const MILES_PLACEHOLDER = '__!{21_37_69}!__'
83
-
84
- export const preservedWordsReplacers: [RegExp, string][] = [
85
- [MILES_REGEX, MILES_PLACEHOLDER],
86
- [MILE_REGEX, MILE_PLACEHOLDER],
87
- ]
@@ -1,50 +0,0 @@
1
- import { createEffect, Effect } from 'effector'
2
- import { LanguageGlossary, TranslationProvider } from '../translation.interface'
3
- import { GoogleTranslateLanguage, resolveGoogleLanguageCode } from './supportedLanguages'
4
- import { GoogleTranslateProps, GoogleTranslateResponse } from '../google.types'
5
- import { decodeHtmlEntities } from '../../helpers'
6
-
7
- type GoogleTranslationProviderProps = {
8
- api: {
9
- translateRequest: (payload: GoogleTranslateProps) => Promise<GoogleTranslateResponse>
10
- }
11
- glossaries?: LanguageGlossary
12
- }
13
-
14
- export class GoogleTranslationProvider extends TranslationProvider {
15
- private readonly getTranslationFx: Effect<GoogleTranslateProps, GoogleTranslateResponse>
16
-
17
- constructor({ api, glossaries }: GoogleTranslationProviderProps) {
18
- super({ supportedLanguages: Object.values(GoogleTranslateLanguage), glossaries })
19
- this.getTranslationFx = createEffect(api.translateRequest)
20
- }
21
-
22
- public resolveLanguage(language: string): string | null {
23
- return resolveGoogleLanguageCode(language)
24
- }
25
-
26
- public async request(text: string, targetLanguage: string, sourceLanguage?: string) {
27
- const resolvedTarget = this.resolveLanguage(targetLanguage) ?? targetLanguage
28
- const resolvedSource = sourceLanguage ? this.resolveLanguage(sourceLanguage) ?? undefined : undefined
29
- const response = await this.getTranslationFx({
30
- text: [text],
31
- targetLanguage: resolvedTarget,
32
- sourceLanguage: resolvedSource,
33
- })
34
- const translated = response.data.translations[0]?.translatedText ?? ''
35
- return this.applyGlossary(decodeHtmlEntities(translated), resolvedTarget)
36
- }
37
-
38
- public async requestBatch(text: string[], targetLanguage: string, sourceLanguage?: string) {
39
- const resolvedTarget = this.resolveLanguage(targetLanguage) ?? targetLanguage
40
- const resolvedSource = sourceLanguage ? this.resolveLanguage(sourceLanguage) ?? undefined : undefined
41
- const response = await this.getTranslationFx({
42
- text,
43
- targetLanguage: resolvedTarget,
44
- sourceLanguage: resolvedSource,
45
- })
46
- return response.data.translations.map(({ translatedText }) =>
47
- this.applyGlossary(decodeHtmlEntities(translatedText), resolvedTarget),
48
- )
49
- }
50
- }