mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 03:15:01 +00:00
Moves ~970 strings in session screens, the terminal, agent chat (including the copy mobile used to render straight from shared English records), the browser pane and the file explorer to the translation API, with all ten translations. - Chat tool-run sentences, task lists, receipts, notices and turn status take translated words; the shared sentence joiner accepts an optional continuation so German nouns and Turkish casing survive mid-sentence (desktop unchanged) - "Used the browser" vs "… 21 times" and resolved PR comment headers use explicit keys instead of plural rules, which would drop the count for Russian 21, 31, … - Action sheet rows carry stable ids instead of being keyed by translated labels - Rename inputs keep the raw title rather than a translated placeholder Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
63 lines
2.2 KiB
TypeScript
63 lines
2.2 KiB
TypeScript
import { useEffect, useState } from 'react'
|
|
import { Text, TextInput, View } from 'react-native'
|
|
import type { MobileFilePreviewLineColumn } from './mobile-file-preview-line-column'
|
|
import { textOffsetForLineColumn } from './mobile-file-preview-line-column'
|
|
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
|
|
import { filePreviewStyles as styles } from './mobile-file-preview-styles'
|
|
import { useMobileTranslation } from '../i18n/use-mobile-translation'
|
|
|
|
type Props = {
|
|
title: string
|
|
draftContent: string
|
|
lineColumn: MobileFilePreviewLineColumn | null
|
|
saveError?: string
|
|
onDraftChange: (content: string) => void
|
|
}
|
|
|
|
export function MobileFilePreviewEditableSource({
|
|
title,
|
|
draftContent,
|
|
lineColumn,
|
|
saveError,
|
|
onDraftChange
|
|
}: Props) {
|
|
useMobileColorScheme()
|
|
const t = useMobileTranslation()
|
|
const selectionTargetKey = lineColumn
|
|
? `${title}:${lineColumn.line}:${lineColumn.column ?? ''}`
|
|
: ''
|
|
const [selection, setSelection] = useState<{ start: number; end: number } | null>(null)
|
|
const [revealedTargetKey, setRevealedTargetKey] = useState('')
|
|
|
|
// Reveal the requested position once; subsequent cursor movement owns selection.
|
|
useEffect(() => {
|
|
if (!lineColumn || !selectionTargetKey || revealedTargetKey === selectionTargetKey) {
|
|
return
|
|
}
|
|
const offset = textOffsetForLineColumn(draftContent, lineColumn)
|
|
const initialSelection = { start: offset, end: offset }
|
|
setSelection(initialSelection)
|
|
setRevealedTargetKey(selectionTargetKey)
|
|
}, [draftContent, lineColumn, revealedTargetKey, selectionTargetKey])
|
|
|
|
return (
|
|
<View style={styles.editContainer}>
|
|
{saveError ? <Text style={styles.saveErrorText}>{saveError}</Text> : null}
|
|
<TextInput
|
|
style={styles.editInput}
|
|
value={draftContent}
|
|
onChangeText={onDraftChange}
|
|
multiline
|
|
textAlignVertical="top"
|
|
autoCapitalize="none"
|
|
autoCorrect={false}
|
|
selection={selection ?? undefined}
|
|
onSelectionChange={() => setSelection(null)}
|
|
accessibilityLabel={t('files.filePreviewEditableSource.editorLabel', '{{title}} editor', {
|
|
title
|
|
})}
|
|
/>
|
|
</View>
|
|
)
|
|
}
|