* feat: add README for @cio/db package and remove existingAccounts.json * load session, load profile and organization, add create profile hook * chore: cache session request The trick was passing all the cookies to the backend. Previously I was only passing the better-auth.session_token and not better-auth.session_data. Read about the difference here https://www.better-auth.com/docs/concepts/cookies#custom-cookies * feat: login, logout, onboarding, verify email, reset password. * feat: complete change email and email verification * feat: standardise how we make rpc calls and create org endpoints * fix ui errors * fix: handle potential undefined customerId and standardize avatar URL property * refactor: standardize custom domain handling and update telegram chat ID references * chore: add tailwind prefix to @cio/ui this fixed the media query issues because @cio/ui classes were overriding this dashboard tailwind build * chore: clean up org sidebar * chore: persist mode state * feat: implement order breadcrumbs * chore: upgrade to better auth 1.4 * chore: address common auth flow bugs and setup app for others to setup locally.
99 lines
2.3 KiB
TypeScript
99 lines
2.3 KiB
TypeScript
import type { TLocale } from '@cio/db/types';
|
|
import i18n from '@sveltekit-i18n/base';
|
|
import parser from '@sveltekit-i18n/parser-icu';
|
|
import { writable } from 'svelte/store';
|
|
|
|
export const config = {
|
|
parser: parser(),
|
|
loaders: [
|
|
{
|
|
locale: 'en',
|
|
key: '',
|
|
loader: async () => (await import('../translations/en.json')).default
|
|
},
|
|
{
|
|
locale: 'hi',
|
|
key: '',
|
|
loader: async () => (await import('../translations/hi.json')).default
|
|
},
|
|
{
|
|
locale: 'fr',
|
|
key: '',
|
|
loader: async () => (await import('../translations/fr.json')).default
|
|
},
|
|
{
|
|
locale: 'pl',
|
|
key: '',
|
|
loader: async () => (await import('../translations/pl.json')).default
|
|
},
|
|
{
|
|
locale: 'pt',
|
|
key: '',
|
|
loader: async () => (await import('../translations/pt.json')).default
|
|
},
|
|
{
|
|
locale: 'de',
|
|
key: '',
|
|
loader: async () => (await import('../translations/de.json')).default
|
|
},
|
|
{
|
|
locale: 'vi',
|
|
key: '',
|
|
loader: async () => (await import('../translations/vi.json')).default
|
|
},
|
|
{
|
|
locale: 'ru',
|
|
key: '',
|
|
loader: async () => (await import('../translations/ru.json')).default
|
|
},
|
|
{
|
|
locale: 'es',
|
|
key: '',
|
|
loader: async () => (await import('../translations/es.json')).default
|
|
},
|
|
{
|
|
locale: 'da',
|
|
key: '',
|
|
loader: async () => (await import('../translations/da.json')).default
|
|
}
|
|
]
|
|
};
|
|
|
|
export const { t, loading, locales, locale, initialized, translations, loadTranslations } = new i18n(config);
|
|
|
|
export const selectedLocale = writable<string>('en');
|
|
|
|
// Translations logs
|
|
loading.subscribe(async ($loading) => {
|
|
if ($loading) {
|
|
console.log('Loading translations...');
|
|
|
|
await loading.toPromise();
|
|
}
|
|
});
|
|
|
|
export function handleLocaleChange(newLocale: TLocale) {
|
|
if (!newLocale) {
|
|
return;
|
|
}
|
|
|
|
locale.set(newLocale);
|
|
|
|
selectedLocale.set(newLocale);
|
|
}
|
|
|
|
export function lessonFallbackNote(note: string, translation: Record<TLocale, string>, locale: TLocale) {
|
|
if (!translation) {
|
|
return note;
|
|
}
|
|
|
|
const content = translation[locale];
|
|
|
|
// if locale is english and no translated content for english but note exists
|
|
if (locale === 'en' && !content && note?.length) {
|
|
return note;
|
|
}
|
|
|
|
return content;
|
|
}
|