1
1
mirror of https://github.com/theoludwig/theoludwig.git synced 2025-05-29 22:37:44 +02:00

chore: better Prettier config for easier reviews

This commit is contained in:
2023-10-23 23:11:59 +02:00
parent c7ad15a465
commit e566ef6c38
105 changed files with 2138 additions and 2080 deletions

View File

@ -1,12 +1,12 @@
import UniversalCookie from 'universal-cookie'
import type { I18n } from 'i18n-js'
import UniversalCookie from "universal-cookie"
import type { I18n } from "i18n-js"
import type { CookiesStore } from '@/utils/constants'
import type { CookiesStore } from "@/utils/constants"
import { i18n } from './i18n'
import { i18n } from "./i18n"
export const useI18n = (cookiesStore: CookiesStore): I18n => {
const universalCookie = new UniversalCookie(cookiesStore)
i18n.locale = universalCookie.get('locale') ?? i18n.defaultLocale
i18n.locale = universalCookie.get("locale") ?? i18n.defaultLocale
return i18n
}

View File

@ -1,21 +1,21 @@
'use server'
"use server"
import { cookies } from 'next/headers'
import type { I18n } from 'i18n-js'
import { cookies } from "next/headers"
import type { I18n } from "i18n-js"
import type { Locale } from '@/utils/constants'
import { COOKIE_MAX_AGE } from '@/utils/constants'
import type { Locale } from "@/utils/constants"
import { COOKIE_MAX_AGE } from "@/utils/constants"
import { i18n } from './i18n'
import { i18n } from "./i18n"
export const setLocale = (locale: Locale): void => {
cookies().set('locale', locale, {
path: '/',
maxAge: COOKIE_MAX_AGE
cookies().set("locale", locale, {
path: "/",
maxAge: COOKIE_MAX_AGE,
})
}
export const getI18n = (): I18n => {
i18n.locale = cookies().get('locale')?.value ?? i18n.defaultLocale
i18n.locale = cookies().get("locale")?.value ?? i18n.defaultLocale
return i18n
}

View File

@ -1,30 +1,30 @@
import { I18n } from 'i18n-js'
import { I18n } from "i18n-js"
import type { Locale } from '@/utils/constants'
import { DEFAULT_LOCALE, LOCALES } from '@/utils/constants'
import type { Locale } from "@/utils/constants"
import { DEFAULT_LOCALE, LOCALES } from "@/utils/constants"
import commonEnglish from './translations/en-US/common.json'
import errorsEnglish from './translations/en-US/errors.json'
import homeEnglish from './translations/en-US/home.json'
import commonFrench from './translations/fr-FR/common.json'
import errorsFrench from './translations/fr-FR/errors.json'
import homeFrench from './translations/fr-FR/home.json'
import commonEnglish from "./translations/en-US/common.json"
import errorsEnglish from "./translations/en-US/errors.json"
import homeEnglish from "./translations/en-US/home.json"
import commonFrench from "./translations/fr-FR/common.json"
import errorsFrench from "./translations/fr-FR/errors.json"
import homeFrench from "./translations/fr-FR/home.json"
const translations = {
'en-US': {
"en-US": {
common: commonEnglish,
errors: errorsEnglish,
home: homeEnglish
home: homeEnglish,
},
'fr-FR': {
"fr-FR": {
common: commonFrench,
errors: errorsFrench,
home: homeFrench
}
home: homeFrench,
},
} satisfies Record<Locale, Record<string, unknown>>
export const i18n = new I18n(translations, {
defaultLocale: DEFAULT_LOCALE,
availableLocales: LOCALES.slice(),
enableFallback: true
enableFallback: true,
})