Files
orca/src/renderer/src/main.tsx
T
JinjingandOrca 868b024dbe Fix localized strings getting stuck on language switch (#5150)
* Fix localized strings getting stuck on language switch

Replace static module-level translation evaluations with property
getters and i18n hooks to ensure UI elements update dynamically when
the active language changes.

- Convert static configuration properties to dynamic getters.
- Call `useTranslation()` to trigger re-renders on language updates.
- Recreate Tiptap editor extensions when the active language changes
  to refresh frozen placeholder configurations.

* Evaluate localized strings dynamically in static UI structures

- Use ES6 getters with `translate()` in static object maps (such as SSH
  connection status, usage ranges, and feature tour copy) to evaluate
  strings on demand when the language changes.
- Add the `useTranslation()` hook to `LinearIssueMarkdownToolbar` so it
  subscribes directly to translation updates.
- Extract markdown slash command primitives to a separate file to keep
  catalog configuration clean.

---------

Co-authored-by: Orca <help@stably.ai>
2026-06-11 19:45:50 -07:00

64 lines
1.9 KiB
TypeScript

import './assets/main.css'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { useTranslation } from 'react-i18next'
import App from './App'
import { RecoverableRenderErrorBoundary } from './components/error-boundaries/RecoverableRenderErrorBoundary'
import {
installRendererCrashDiagnostics,
recordRendererCrashBreadcrumb
} from './lib/crash-diagnostics'
import { applyDocumentTheme } from './lib/document-theme'
import { shouldEnableReactGrab } from './lib/react-grab-dev-gate'
import { I18nProvider } from './i18n/I18nProvider'
import { translate } from './i18n/i18n'
recordRendererCrashBreadcrumb('renderer_bootstrap_started', { dev: import.meta.env.DEV })
installRendererCrashDiagnostics()
if (
import.meta.env.DEV &&
shouldEnableReactGrab({
dev: import.meta.env.DEV,
enableFlag: import.meta.env.VITE_ENABLE_REACT_GRAB
})
) {
void import('react-grab').then(({ init }) => init())
void import('react-grab/styles.css')
}
applyDocumentTheme('system', { disableTransitions: false })
const rootElement = document.getElementById('root')
if (!rootElement) {
recordRendererCrashBreadcrumb('renderer_root_missing')
throw new Error('Renderer root element not found.')
}
function RendererRoot(): React.JSX.Element {
useTranslation()
return (
<RecoverableRenderErrorBoundary
boundaryId="app.root"
surface="app-root"
title={translate('app.recoverableError.rootTitle', 'Orca hit a renderer error.')}
description={translate(
'app.recoverableError.rootDescription',
'The app shell could not finish rendering. Retry to remount it, or relaunch Orca if the error persists.'
)}
>
<App />
</RecoverableRenderErrorBoundary>
)
}
createRoot(rootElement).render(
<StrictMode>
<I18nProvider>
<RendererRoot />
</I18nProvider>
</StrictMode>
)
recordRendererCrashBreadcrumb('renderer_bootstrap_rendered')