Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
NebulaServices
GitHub Repository: NebulaServices/Nebula
Path: blob/main/src/i18n/utils.ts
976 views
1
import { defaultLang, ui } from "./ui";
2
3
export const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
4
5
export function getLangFromUrl(url: URL) {
6
const [, lang] = url.pathname.split("/");
7
if (lang in ui) return lang as keyof typeof ui;
8
return defaultLang;
9
}
10
11
export function useTranslations(lang: keyof typeof ui) {
12
return function t(key: keyof (typeof ui)[typeof defaultLang]) {
13
return ui[lang][key] || ui[defaultLang][key];
14
};
15
}
16
17