···708708709709 translate: {
710710 os: Platform['OS']
711711- sourceLanguages: string[]
712712- targetLanguage: string
711711+ /**
712712+ * The languages the content might be in, such as the user-supplied
713713+ * language codes on posts. Currently only available on posts.
714714+ */
715715+ possibleSourceLanguages: string[] | undefined
716716+ /**
717717+ * This is the user's configured primary language, which is always defined.
718718+ */
719719+ expectedTargetLanguage: string
720720+ /**
721721+ * The length of the text being translated. We assume shorter texts are
722722+ * more likely to have inaccurate translations.
723723+ */
713724 textLength: number
725725+ googleTranslate: boolean
714726 }
715727 'translate:result': {
716716- method: 'on-device' | 'fallback-alert'
728728+ success: boolean
717729 os: Platform['OS']
718718- sourceSelection: 'automatic' | 'manual'
719719- sourceLanguage: string | null
720720- targetLanguage: string
721721-722722- /* Only relevant to posts */
723723- postLanguages?: string[]
730730+ /**
731731+ * The languages the content might be in, such as the user-supplied
732732+ * language codes on posts. Currently only available on posts.
733733+ */
734734+ possibleSourceLanguages: string[] | undefined
735735+ /**
736736+ * The language we expected the content to be in. This could be based on
737737+ * user selection or on our confidence in the detected language. This is
738738+ * nullable because we may not always have an expected source language.
739739+ */
740740+ expectedSourceLanguage: string | null
741741+ /**
742742+ * This is the user's configured primary language, which is always defined.
743743+ */
744744+ expectedTargetLanguage: string
745745+ /**
746746+ * The language the translation result was actually in. This is nullable
747747+ * because the translation could have failed, in which case we won't have a
748748+ * result source language.
749749+ */
750750+ resultSourceLanguage: string | null
751751+ /**
752752+ * The language the translation result was translated into. This should be
753753+ * the same as `expectedTargetLanguage`, but we include it for completeness
754754+ * and in case there are any edge cases where they differ. This is nullable
755755+ * because if the translation failed, we won't have a result target
756756+ * language.
757757+ */
758758+ resultTargetLanguage: string | null
759759+ /**
760760+ * The length of the text being translated. We assume shorter texts are
761761+ * more likely to have inaccurate translations.
762762+ */
763763+ textLength: number
724764 }
725765 'translate:override': {
726766 os: Platform['OS']
727727- sourceLanguage: string
728728- targetLanguage: string
767767+ /**
768768+ * The languages the content might be in, such as the user-supplied
769769+ * language codes on posts. Currently only available on posts.
770770+ */
771771+ possibleSourceLanguages: string[] | undefined
772772+ /**
773773+ * The language the user has indicated the content is actually in, which
774774+ * may be different from the expected source language if the user is
775775+ * overriding the auto-detected language. This is the language the user
776776+ * wants to translate from after overriding.
777777+ */
778778+ expectedSourceLanguage: string
779779+ /**
780780+ * This is the user's configured primary language, which is always defined.
781781+ */
782782+ expectedTargetLanguage: string
783783+ /**
784784+ * The language the translation result was actually in, which the user now
785785+ * wishes to override.
786786+ */
787787+ resultSourceLanguage: string
729788 }
730789731790 'postMenu:openMuteWordsDialog': {
···2222 /**
2323 * The language to translate the text into.
2424 */
2525- targetLangCode: string
2525+ expectedTargetLanguage: string
2626 /**
2727- * The source language of the text. Will auto-detect if not provided.
2727+ * We auto-detect the source language by default, but the user has the option
2828+ * to specify a source language if they want to. If this value is present, it
2929+ * means the user selected a source language, or we were certain of the
3030+ * source language and want to specify it explicitly.
2831 */
2929- sourceLangCode?: string
3232+ expectedSourceLanguage?: string
3033 /**
3131- * Whether we auto-detected the language or it was selected manually. Defaults to 'automatic'.
3434+ * The languages the content might be in, such as the user-supplied
3535+ * language codes on posts. Currently only available on posts.
3636+ */
3737+ possibleSourceLanguages?: string[]
3838+ /**
3939+ * Override the default behavior and always use Google Translate.
3240 */
3333- sourceSelection?: 'automatic' | 'manual'
4141+ forceGoogleTranslate?: boolean
3442}
35433644export type TranslationOptions = {
4545+ /**
4646+ * A unique key to identify this translation instance e.g. the post URI
4747+ */
3748 key: string
3838- forceGoogleTranslate?: boolean
3949 /**
4040- * The language(s) of the post being translated. Used for analytics purposes
4141- * to understand translation usage patterns better. Optional because it may
4242- * not always be available (e.g. if the post text is empty or if the
4343- * translation is triggered from a non-post
4444- * context).
5050+ * Override the default behavior and always use Google Translate.
4551 */
4646- postLangCodes?: string[]
5252+ forceGoogleTranslate?: boolean
4753}
48544955export type TranslationFunction = (
5050- parameters: TranslationFunctionParams,
5656+ params: TranslationFunctionParams,
5157) => Promise<void>
52585359export type ContextType = {
5460 translationState: Record<string, TranslationState>
5561 translate: (
5656- parameters: TranslationFunctionParams & TranslationOptions,
6262+ params: TranslationFunctionParams,
6363+ options: TranslationOptions,
5764 ) => Promise<void>
5865 clearTranslation: (key: string) => void
5966 acquireTranslation: (key: string) => () => void