Bluesky app fork with some witchin' additions 馃挮
witchsky.app
bluesky
fork
client
1import {type TranslationTaskResult} from '@bsky.app/expo-translate-text/build/ExpoTranslateText.types'
2
3export type TranslationState =
4 | {status: 'idle'}
5 | {status: 'loading'}
6 | {
7 status: 'success'
8 translatedText: string
9 sourceLanguage: TranslationTaskResult['sourceLanguage']
10 targetLanguage: TranslationTaskResult['targetLanguage']
11 }
12 | {
13 status: 'error'
14 message: string
15 }
16
17export type TranslationFunctionParams = {
18 /**
19 * The text to be translated.
20 */
21 text: string
22 /**
23 * The language to translate the text into.
24 */
25 expectedTargetLanguage: string
26 /**
27 * We auto-detect the source language by default, but the user has the option
28 * to specify a source language if they want to. If this value is present, it
29 * means the user selected a source language, or we were certain of the
30 * source language and want to specify it explicitly.
31 */
32 expectedSourceLanguage?: string
33 /**
34 * The languages the content might be in, such as the user-supplied
35 * language codes on posts. Currently only available on posts.
36 */
37 possibleSourceLanguages?: string[]
38 /**
39 * Override the default behavior and always use Google Translate.
40 */
41 forceGoogleTranslate?: boolean
42}
43
44export type TranslationOptions = {
45 /**
46 * A unique key to identify this translation instance e.g. the post URI
47 */
48 key: string
49 /**
50 * Override the default behavior and always use Google Translate.
51 */
52 forceGoogleTranslate?: boolean
53}
54
55export type TranslationFunction = (
56 params: TranslationFunctionParams,
57) => Promise<void>
58
59export type ContextType = {
60 translationState: Record<string, TranslationState>
61 translate: (
62 params: TranslationFunctionParams,
63 options: TranslationOptions,
64 ) => Promise<void>
65 clearTranslation: (key: string) => void
66 acquireTranslation: (key: string) => () => void
67}