mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 07:13:37 +01:00
use useLocale
This commit is contained in:
parent
0c13f8d358
commit
703a1e13db
@ -1,19 +1,17 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FormattedMessage, useIntl } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import Link from 'components/common/Link';
|
import Link from 'components/common/Link';
|
||||||
import styles from './Footer.module.css';
|
import styles from './Footer.module.css';
|
||||||
import useVersion from 'hooks/useVersion';
|
import useVersion from 'hooks/useVersion';
|
||||||
|
import useLocale from 'hooks/useLocale';
|
||||||
|
|
||||||
export default function Footer() {
|
export default function Footer() {
|
||||||
const { current } = useVersion();
|
const { current } = useVersion();
|
||||||
const intl = useIntl();
|
const [locale] = useLocale();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<footer
|
<footer className="container" dir={locale === 'ar-SA' ? 'rtl' : 'ltr'}>
|
||||||
className="container"
|
|
||||||
dir={intl.formatMessage({ id: 'metrics.dir', defaultMessage: 'ltr' })}
|
|
||||||
>
|
|
||||||
<div className={classNames(styles.footer, 'row')}>
|
<div className={classNames(styles.footer, 'row')}>
|
||||||
<div className="col-12 col-md-4" />
|
<div className="col-12 col-md-4" />
|
||||||
<div className="col-12 col-md-4">
|
<div className="col-12 col-md-4">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { FormattedMessage, useIntl } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import Link from 'components/common/Link';
|
import Link from 'components/common/Link';
|
||||||
@ -10,21 +10,19 @@ import UpdateNotice from 'components/common/UpdateNotice';
|
|||||||
import UserButton from 'components/settings/UserButton';
|
import UserButton from 'components/settings/UserButton';
|
||||||
import Logo from 'assets/logo.svg';
|
import Logo from 'assets/logo.svg';
|
||||||
import styles from './Header.module.css';
|
import styles from './Header.module.css';
|
||||||
|
import useLocale from 'hooks/useLocale';
|
||||||
|
|
||||||
export default function Header() {
|
export default function Header() {
|
||||||
const user = useSelector(state => state.user);
|
const user = useSelector(state => state.user);
|
||||||
const [active, setActive] = useState(false);
|
const [active, setActive] = useState(false);
|
||||||
const intl = useIntl();
|
const [locale] = useLocale();
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
setActive(state => !state);
|
setActive(state => !state);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav className="container" dir={locale === 'ar-SA' ? 'rtl' : 'ltr'}>
|
||||||
className="container"
|
|
||||||
dir={intl.formatMessage({ id: 'metrics.dir', defaultMessage: 'ltr' })}
|
|
||||||
>
|
|
||||||
{user?.is_admin && <UpdateNotice />}
|
{user?.is_admin && <UpdateNotice />}
|
||||||
<div className={classNames(styles.header, 'row align-items-center')}>
|
<div className={classNames(styles.header, 'row align-items-center')}>
|
||||||
<div className={styles.nav}>
|
<div className={styles.nav}>
|
||||||
|
@ -2,22 +2,19 @@ import React from 'react';
|
|||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import Header from 'components/layout/Header';
|
import Header from 'components/layout/Header';
|
||||||
import Footer from 'components/layout/Footer';
|
import Footer from 'components/layout/Footer';
|
||||||
import { useIntl } from 'react-intl';
|
import useLocale from 'hooks/useLocale';
|
||||||
|
|
||||||
export default function Layout({ title, children, header = true, footer = true }) {
|
export default function Layout({ title, children, header = true, footer = true }) {
|
||||||
const intl = useIntl();
|
const [locale] = useLocale();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head dir={intl.formatMessage({ id: 'metrics.dir', defaultMessage: 'ltr' })}>
|
<Head>
|
||||||
<title>umami{title && ` - ${title}`}</title>
|
<title>umami{title && ` - ${title}`}</title>
|
||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
{header && <Header />}
|
{header && <Header />}
|
||||||
<main
|
<main className="container" dir={locale === 'ar-SA' ? 'rtl' : 'ltr'}>
|
||||||
className="container"
|
|
||||||
dir={intl.formatMessage({ id: 'metrics.dir', defaultMessage: 'ltr' })}
|
|
||||||
>
|
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
{footer && <Footer />}
|
{footer && <Footer />}
|
||||||
|
@ -96,6 +96,5 @@
|
|||||||
"metrics.referrers": "التحويلات",
|
"metrics.referrers": "التحويلات",
|
||||||
"metrics.unique-visitors": "زائرون فريدون",
|
"metrics.unique-visitors": "زائرون فريدون",
|
||||||
"metrics.views": "مشاهدات",
|
"metrics.views": "مشاهدات",
|
||||||
"metrics.visitors": "زوار",
|
"metrics.visitors": "زوار"
|
||||||
"metrics.dir": "rtl"
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user