Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

841 B
Raw Blame
import { useMemo, useSyncExternalStore } from 'react'
import type { SupportedUiLocale } from '../../../src/shared/ui-locale'
import {
  getMobileUiLocale,
  getMobileUiRevision,
  subscribeMobileUiLanguage,
  translate,
  type Translate
} from './mobile-i18n'

// Call in every component that renders translated text. The returned function changes identity
// with the language, so memos and callbacks that list it as a dependency recompute.
export function useMobileTranslation(): Translate {
  const revision = useSyncExternalStore(subscribeMobileUiLanguage, getMobileUiRevision)
  return useMemo<Translate>(
    () => (key, fallback, options) => translate(key, fallback, options),
    [revision]
  )
}

export function useMobileUiLocale(): SupportedUiLocale {
  return useSyncExternalStore(subscribeMobileUiLanguage, getMobileUiLocale)
}