@magmamath/students-features 1.3.22 → 1.3.23-rc.10
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/dist/commonjs/features/translation/constants.js +11 -0
- package/dist/commonjs/features/translation/constants.js.map +1 -0
- package/dist/commonjs/features/translation/helpers.js +60 -0
- package/dist/commonjs/features/translation/helpers.js.map +1 -0
- package/dist/commonjs/features/translation/index.js +105 -0
- package/dist/commonjs/features/translation/index.js.map +1 -0
- package/dist/commonjs/features/translation/model/TranslationModel.js +122 -0
- package/dist/commonjs/features/translation/model/TranslationModel.js.map +1 -0
- package/dist/commonjs/features/translation/model/TranslationPreprocessor.js +142 -0
- package/dist/commonjs/features/translation/model/TranslationPreprocessor.js.map +1 -0
- package/dist/commonjs/features/translation/model/TranslationService.js +112 -0
- package/dist/commonjs/features/translation/model/TranslationService.js.map +1 -0
- package/dist/commonjs/features/translation/preserve/wordsToPreserve.js +314 -0
- package/dist/commonjs/features/translation/preserve/wordsToPreserve.js.map +1 -0
- package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js +50 -0
- package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js.map +1 -0
- package/dist/commonjs/features/translation/providers/google/supportedLanguages.js +230 -0
- package/dist/commonjs/features/translation/providers/google/supportedLanguages.js.map +1 -0
- package/dist/commonjs/features/translation/providers/google.types.js +2 -0
- package/dist/commonjs/features/translation/providers/google.types.js.map +1 -0
- package/dist/commonjs/features/translation/providers/translation.interface.js +49 -0
- package/dist/commonjs/features/translation/providers/translation.interface.js.map +1 -0
- package/dist/commonjs/features/translation/types.js +2 -0
- package/dist/commonjs/features/translation/types.js.map +1 -0
- package/dist/commonjs/features/voice/index.js +4 -4
- package/dist/commonjs/features/voice/index.js.map +1 -1
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js +44 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js +142 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js +66 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +59 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useVoiceTranscription.js} +4 -4
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscription.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js +26 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +37 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js +18 -4
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js +6 -2
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → VoiceTranscription.model.js} +4 -4
- package/dist/commonjs/features/voice/playing/model/VoiceTranscription.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.js +62 -0
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.js.map +1 -0
- package/dist/commonjs/features/voice/types.js +6 -1
- package/dist/commonjs/features/voice/types.js.map +1 -1
- package/dist/commonjs/index.js +12 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/module/features/translation/constants.js +7 -0
- package/dist/module/features/translation/constants.js.map +1 -0
- package/dist/module/features/translation/helpers.js +53 -0
- package/dist/module/features/translation/helpers.js.map +1 -0
- package/dist/module/features/translation/index.js +12 -0
- package/dist/module/features/translation/index.js.map +1 -0
- package/dist/module/features/translation/model/TranslationModel.js +117 -0
- package/dist/module/features/translation/model/TranslationModel.js.map +1 -0
- package/dist/module/features/translation/model/TranslationPreprocessor.js +137 -0
- package/dist/module/features/translation/model/TranslationPreprocessor.js.map +1 -0
- package/dist/module/features/translation/model/TranslationService.js +107 -0
- package/dist/module/features/translation/model/TranslationService.js.map +1 -0
- package/dist/module/features/translation/preserve/wordsToPreserve.js +310 -0
- package/dist/module/features/translation/preserve/wordsToPreserve.js.map +1 -0
- package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js +45 -0
- package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js.map +1 -0
- package/dist/module/features/translation/providers/google/supportedLanguages.js +225 -0
- package/dist/module/features/translation/providers/google/supportedLanguages.js.map +1 -0
- package/dist/module/features/translation/providers/google.types.js +2 -0
- package/dist/module/features/translation/providers/google.types.js.map +1 -0
- package/dist/module/features/translation/providers/translation.interface.js +44 -0
- package/dist/module/features/translation/providers/translation.interface.js.map +1 -0
- package/dist/module/features/translation/types.js +2 -0
- package/dist/module/features/translation/types.js.map +1 -0
- package/dist/module/features/voice/index.js +1 -1
- package/dist/module/features/voice/index.js.map +1 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js +38 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceTranscription.js +134 -0
- package/dist/module/features/voice/playing/components/VoiceTranscription.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js +58 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +51 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useVoiceTranscription.js} +2 -2
- package/dist/module/features/voice/playing/hooks/useVoiceTranscription.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js +21 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +32 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +1 -0
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js +18 -4
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -1
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js +6 -2
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/module/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → VoiceTranscription.model.js} +2 -2
- package/dist/module/features/voice/playing/model/VoiceTranscription.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.js +57 -0
- package/dist/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.js.map +1 -0
- package/dist/module/features/voice/types.js +5 -0
- package/dist/module/features/voice/types.js.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/typescript/commonjs/features/translation/constants.d.ts +5 -0
- package/dist/typescript/commonjs/features/translation/constants.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/helpers.d.ts +9 -0
- package/dist/typescript/commonjs/features/translation/helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/index.d.ts +12 -0
- package/dist/typescript/commonjs/features/translation/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts +33 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts +34 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts +40 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts +3 -0
- package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts +17 -0
- package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts +209 -0
- package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts +15 -0
- package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts +30 -0
- package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/types.d.ts +27 -0
- package/dist/typescript/commonjs/features/translation/types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/index.d.ts +1 -1
- package/dist/typescript/commonjs/features/voice/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts +8 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts +16 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +10 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +12 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -0
- package/dist/typescript/{module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts → commonjs/features/voice/playing/hooks/useVoiceTranscription.d.ts} +3 -3
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscription.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts +10 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts +12 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts +4 -2
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.d.ts → VoiceTranscription.model.d.ts} +2 -2
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscription.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts +25 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/types.d.ts +9 -1
- package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -1
- package/dist/typescript/commonjs/index.d.ts +1 -0
- package/dist/typescript/commonjs/index.d.ts.map +1 -1
- package/dist/typescript/module/features/translation/constants.d.ts +5 -0
- package/dist/typescript/module/features/translation/constants.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/helpers.d.ts +9 -0
- package/dist/typescript/module/features/translation/helpers.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/index.d.ts +12 -0
- package/dist/typescript/module/features/translation/index.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/model/TranslationModel.d.ts +33 -0
- package/dist/typescript/module/features/translation/model/TranslationModel.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts +34 -0
- package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/model/TranslationService.d.ts +40 -0
- package/dist/typescript/module/features/translation/model/TranslationService.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts +3 -0
- package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts +17 -0
- package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts +209 -0
- package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/google.types.d.ts +15 -0
- package/dist/typescript/module/features/translation/providers/google.types.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/translation.interface.d.ts +30 -0
- package/dist/typescript/module/features/translation/providers/translation.interface.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/types.d.ts +27 -0
- package/dist/typescript/module/features/translation/types.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/index.d.ts +1 -1
- package/dist/typescript/module/features/voice/index.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts +8 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts +16 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +10 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +12 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -0
- package/dist/typescript/{commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts → module/features/voice/playing/hooks/useVoiceTranscription.d.ts} +3 -3
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscription.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts +10 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts +12 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +1 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts +4 -2
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.d.ts → VoiceTranscription.model.d.ts} +2 -2
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscription.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts +25 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/types.d.ts +9 -1
- package/dist/typescript/module/features/voice/types.d.ts.map +1 -1
- package/dist/typescript/module/index.d.ts +1 -0
- package/dist/typescript/module/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/translation/constants.ts +4 -0
- package/src/features/translation/helpers.ts +63 -0
- package/src/features/translation/index.ts +30 -0
- package/src/features/translation/model/TranslationModel.ts +174 -0
- package/src/features/translation/model/TranslationPreprocessor.ts +171 -0
- package/src/features/translation/model/TranslationService.ts +148 -0
- package/src/features/translation/preserve/wordsToPreserve.ts +87 -0
- package/src/features/translation/providers/google/GoogleTranslationProvider.ts +50 -0
- package/src/features/translation/providers/google/supportedLanguages.ts +229 -0
- package/src/features/translation/providers/google.types.ts +16 -0
- package/src/features/translation/providers/translation.interface.ts +63 -0
- package/src/features/translation/types.ts +30 -0
- package/src/features/voice/index.ts +1 -1
- package/src/features/voice/playing/components/VoiceTranscriptContent.tsx +37 -0
- package/src/features/voice/playing/components/VoiceTranscription.tsx +175 -0
- package/src/features/voice/playing/components/VoiceTranscriptionCollapsible.tsx +59 -0
- package/src/features/voice/playing/components/VoiceTranscriptionHeaderActions.tsx +62 -0
- package/src/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.ts → useVoiceTranscription.ts} +2 -2
- package/src/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.ts +32 -0
- package/src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts +44 -0
- package/src/features/voice/playing/model/TranscriptionsDownloaderModel.ts +12 -5
- package/src/features/voice/playing/model/VoicePlayer.model.ts +7 -2
- package/src/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.ts → VoiceTranscription.model.ts} +2 -2
- package/src/features/voice/playing/model/VoiceTranscriptionTranslation.model.ts +75 -0
- package/src/features/voice/types.ts +15 -0
- package/src/index.ts +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js +0 -245
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +0 -109
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +0 -1
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +0 -34
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +0 -1
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +0 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js +0 -238
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +0 -103
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +0 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +0 -29
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +0 -1
- package/dist/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +0 -16
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +0 -12
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +0 -11
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +0 -16
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +0 -12
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +0 -11
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +0 -1
- package/src/features/voice/playing/components/VoiceTranscriptionsDropdown.tsx +0 -296
- package/src/features/voice/playing/components/VoiceTranscriptionsDropdownItem.tsx +0 -128
- package/src/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.ts +0 -40
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
]
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
const SUPPORTED_CODES = new Set<string>()
|
|
2
|
+
const NAME_TO_CODE: Record<string, string> = {}
|
|
3
|
+
|
|
4
|
+
const normalizeLanguageName = (language: string): string =>
|
|
5
|
+
language
|
|
6
|
+
.trim()
|
|
7
|
+
.toUpperCase()
|
|
8
|
+
.replace(/[\s()-]+/g, '_')
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolves an arbitrary language input (ISO code, locale, or English name) to the
|
|
12
|
+
* Google Translate ISO code. Returns null when the language is not supported.
|
|
13
|
+
*
|
|
14
|
+
* Examples:
|
|
15
|
+
* "en" → "en"
|
|
16
|
+
* "en-SE" → "en" (base fallback)
|
|
17
|
+
* "zh-CN" → "zh-CN" (exact match)
|
|
18
|
+
* "Spanish" → "es" (name lookup)
|
|
19
|
+
* "Chinese Simplified" → "zh-CN"
|
|
20
|
+
*/
|
|
21
|
+
export const resolveGoogleLanguageCode = (language?: string | null): string | null => {
|
|
22
|
+
if (!language) return null
|
|
23
|
+
if (SUPPORTED_CODES.has(language)) return language
|
|
24
|
+
const base = language.split('-')[0]
|
|
25
|
+
if (base !== language && SUPPORTED_CODES.has(base)) return base
|
|
26
|
+
return NAME_TO_CODE[normalizeLanguageName(language)] ?? null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const GoogleTranslateLanguage = {
|
|
30
|
+
ABKHAZ: 'ab',
|
|
31
|
+
ACEHNESE: 'ace',
|
|
32
|
+
ACHOLI: 'ach',
|
|
33
|
+
AFRIKAANS: 'af',
|
|
34
|
+
ALBANIAN: 'sq',
|
|
35
|
+
ALUR: 'alz',
|
|
36
|
+
AMHARIC: 'am',
|
|
37
|
+
ARABIC: 'ar',
|
|
38
|
+
ARMENIAN: 'hy',
|
|
39
|
+
ASSAMESE: 'as',
|
|
40
|
+
AWADHI: 'awa',
|
|
41
|
+
AYMARA: 'ay',
|
|
42
|
+
AZERBAIJANI: 'az',
|
|
43
|
+
BALINESE: 'ban',
|
|
44
|
+
BAMBARA: 'bm',
|
|
45
|
+
BASHKIR: 'ba',
|
|
46
|
+
BASQUE: 'eu',
|
|
47
|
+
BATAK_KARO: 'btx',
|
|
48
|
+
BATAK_SIMALUNGUN: 'bts',
|
|
49
|
+
BATAK_TOBA: 'bbc',
|
|
50
|
+
BELARUSIAN: 'be',
|
|
51
|
+
BEMBA: 'bem',
|
|
52
|
+
BENGALI: 'bn',
|
|
53
|
+
BETAWI: 'bew',
|
|
54
|
+
BHOJPURI: 'bho',
|
|
55
|
+
BIKOL: 'bik',
|
|
56
|
+
BOSNIAN: 'bs',
|
|
57
|
+
BRETON: 'br',
|
|
58
|
+
BULGARIAN: 'bg',
|
|
59
|
+
BURMESE: 'my',
|
|
60
|
+
BURYAT: 'bua',
|
|
61
|
+
CANTONESE: 'yue',
|
|
62
|
+
CATALAN: 'ca',
|
|
63
|
+
CEBUANO: 'ceb',
|
|
64
|
+
CHICHEWA_NYANJA: 'ny',
|
|
65
|
+
CHINESE_SIMPLIFIED: 'zh-CN',
|
|
66
|
+
CHINESE_TRADITIONAL: 'zh-TW',
|
|
67
|
+
CHUVASH: 'cv',
|
|
68
|
+
CORSICAN: 'co',
|
|
69
|
+
CRIMEAN_TATAR: 'crh',
|
|
70
|
+
CROATIAN: 'hr',
|
|
71
|
+
CZECH: 'cs',
|
|
72
|
+
DANISH: 'da',
|
|
73
|
+
DINKA: 'din',
|
|
74
|
+
DIVEHI: 'dv',
|
|
75
|
+
DOGRI: 'doi',
|
|
76
|
+
DOMBE: 'dov',
|
|
77
|
+
DUTCH: 'nl',
|
|
78
|
+
DZONGKHA: 'dz',
|
|
79
|
+
ENGLISH: 'en',
|
|
80
|
+
ESPERANTO: 'eo',
|
|
81
|
+
ESTONIAN: 'et',
|
|
82
|
+
EWE: 'ee',
|
|
83
|
+
FIJIAN: 'fj',
|
|
84
|
+
FILIPINO_TAGALOG: 'fil',
|
|
85
|
+
FINNISH: 'fi',
|
|
86
|
+
FRENCH: 'fr',
|
|
87
|
+
FRENCH_CANADA: 'fr-CA',
|
|
88
|
+
FRENCH_FRANCE: 'fr-FR',
|
|
89
|
+
FRISIAN: 'fy',
|
|
90
|
+
FULFULDE: 'ff',
|
|
91
|
+
GA: 'gaa',
|
|
92
|
+
GALICIAN: 'gl',
|
|
93
|
+
GANDA_LUGANDA: 'lg',
|
|
94
|
+
GEORGIAN: 'ka',
|
|
95
|
+
GERMAN: 'de',
|
|
96
|
+
GREEK: 'el',
|
|
97
|
+
GUARANI: 'gn',
|
|
98
|
+
GUJARATI: 'gu',
|
|
99
|
+
HAITIAN_CREOLE: 'ht',
|
|
100
|
+
HAKHA_CHIN: 'cnh',
|
|
101
|
+
HAUSA: 'ha',
|
|
102
|
+
HAWAIIAN: 'haw',
|
|
103
|
+
HEBREW: 'he',
|
|
104
|
+
HILIGAYNON: 'hil',
|
|
105
|
+
HINDI: 'hi',
|
|
106
|
+
HMONG: 'hmn',
|
|
107
|
+
HUNGARIAN: 'hu',
|
|
108
|
+
HUNSRIK: 'hrx',
|
|
109
|
+
ICELANDIC: 'is',
|
|
110
|
+
IGBO: 'ig',
|
|
111
|
+
ILOKO: 'ilo',
|
|
112
|
+
INDONESIAN: 'id',
|
|
113
|
+
IRISH: 'ga',
|
|
114
|
+
ITALIAN: 'it',
|
|
115
|
+
JAPANESE: 'ja',
|
|
116
|
+
JAVANESE: 'jw',
|
|
117
|
+
KANNADA: 'kn',
|
|
118
|
+
KAPAMPANGAN: 'pam',
|
|
119
|
+
KAZAKH: 'kk',
|
|
120
|
+
KHMER: 'km',
|
|
121
|
+
KIGA: 'cgg',
|
|
122
|
+
KINYARWANDA: 'rw',
|
|
123
|
+
KITUBA: 'ktu',
|
|
124
|
+
KONKANI: 'gom',
|
|
125
|
+
KOREAN: 'ko',
|
|
126
|
+
KRIO: 'kri',
|
|
127
|
+
KURMANJI: 'ku',
|
|
128
|
+
KYRGYZ: 'ky',
|
|
129
|
+
LAO: 'lo',
|
|
130
|
+
LATGALIAN: 'ltg',
|
|
131
|
+
LATIN: 'la',
|
|
132
|
+
LATVIAN: 'lv',
|
|
133
|
+
LIGURIAN: 'lij',
|
|
134
|
+
LIMBURGAN: 'li',
|
|
135
|
+
LINGALA: 'ln',
|
|
136
|
+
LITHUANIAN: 'lt',
|
|
137
|
+
LOMBARD: 'lmo',
|
|
138
|
+
LUO: 'luo',
|
|
139
|
+
LUXEMBOURGISH: 'lb',
|
|
140
|
+
MACEDONIAN: 'mk',
|
|
141
|
+
MAITHILI: 'mai',
|
|
142
|
+
MAKASSAR: 'mak',
|
|
143
|
+
MALAGASY: 'mg',
|
|
144
|
+
MALAY: 'ms',
|
|
145
|
+
MALAYALAM: 'ml',
|
|
146
|
+
MALAY_JAWI: 'ms-Arab',
|
|
147
|
+
MALTESE: 'mt',
|
|
148
|
+
MAORI: 'mi',
|
|
149
|
+
MARATHI: 'mr',
|
|
150
|
+
MEADOW_MARI: 'chm',
|
|
151
|
+
MEITEILON_MANIPURI: 'mni-Mtei',
|
|
152
|
+
MINANG: 'min',
|
|
153
|
+
MIZO: 'lus',
|
|
154
|
+
MONGOLIAN: 'mn',
|
|
155
|
+
NDEBELE_SOUTH: 'nr',
|
|
156
|
+
NEPALBHASA_NEWARI: 'new',
|
|
157
|
+
NEPALI: 'ne',
|
|
158
|
+
NORTHERN_SOTHO: 'nso',
|
|
159
|
+
NORWEGIAN: 'no',
|
|
160
|
+
NUER: 'nus',
|
|
161
|
+
OCCITAN: 'oc',
|
|
162
|
+
ODIA: 'or',
|
|
163
|
+
OROMO: 'om',
|
|
164
|
+
PANGASINAN: 'pag',
|
|
165
|
+
PAPIAMENTO: 'pap',
|
|
166
|
+
PASHTO: 'ps',
|
|
167
|
+
PERSIAN: 'fa',
|
|
168
|
+
POLISH: 'pl',
|
|
169
|
+
PORTUGUESE: 'pt',
|
|
170
|
+
PORTUGUESE_BRAZIL: 'pt-BR',
|
|
171
|
+
PORTUGUESE_PORTUGAL: 'pt-PT',
|
|
172
|
+
PUNJABI: 'pa',
|
|
173
|
+
PUNJABI_SHAHMUKHI: 'pa-Arab',
|
|
174
|
+
QUECHUA: 'qu',
|
|
175
|
+
ROMANI: 'rom',
|
|
176
|
+
ROMANIAN: 'ro',
|
|
177
|
+
RUNDI: 'rn',
|
|
178
|
+
RUSSIAN: 'ru',
|
|
179
|
+
SAMOAN: 'sm',
|
|
180
|
+
SANGO: 'sg',
|
|
181
|
+
SANSKRIT: 'sa',
|
|
182
|
+
SCOTS_GAELIC: 'gd',
|
|
183
|
+
SERBIAN: 'sr',
|
|
184
|
+
SESOTHO: 'st',
|
|
185
|
+
SEYCHELLOIS_CREOLE: 'crs',
|
|
186
|
+
SHAN: 'shn',
|
|
187
|
+
SHONA: 'sn',
|
|
188
|
+
SICILIAN: 'scn',
|
|
189
|
+
SILESIAN: 'szl',
|
|
190
|
+
SINDHI: 'sd',
|
|
191
|
+
SINHALA: 'si',
|
|
192
|
+
SLOVAK: 'sk',
|
|
193
|
+
SLOVENIAN: 'sl',
|
|
194
|
+
SOMALI: 'so',
|
|
195
|
+
SORANI: 'ckb',
|
|
196
|
+
SPANISH: 'es',
|
|
197
|
+
SUNDANESE: 'su',
|
|
198
|
+
SWAHILI: 'sw',
|
|
199
|
+
SWATI: 'ss',
|
|
200
|
+
SWEDISH: 'sv',
|
|
201
|
+
TAJIK: 'tg',
|
|
202
|
+
TAMIL: 'ta',
|
|
203
|
+
TATAR: 'tt',
|
|
204
|
+
TELUGU: 'te',
|
|
205
|
+
TETUM: 'tet',
|
|
206
|
+
THAI: 'th',
|
|
207
|
+
TIGRINYA: 'ti',
|
|
208
|
+
TSONGA: 'ts',
|
|
209
|
+
TSWANA: 'tn',
|
|
210
|
+
TURKISH: 'tr',
|
|
211
|
+
TURKMEN: 'tk',
|
|
212
|
+
TWI_AKAN: 'ak',
|
|
213
|
+
UKRAINIAN: 'uk',
|
|
214
|
+
URDU: 'ur',
|
|
215
|
+
UYGHUR: 'ug',
|
|
216
|
+
UZBEK: 'uz',
|
|
217
|
+
VIETNAMESE: 'vi',
|
|
218
|
+
WELSH: 'cy',
|
|
219
|
+
XHOSA: 'xh',
|
|
220
|
+
YIDDISH: 'yi',
|
|
221
|
+
YORUBA: 'yo',
|
|
222
|
+
YUCATEC_MAYA: 'yua',
|
|
223
|
+
ZULU: 'zu',
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
Object.entries(GoogleTranslateLanguage).forEach(([name, code]) => {
|
|
227
|
+
SUPPORTED_CODES.add(code)
|
|
228
|
+
NAME_TO_CODE[name] = code
|
|
229
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type GoogleTranslateProps = {
|
|
2
|
+
text: string[]
|
|
3
|
+
targetLanguage: string
|
|
4
|
+
sourceLanguage?: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type GoogleTranslation = {
|
|
8
|
+
translatedText: string
|
|
9
|
+
detectedSourceLanguage: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type GoogleTranslateResponse = {
|
|
13
|
+
data: {
|
|
14
|
+
translations: GoogleTranslation[]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { replaceMappedTokens } from '../helpers'
|
|
2
|
+
|
|
3
|
+
export type LanguageGlossary = {
|
|
4
|
+
[languageCode: string]: Record<string, string>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
type TranslationProviderProps = {
|
|
8
|
+
supportedLanguages: string[]
|
|
9
|
+
glossaries?: LanguageGlossary
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export abstract class TranslationProvider {
|
|
13
|
+
protected readonly supportedLanguages: ReadonlySet<string>
|
|
14
|
+
protected readonly glossaries: LanguageGlossary = {}
|
|
15
|
+
|
|
16
|
+
protected constructor({ supportedLanguages, glossaries = {} }: TranslationProviderProps) {
|
|
17
|
+
this.supportedLanguages = new Set(supportedLanguages)
|
|
18
|
+
this.glossaries = glossaries
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public abstract request(
|
|
22
|
+
text: string,
|
|
23
|
+
targetLanguage: string,
|
|
24
|
+
sourceLanguage?: string,
|
|
25
|
+
): Promise<string>
|
|
26
|
+
public abstract requestBatch(
|
|
27
|
+
text: string[],
|
|
28
|
+
targetLanguage: string,
|
|
29
|
+
sourceLanguage?: string,
|
|
30
|
+
): Promise<string[]>
|
|
31
|
+
|
|
32
|
+
public isTargetSupported(language: string) {
|
|
33
|
+
return this.resolveLanguage(language) !== null
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns the provider-supported variant of `language`, falling back to the base
|
|
38
|
+
* language part (e.g. "en-SE" → "en") when the exact locale is not listed.
|
|
39
|
+
* Subclasses may override to add their own resolution (e.g. language names).
|
|
40
|
+
* Returns null when the language cannot be resolved.
|
|
41
|
+
*/
|
|
42
|
+
public resolveLanguage(language: string): string | null {
|
|
43
|
+
if (!language) return null
|
|
44
|
+
if (this.supportedLanguages.has(language)) return language
|
|
45
|
+
const base = language.split('-')[0]
|
|
46
|
+
if (base !== language && this.supportedLanguages.has(base)) return base
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public getSupportedLanguages() {
|
|
51
|
+
return this.supportedLanguages.values()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Replaces full standalone words in text using a custom glossary for the target language,
|
|
56
|
+
* matching words like "Hello", or "Hej" regardless of case, but not when they appear inside other words.
|
|
57
|
+
*/
|
|
58
|
+
public applyGlossary(text: string, targetLanguage: string): string {
|
|
59
|
+
const glossary = this.glossaries[targetLanguage]
|
|
60
|
+
if (!glossary) return text
|
|
61
|
+
return replaceMappedTokens(text, glossary)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type TranslatableProblem = {
|
|
2
|
+
description: string
|
|
3
|
+
richDescription?: string
|
|
4
|
+
answerVariants: string[]
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type TranslateAllFxParams<TProblem extends TranslatableProblem = TranslatableProblem> = {
|
|
8
|
+
problem: TProblem | null
|
|
9
|
+
translationLanguageCode?: string | null
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type TranslateFxParams = {
|
|
13
|
+
cacheKey: string
|
|
14
|
+
text: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type Replacement = {
|
|
18
|
+
placeholder: string
|
|
19
|
+
original: string
|
|
20
|
+
leftPad?: boolean
|
|
21
|
+
rightPad?: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type MaskSegmentParams = {
|
|
25
|
+
text: string
|
|
26
|
+
regex: RegExp
|
|
27
|
+
placeholder: string
|
|
28
|
+
replacements: Replacement[]
|
|
29
|
+
shouldSkip?: (match: string) => boolean
|
|
30
|
+
}
|
|
@@ -4,7 +4,7 @@ export * from './recording/modal/VoiceRecordDeleteModal'
|
|
|
4
4
|
export * from './recording/modal/VoiceRecordUndoModal'
|
|
5
5
|
|
|
6
6
|
export * from './playing/model/VoicePlayer.model'
|
|
7
|
-
export * from './playing/components/
|
|
7
|
+
export * from './playing/components/VoiceTranscription'
|
|
8
8
|
|
|
9
9
|
export * from './playing/components/VoiceIcon'
|
|
10
10
|
export * from './constants'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { COLORS, Loader, LoaderColor, LoaderSize, Typography } from '@magmamath/react-native-ui'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { StyleSheet, View } from 'react-native'
|
|
4
|
+
|
|
5
|
+
type VoiceTranscriptContentProps = {
|
|
6
|
+
text: string
|
|
7
|
+
isLoading: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const VoiceTranscriptContent = ({ text, isLoading }: VoiceTranscriptContentProps) => {
|
|
11
|
+
if (isLoading) {
|
|
12
|
+
return (
|
|
13
|
+
<View style={styles.loaderContainer}>
|
|
14
|
+
<Loader size={LoaderSize.SMALL} color={LoaderColor.BLUE} />
|
|
15
|
+
</View>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Typography variant="h8" style={styles.text}>
|
|
21
|
+
{text}
|
|
22
|
+
</Typography>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const styles = StyleSheet.create({
|
|
27
|
+
text: {
|
|
28
|
+
color: COLORS.NEUTRAL_7,
|
|
29
|
+
paddingHorizontal: 8,
|
|
30
|
+
paddingVertical: 8,
|
|
31
|
+
},
|
|
32
|
+
loaderContainer: {
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
paddingVertical: 8,
|
|
36
|
+
},
|
|
37
|
+
})
|