feat: automatically detect language on server and translate UI (#530)
* feat: detect language on the server and translate page * translate auth pages * PR reviews
This commit is contained in:
@@ -76,7 +76,10 @@ export async function getProfile({
|
||||
}
|
||||
|
||||
// Skip refetching profile, if already in store
|
||||
if (profileStore.id) return;
|
||||
if (profileStore.id) {
|
||||
handleLocaleChange(profileStore.locale);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if user has profile
|
||||
let {
|
||||
@@ -124,7 +127,7 @@ export async function getProfile({
|
||||
setAnalyticsUser();
|
||||
|
||||
// Fetch language
|
||||
handleLocaleChange(profileStore.locale);
|
||||
handleLocaleChange(newProfileData[0].locale);
|
||||
|
||||
if (isOrgSite) {
|
||||
const { data, error } = await supabase
|
||||
@@ -179,8 +182,7 @@ export async function getProfile({
|
||||
// Set user in sentry
|
||||
setAnalyticsUser();
|
||||
|
||||
// Fetch language
|
||||
handleLocaleChange(profileStore.locale);
|
||||
handleLocaleChange(profileData.locale);
|
||||
|
||||
const orgRes = await getOrganizations(profileData.id, isOrgSite, orgSiteName);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LOCALE } from '$lib/utils/types';
|
||||
import { writable } from 'svelte/store';
|
||||
import i18n, { type Config } from 'sveltekit-i18n';
|
||||
import { LOCALE } from '$lib/utils/types';
|
||||
|
||||
interface Params {
|
||||
dateValue: number;
|
||||
@@ -10,8 +10,7 @@ interface Params {
|
||||
val: Date;
|
||||
}
|
||||
|
||||
const config: Config<Partial<Params>> = {
|
||||
initLocale: 'en',
|
||||
export const config: Config<Partial<Params>> = {
|
||||
// parser: parser(),
|
||||
loaders: [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { t } from '$lib/utils/functions/translations';
|
||||
import isNumber from 'lodash/isNumber';
|
||||
import z from 'zod';
|
||||
import { validateEmail } from './validateEmail';
|
||||
import { t } from '$lib/utils/functions/translations';
|
||||
|
||||
const getOrgNameValidation = () =>
|
||||
z
|
||||
@@ -85,12 +85,12 @@ const forgotValidationSchema = z.object({
|
||||
|
||||
const authValidationSchema = z.object({
|
||||
email: z.string().email({
|
||||
message: `${t.get('validations.auth.email.invalid_email')}`,
|
||||
invalid_type_error: `${t.get('validations.invalid_type_error')}`
|
||||
message: 'validations.auth.email.invalid_email',
|
||||
invalid_type_error: 'validations.invalid_type_error'
|
||||
}),
|
||||
password: z.string().min(6, {
|
||||
message: `${t.get('validations.auth.password.min_char')}`,
|
||||
invalid_type_error: `${t.get('validations.invalid_type_error')}`
|
||||
message: 'validations.auth.password.min_char',
|
||||
invalid_type_error: 'validations.invalid_type_error'
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user