feat(stats): add i18n support (#33693)
This commit is contained in:
@@ -2,21 +2,17 @@ import { MetaProvider, Meta, Title } from "@solidjs/meta"
|
||||
import { Router } from "@solidjs/router"
|
||||
import { FileRoutes } from "@solidjs/start/router"
|
||||
import { Suspense } from "solid-js"
|
||||
import { I18nProvider, useI18n } from "./context/i18n"
|
||||
import { LanguageProvider } from "./context/language"
|
||||
import { strip } from "./lib/language"
|
||||
import "./app.css"
|
||||
|
||||
function stripLocaleDataPrefix(pathname: string) {
|
||||
const value = pathname.startsWith("/") ? pathname : `/${pathname}`
|
||||
return value.replace(/^\/[^/]+(?=\/data(?:\/|$))/, "")
|
||||
}
|
||||
|
||||
function AppMeta() {
|
||||
const i18n = useI18n()
|
||||
return (
|
||||
<>
|
||||
<Title>AI Model Usage Rankings | OpenCode Data</Title>
|
||||
<Meta
|
||||
name="description"
|
||||
content="Explore OpenCode Go usage across AI models, including token volume, rankings, market share, token pricing, session cost, cache ratio, and geo breakdowns."
|
||||
/>
|
||||
<Title>{i18n.t("app.title")}</Title>
|
||||
<Meta name="description" content={i18n.t("app.description")} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -26,12 +22,16 @@ export default function App() {
|
||||
<Router
|
||||
base={import.meta.env.BASE_URL.replace(/\/$/, "")}
|
||||
explicitLinks={true}
|
||||
transformUrl={stripLocaleDataPrefix}
|
||||
transformUrl={strip}
|
||||
root={(props) => (
|
||||
<MetaProvider>
|
||||
<AppMeta />
|
||||
<Suspense>{props.children}</Suspense>
|
||||
</MetaProvider>
|
||||
<LanguageProvider>
|
||||
<I18nProvider>
|
||||
<MetaProvider>
|
||||
<AppMeta />
|
||||
<Suspense>{props.children}</Suspense>
|
||||
</MetaProvider>
|
||||
</I18nProvider>
|
||||
</LanguageProvider>
|
||||
)}
|
||||
>
|
||||
<FileRoutes />
|
||||
|
||||
Reference in New Issue
Block a user