summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/pages
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-01-19 15:50:23 -0600
committerAdam <[email protected]>2026-01-20 17:58:06 -0600
commit0470717c7fbb9ff175b70c6d76ffb2330ef40a1a (patch)
tree291cff80dcd40315572893e1c639463fda635001 /packages/app/src/pages
parent7f50b279962aa76990e2ca2b7eb9bdfd3beafc38 (diff)
downloadopencode-0470717c7fbb9ff175b70c6d76ffb2330ef40a1a.tar.gz
opencode-0470717c7fbb9ff175b70c6d76ffb2330ef40a1a.zip
feat(app): initial i18n stubbing
Diffstat (limited to 'packages/app/src/pages')
-rw-r--r--packages/app/src/pages/layout.tsx36
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/app/src/pages/layout.tsx b/packages/app/src/pages/layout.tsx
index 9d873e08a..bd6c044a8 100644
--- a/packages/app/src/pages/layout.tsx
+++ b/packages/app/src/pages/layout.tsx
@@ -69,6 +69,7 @@ import { DialogSelectDirectory } from "@/components/dialog-select-directory"
import { DialogEditProject } from "@/components/dialog-edit-project"
import { Titlebar } from "@/components/titlebar"
import { useServer } from "@/context/server"
+import { useLanguage, type Locale } from "@/context/language"
export default function Layout(props: ParentProps) {
const [store, setStore, , ready] = persisted(
@@ -109,6 +110,7 @@ export default function Layout(props: ParentProps) {
const dialog = useDialog()
const command = useCommand()
const theme = useTheme()
+ const language = useLanguage()
const initialDir = params.dir
const availableThemeEntries = createMemo(() => Object.entries(theme.themes()))
const colorSchemeOrder: ColorScheme[] = ["system", "light", "dark"]
@@ -268,6 +270,24 @@ export default function Layout(props: ParentProps) {
})
}
+ function setLocale(next: Locale) {
+ if (next === language.locale()) return
+ language.setLocale(next)
+ showToast({
+ title: language.t("toast.language.title"),
+ description: language.t("toast.language.description", { language: language.label(next) }),
+ })
+ }
+
+ function cycleLanguage(direction = 1) {
+ const locales = language.locales
+ const currentIndex = locales.indexOf(language.locale())
+ const nextIndex = currentIndex === -1 ? 0 : (currentIndex + direction + locales.length) % locales.length
+ const next = locales[nextIndex]
+ if (!next) return
+ setLocale(next)
+ }
+
onMount(() => {
if (!platform.checkUpdate || !platform.update || !platform.restart) return
@@ -906,6 +926,22 @@ export default function Layout(props: ParentProps) {
})
}
+ commands.push({
+ id: "language.cycle",
+ title: language.t("command.language.cycle"),
+ category: language.t("command.category.language"),
+ onSelect: () => cycleLanguage(1),
+ })
+
+ for (const locale of language.locales) {
+ commands.push({
+ id: `language.set.${locale}`,
+ title: language.t("command.language.set", { language: language.label(locale) }),
+ category: language.t("command.category.language"),
+ onSelect: () => setLocale(locale),
+ })
+ }
+
return commands
})