Skip to content

Commit

Permalink
feat: add IS_I18N_DEBUG_ENABLED global var
Browse files Browse the repository at this point in the history
  • Loading branch information
pahaz committed Jun 12, 2024
1 parent 2e72268 commit 90349c5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
9 changes: 4 additions & 5 deletions apps/web/components/Layout/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use client'

import {
useIsAuthenticated,
useLink,
} from '@repo/ui/refine/core'
import { useIsAuthenticated, useLink, useTranslate } from '@repo/ui/refine/core'
import React from 'react'

import { Layout, Space, theme } from '@repo/ui/general'
Expand All @@ -17,6 +14,8 @@ export const Header: React.FC = () => {
const Link = useLink()
const { data: auth } = useIsAuthenticated()
const isAuthenticated = auth?.authenticated
const translate = useTranslate()
const loginMessage = translate('buttons.login', 'Login')

const headerStyles: React.CSSProperties = {
backgroundColor: token.colorBgElevated,
Expand All @@ -36,7 +35,7 @@ export const Header: React.FC = () => {
<Space>
{/*<Notifications/>*/}
{isAuthenticated ? <CurrentUser /> : null}
{!isAuthenticated ? <Link to={'login'}>Login</Link> : null}
{!isAuthenticated ? <Link to={'login'}>{loginMessage}</Link> : null}
</Space>
</BaseHeader>
)
Expand Down
2 changes: 0 additions & 2 deletions apps/web/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { BrandTitle } from '../BrandTitle'
import { Header } from './header'

export const Layout: React.FC<React.PropsWithChildren> = ({ children }) => {
console.log('Layout')

return (
// ThemedLayoutV2: https://refine.dev/docs/ui-integrations/ant-design/components/themed-layout/
// Header: https://refine.dev/docs/ui-integrations/ant-design/components/themed-layout/#header
Expand Down
3 changes: 2 additions & 1 deletion apps/web/providers/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
DEFAULT_LOCALE,
DEFAULT_NAMESPACE,
LOCALES,
IS_I18N_DEBUG_ENABLED,
} from '@repo/i18n'

import { IMPORTER } from './importer'
Expand All @@ -20,7 +21,7 @@ i18next
.use(LanguageDetector)
.use(resourcesToBackend(IMPORTER))
.init({
// debug: true,
debug: IS_I18N_DEBUG_ENABLED,
lng: undefined, // let detect the language on client side
fallbackLng: DEFAULT_LOCALE,
fallbackNS: DEFAULT_NAMESPACE,
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export const LOCALE_COOKIE_NAME = 'NEXT_LOCALE'
export const LOCALES = ['en', 'ru']
export const DEFAULT_LOCALE = 'en'
export const DEFAULT_NAMESPACE = 'common'
export const IS_I18N_DEBUG_ENABLED = false
3 changes: 2 additions & 1 deletion packages/i18n/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import acceptLanguage from 'accept-language'
import {
DEFAULT_LOCALE,
DEFAULT_NAMESPACE,
IS_I18N_DEBUG_ENABLED,
LOCALE_COOKIE_NAME,
LOCALES,
} from './config'
Expand All @@ -32,7 +33,7 @@ const initI18next = async (
.use(initReactI18next)
.use(resourcesToBackend(importer))
.init({
debug: true,
debug: IS_I18N_DEBUG_ENABLED,
fallbackLng: DEFAULT_LOCALE,
fallbackNS: DEFAULT_NAMESPACE,
defaultNS: DEFAULT_NAMESPACE,
Expand Down

0 comments on commit 90349c5

Please sign in to comment.