Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

set up i18next, covered main page / header / footer with it, added some basic translations and other minor improvements

Blue Mouse942691cb9477
diff --git a/package.json b/package.json
index 6d2c7478b..e5d8392aa 100644
--- a/package.json
+++ b/package.json
@@ -21,6 +21,8 @@
"dom-to-image": "^2.6.0",
"file-saver": "^2.0.5",
"i18n-iso-countries": "^6.8.0",
+ "i18next": "^21.1.1",
+ "i18next-browser-languagedetector": "^6.1.2",
"lodash": "^4.17.21",
"nanoid": "^3.1.23",
"node-sass": "^5.0.0",
@@ -30,6 +32,7 @@
"react-dom": "^17.0.2",
"react-flagkit": "^2.0.4",
"react-helmet": "^6.1.0",
+ "react-i18next": "^11.12.0",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
"react-router-hash-link": "^2.4.3",
diff --git a/src/components/Footer/index.jsx b/src/components/Footer/index.jsx
index 718da1a39..f64a4ddd8 100644
--- a/src/components/Footer/index.jsx
+++ b/src/components/Footer/index.jsx
@@ -1,6 +1,7 @@
import React, { memo } from 'react'
import { Link } from 'react-router-dom'
import { HashLink } from 'react-router-hash-link'
+import { useTranslation } from 'react-i18next'
import _map from 'lodash/map'
import Flag from 'react-flagkit'
import PropTypes from 'prop-types'
@@ -9,17 +10,17 @@ import routes from 'routes'
const navigation = {
support: [
- (authenticated) => (authenticated ? { name: 'Billing', href: routes.billing } : { name: 'Pricing', href: `${routes.main}#pricing` }),
- () => ({ name: 'Documentation', href: routes.docs }),
- () => ({ name: 'Guides', href: `${routes.docs}#docs-ht` }),
+ (authenticated) => (authenticated ? { key: 'billing', href: routes.billing } : { key: 'pricing', href: `${routes.main}#pricing` }),
+ () => ({ key: 'docs', href: routes.docs }),
+ () => ({ key: 'guides', href: `${routes.docs}#docs-ht` }),
],
company: [
- { name: 'About', href: '#' },
- { name: 'Blog', href: '#' },
+ { key: 'about', href: '#' },
+ { key: 'blog', href: '#' },
],
legal: [
- { name: 'Privacy', href: routes.privacy },
- { name: 'Terms', href: routes.terms },
+ { key: 'privacy', href: routes.privacy },
+ { key: 'terms', href: routes.terms },
],
social: [
{
@@ -39,6 +40,9 @@ const navigation = {
}
const Footer = ({ minimal, authenticated }) => {
+ const { t, i18n: { language } } = useTranslation('common')
+ const year = new Date().getFullYear()
+
if (minimal) {
return (
<footer className='bg-gray-800'>
@@ -46,27 +50,27 @@ const Footer = ({ minimal, authenticated }) => {
<nav className='-mx-5 -my-2 flex flex-wrap justify-center' aria-label='Footer'>
<div className='px-5 py-2'>
<a href='#/' className='text-base text-gray-300 hover:text-white'>
- About
+ {t('footer.about')}
</a>
</div>
<div className='px-5 py-2'>
<Link to={routes.privacy} className='text-base text-gray-300 hover:text-white'>
- Privacy Policy
+ {t('footer.pp')}
</Link>
</div>
<div className='px-5 py-2'>
<Link to={routes.terms} className='text-base text-gray-300 hover:text-white'>
- Terms of Service
+ {t('footer.tos')}
</Link>
</div>
<div className='px-5 py-2'>
<Link to={routes.docs} className='text-base text-gray-300 hover:text-white'>
- Docs
+ {t('common.docs')}
</Link>
</div>
<div className='px-5 py-2'>
<a href='#/' className='text-base text-gray-300 hover:text-white'>
- Blog
+ {t('footer.blog')}
</a>
</div>
</nav>
@@ -90,22 +94,25 @@ const Footer = ({ minimal, authenticated }) => {
<img className='h-10 w-28' src='/assets/visa.png' height='40' width='112' loading='lazy' alt='' />
</div>
<p className='text-gray-300 text-base'>
- The best apps need the best services.<br />
- Swetrix is a powerful analytics platform that respects user privacy.
+ {t('footer.slogan')}
+ <br />
+ {t('footer.description')}
</p>
<div>
<p className='flex text-gray-300 text-base'>
- Made in
- <a className='flex hover:underline hover:opacity-80 text-blue-400 ml-1' href='https://en.wikipedia.org/wiki/Ukraine' target='_blank' rel='noopener noreferrer'>
+ {t('footer.madeIn')}
+ <a className='flex hover:underline hover:opacity-80 text-blue-400 ml-1' href={`https://${language}.wikipedia.org/wiki/Ukraine`} target='_blank' rel='noopener noreferrer'>
<Flag country='UA' size={18} alt='' />
- &nbsp;Ukraine
+ &nbsp;
+ {t('footer.ukraine')}
</a>
</p>
<p className='flex text-gray-300 text-base'>
- Hosted in the
- <a className='flex hover:underline hover:opacity-80 text-blue-400 ml-1' href='https://en.wikipedia.org/wiki/European_Union' target='_blank' rel='noopener noreferrer'>
+ {t('footer.hostedIn')}
+ <a className='flex hover:underline hover:opacity-80 text-blue-400 ml-1' href={`https://${language}.wikipedia.org/wiki/European_Union`} target='_blank' rel='noopener noreferrer'>
<Flag country='EU' size={18} alt='' />
- &nbsp;European Union
+ &nbsp;
+ {t('footer.eu')}
</a>
</p>
</div>
@@ -122,15 +129,17 @@ const Footer = ({ minimal, authenticated }) => {
<div className='md:grid md:grid-cols-2 md:gap-8'>
<div />
<div className='mt-12 md:mt-0'>
- <h3 className='text-sm font-semibold text-gray-400 tracking-wider uppercase'>Support</h3>
+ <h3 className='text-sm font-semibold text-gray-400 tracking-wider uppercase'>
+ {t('footer.support')}
+ </h3>
<ul className='mt-4 space-y-4'>
{_map(navigation.support, (func) => {
- const item = func(authenticated)
+ const { key, href } = func(authenticated)
return (
- <li key={item.name}>
- <HashLink to={item.href} className='text-base text-gray-300 hover:text-white'>
- {item.name}
+ <li key={key}>
+ <HashLink to={href} className='text-base text-gray-300 hover:text-white'>
+ {t(`footer.${key}`)}
</HashLink>
</li>
)
@@ -140,24 +149,28 @@ const Footer = ({ minimal, authenticated }) => {
</div>
<div className='md:grid md:grid-cols-2 md:gap-8'>
<div>
- <h3 className='text-sm font-semibold text-gray-400 tracking-wider uppercase'>Company</h3>
+ <h3 className='text-sm font-semibold text-gray-400 tracking-wider uppercase'>
+ {t('footer.company')}
+ </h3>
<ul className='mt-4 space-y-4'>
- {_map(navigation.company, (item) => (
- <li key={item.name}>
- <Link to={item.href} className='text-base text-gray-300 hover:text-white'>
- {item.name}
+ {_map(navigation.company, ({ key, href }) => (
+ <li key={key}>
+ <Link to={href} className='text-base text-gray-300 hover:text-white'>
+ {t(`footer.${key}`)}
</Link>
</li>
))}
</ul>
</div>
<div className='mt-12 md:mt-0'>
- <h3 className='text-sm font-semibold text-gray-400 tracking-wider uppercase'>Legal</h3>
+ <h3 className='text-sm font-semibold text-gray-400 tracking-wider uppercase'>
+ {t('footer.legal')}
+ </h3>
<ul className='mt-4 space-y-4'>
- {_map(navigation.legal, (item) => (
- <li key={item.name}>
- <Link to={item.href} className='text-base text-gray-300 hover:text-white'>
- {item.name}
+ {_map(navigation.legal, ({ key, href }) => (
+ <li key={key}>
+ <Link to={href} className='text-base text-gray-300 hover:text-white'>
+ {t(`footer.${key}`)}
</Link>
</li>
))}
@@ -167,7 +180,13 @@ const Footer = ({ minimal, authenticated }) => {
</div>
</div>
<div className='mt-8 border-t border-gray-200 pt-8'>
- <p className='text-base text-gray-400 xl:text-center'>&copy; 2021 Swetrix Analytics. All rights reserved.</p>
+ <p className='text-base text-gray-400 xl:text-center'>
+ &copy;
+ {' '}
+ {year}
+ {' '}
+ {t('footer.copy')}
+ </p>
</div>
</div>
</footer>
diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx
index 8b4054aa4..aa7d4996e 100644
--- a/src/components/Header/index.jsx
+++ b/src/components/Header/index.jsx
@@ -2,17 +2,29 @@ import React, { memo } from 'react'
import { Link, NavLink } from 'react-router-dom'
import { HashLink } from 'react-router-hash-link'
import { useDispatch } from 'react-redux'
+import { useTranslation } from 'react-i18next'
+import Flag from 'react-flagkit'
+import i18next from 'i18next'
import routes from 'routes'
import { authActions } from 'redux/actions/auth'
+import {
+ whitelist, languages, languageFlag,
+} from 'redux/constants'
+import Dropdown from 'ui/Dropdown'
const Header = ({ authenticated }) => {
+ const { t, i18n: { language } } = useTranslation('common')
const dispatch = useDispatch()
-
+
const logoutHandler = () => {
dispatch(authActions.logout())
}
+ const onLanguageChange = (id) => {
+ i18next.changeLanguage(id)
+ }
+
return (
<header className='bg-indigo-600'>
<nav className='mx-auto px-4 sm:px-6 lg:px-8' aria-label='Top'>
@@ -23,44 +35,92 @@ const Header = ({ authenticated }) => {
<img className='h-10 w-28' src='/assets/logo_white.png' height='40' width='112' alt='' />
</Link>
<div className='hidden ml-10 space-x-1 lg:block'>
- <NavLink to={routes.features} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Features'>Features</NavLink>
+ <NavLink to={routes.features} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Features'>
+ {t('common.features')}
+ </NavLink>
{authenticated ? (
- <NavLink to={routes.billing} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Billing'>Billing</NavLink>
+ <NavLink to={routes.billing} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Billing'>
+ {t('common.billing')}
+ </NavLink>
) : (
<>
- <HashLink to={`${routes.main}#pricing`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>Pricing</HashLink>
- <HashLink to={`${routes.main}#faqs`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='FAQs'>FAQs</HashLink>
+ <HashLink to={`${routes.main}#pricing`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>
+ {t('common.pricing')}
+ </HashLink>
+ <HashLink to={`${routes.main}#faqs`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='FAQs'>
+ {t('common.faqs')}
+ </HashLink>
</>
)}
- <NavLink to={routes.docs} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Docs'>Docs</NavLink>
+ <NavLink to={routes.docs} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Docs'>
+ {t('common.docs')}
+ </NavLink>
</div>
</div>
<div className='flex justify-center flex-wrap ml-1 md:ml-10 space-y-1 sm:space-y-0 space-x-2 md:space-x-4'>
+ <Dropdown
+ items={whitelist}
+ buttonClassName='flex items-center w-full rounded-md border border-gray-300 shadow-sm px-3 md:px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-indigo-500'
+ selectItemClassName='text-gray-700 block px-4 py-2 text-base cursor-pointer hover:bg-gray-200'
+ title={(
+ <>
+ <Flag className='rounded-sm mr-1.5' country={languageFlag[language]} size={21} alt='' />
+ {languages[language]}
+ </>
+ )}
+ labelExtractor={(lng) => (
+ <div className='flex'>
+ <Flag className='rounded-sm mr-1.5' country={languageFlag[lng]} size={21} alt='' />
+ {languages[lng]}
+ </div>
+ )}
+ onSelect={onLanguageChange}
+ />
{authenticated ? (
<>
- <NavLink to={routes.user_settings} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700'>You</NavLink>
- <Link to={routes.dashboard} className='inline-block select-none bg-white py-2 px-4 border border-transparent rounded-md text-base font-medium text-indigo-600 hover:bg-indigo-50'>Dashboard</Link>
- <Link to='#' className='text-base font-medium select-none text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' onClick={logoutHandler}>Logout</Link>
+ <NavLink to={routes.user_settings} className='text-base select-none font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700'>
+ {t('common.you')}
+ </NavLink>
+ <Link to={routes.dashboard} className='inline-block select-none bg-white py-2 px-4 border border-transparent rounded-md text-base font-medium text-indigo-600 hover:bg-indigo-50'>
+ {t('common.dashboard')}
+ </Link>
+ <Link to='#' className='text-base font-medium select-none text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' onClick={logoutHandler}>
+ {t('common.logout')}
+ </Link>
</>
) : (
<>
- <Link to={routes.signin} className='inline-block select-none bg-indigo-500 mt-1 sm:mt-0 py-2 px-3 md:px-4 border border-transparent rounded-md text-base font-medium text-white hover:bg-opacity-75'>Sign in</Link>
- <Link to={routes.signup} className='inline-block select-none bg-white py-2 px-3 md:px-4 border border-transparent rounded-md text-base font-medium text-indigo-600 hover:bg-indigo-50'>Get started</Link>
+ <Link to={routes.signin} className='inline-block select-none bg-indigo-500 mt-1 sm:mt-0 py-2 px-3 md:px-4 border border-transparent rounded-md text-base font-medium text-white hover:bg-opacity-75'>
+ {t('common.signin')}
+ </Link>
+ <Link to={routes.signup} className='inline-block select-none bg-white py-2 px-3 md:px-4 border border-transparent rounded-md text-base font-medium text-indigo-600 hover:bg-indigo-50'>
+ {t('common.getStarted')}
+ </Link>
</>
)}
</div>
</div>
<div className='py-4 flex flex-wrap justify-center space-x-2 lg:hidden'>
- <NavLink to={routes.features} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Features'>Features</NavLink>
+ <NavLink to={routes.features} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Features'>
+ {t('common.features')}
+ </NavLink>
{authenticated ? (
- <NavLink to={routes.billing} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Billing'>Billing</NavLink>
+ <NavLink to={routes.billing} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Billing'>
+ {t('common.billing')}
+ </NavLink>
) : (
<>
- <HashLink to={`${routes.main}#pricing`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>Pricing</HashLink>
- <HashLink to={`${routes.main}#faqs`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='FAQs'>FAQs</HashLink>
+ <HashLink to={`${routes.main}#pricing`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>
+ {t('common.pricing')}
+ </HashLink>
+ <HashLink to={`${routes.main}#faqs`} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='FAQs'>
+ {t('common.faqs')}
+ </HashLink>
</>
)}
- <NavLink to={routes.docs} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Docs'>Docs</NavLink>
+ <NavLink to={routes.docs} className='text-base select-none font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' activeClassName='bg-indigo-700 hover:bg-indigo-700' key='Docs'>
+ {t('common.docs')}
+ </NavLink>
</div>
</nav>
</header>
diff --git a/src/i18n/en.json b/src/i18n/en.json
new file mode 100644
index 000000000..b60e965ad
--- /dev/null
+++ b/src/i18n/en.json
@@ -0,0 +1,96 @@
+{
+ "common": {
+ "features": "Features",
+ "docs": "Docs",
+ "getStarted": "Get started",
+ "billing": "Billing",
+ "pricing": "Pricing",
+ "faqs": "FAQs",
+ "you": "You",
+ "dashboard": "Dashboard",
+ "logout": "Logout",
+ "signin": "Sign in"
+ },
+ "main": {
+ "slogan": "A <span>powerful</span> analytics platform that respects <span>user privacy<span>",
+ "trackEveryMetric": "Track every metric you need without invading your users' privacy.",
+ "description": "Swetrix brings an advanced and customisable analytics service for your web applications.",
+ "signup": "Sign up, it's free!",
+ "signupTerms": "By signing up, you agree to our <tos>Terms and Conditions</tos> and <pp>Privacy Policy.</pp>",
+ "techDetails": "Want to know more technical details?",
+ "lookAtDocs": "Look at the documentation and features pages.",
+ "readyToStart": "Ready to get started?",
+ "exploreService": "Explore our service or create an account.",
+ "faq": {
+ "title": "Get some questions answered",
+ "list": [
+ {
+ "question": "Does Swetrix tracking require cookies?",
+ "answer": "No, it does not. Our analytics script is fully cookieless. You can use our service without the need to use a cookie notification on your website.\nWe are compliant with such regulations as GDPR, PECR, CCPA, ePrivacy and COPPA."
+ },
+ {
+ "question": "Do you use/share/sell the end users' data?",
+ "answer": "No, we do not. Also, all of the data we collect is anonymised. We do not store any data that would allow us to identify a specific user. We try to be as transparent and respectful of privacy as possible."
+ },
+ {
+ "question": "Do I have to pay for your service?",
+ "answer": "We provide free accounts as well as paid accounts. Most of the features of the paid account are included in the free account, as well as more events per month. You can upgrade or downgrade your account subscription at any time."
+ },
+ {
+ "question": "Is my data secure?",
+ "answer": "We adhere to all standards regarding the security of data storage and processing. All data is securely stored, cannot be accessed by third parties and all communication is always through encrypted channels (HTTPS)."
+ }
+ ]
+ },
+ "features": [
+ {
+ "name": "Simple yet powerful",
+ "description": "View all your analytics in a straightforward way. Say no more to confusing reports, metrics and notifications."
+ },
+ {
+ "name": "Open source",
+ "description": "Our tracking script is open sourced and available for everybody to explore. We only track data that we declare."
+ },
+ {
+ "name": "Full event tracking",
+ "description": "With us, you can not only track your traffic but also custom events such as button clicks or registrations."
+ },
+ {
+ "name": "No cookie banners needed",
+ "description": "We are not doing do targeted advertising or profiling and we do not rely on tracking cookies at all. Our business model is to sell software, not data."
+ },
+ {
+ "name": "We are fast",
+ "description": "We use the fastest and most advanced technology in our applications and our analytics script loads times faster than the competitors."
+ },
+ {
+ "name": "Compare, explore and enjoy the data",
+ "description": "You can view data by selected categories and also correlate statistics, such as separating unique users from regular page views."
+ }
+ ],
+ "custSupport": "Could not find the answer you’re looking for? Reach out to our <mail>customer support</mail> team.",
+ "whyUs": "Why us"
+ },
+ "footer": {
+ "slogan": "The best apps need the best services.",
+ "description": "Swetrix is a powerful analytics platform that respects user privacy.",
+ "madeIn": "Made in",
+ "hostedIn": "Hosted in the",
+ "ukraine": "Ukraine",
+ "eu": "the European Union",
+ "support": "Support",
+ "company": "Company",
+ "legal": "Legal",
+ "copy": "Swetrix Analytics. All rights reserved.",
+ "about": "About",
+ "pp": "Privacy Policy",
+ "tos": "Terms of Service",
+ "blog": "Blog",
+ "billing": "Billing",
+ "pricing": "Pricing",
+ "docs": "Documentation",
+ "guides": "Guides",
+ "privacy": "Privacy",
+ "terms": "Terms"
+ }
+}
diff --git a/src/i18n/ru.json b/src/i18n/ru.json
new file mode 100644
index 000000000..8b92c5a37
--- /dev/null
+++ b/src/i18n/ru.json
@@ -0,0 +1,27 @@
+{
+ "main": {
+ "slogan": "<span>Мощная</span> платформа веб-аналитики, которая ценит <span>приватность пользователей</span>"
+ },
+ "footer": {
+ "slogan": "Лучшие приложения нуждаются в лучших сервисах.",
+ "description": "Swetrix - мощная аналитическая платформа, уважающая конфиденциальность пользователей.",
+ "madeIn": "Сделано в",
+ "hostedIn": "Размещено в",
+ "ukraine": "Украине",
+ "eu": "Европейском Союзе",
+ "support": "Поддержка",
+ "company": "Компания",
+ "legal": "Правовая информация",
+ "copy": "Swetrix Analytics. Все права защищены.",
+ "about": "О нас",
+ "pp": "Политика конфиденциальности",
+ "tos": "Условия использования",
+ "blog": "Блог",
+ "billing": "Оплата",
+ "pricing": "Цены",
+ "docs": "Документация",
+ "guides": "Руководства",
+ "privacy": "Приватность",
+ "terms": "Условия"
+ }
+}
diff --git a/src/i18n/uk.json b/src/i18n/uk.json
new file mode 100644
index 000000000..26f967263
--- /dev/null
+++ b/src/i18n/uk.json
@@ -0,0 +1,27 @@
+{
+ "main": {
+ "slogan": "<span>Потужна</span> платформа веб-аналітики, яка цінує <span>приватність користувачів</span>"
+ },
+ "footer": {
+ "slogan": "Найкращі додатки потребують найкращих сервісів.",
+ "description": "Swetrix - потужна аналітична платформа, яка поважає конфіденційність користувачів.",
+ "madeIn": "Зроблено в",
+ "hostedIn": "Розміщено в",
+ "ukraine": "Україні",
+ "eu": "Європейському Союзі",
+ "support": "Підтримка",
+ "company": "Компанія",
+ "legal": "Правова інформація",
+ "copy": "Swetrix Analytics. Всі права захищені.",
+ "about": "Про нас",
+ "pp": "Політика конфіденційності",
+ "tos": "Умови використання",
+ "blog": "Блог",
+ "billing": "Оплата",
+ "pricing": "Ціни",
+ "docs": "Документація",
+ "guides": "Посібники",
+ "privacy": "Приватність",
+ "terms": "Умови"
+ }
+}
diff --git a/src/i18next.js b/src/i18next.js
new file mode 100644
index 000000000..edef4abf9
--- /dev/null
+++ b/src/i18next.js
@@ -0,0 +1,38 @@
+import i18next from 'i18next'
+import LanguageDetector from 'i18next-browser-languagedetector'
+import { whitelist, defaultLanguage } from 'redux/constants'
+import { setItem } from 'utils/localstorage'
+import en from './i18n/en.json'
+import ru from './i18n/ru.json'
+import uk from './i18n/uk.json'
+
+const lngDetector = new LanguageDetector()
+lngDetector.addDetector({
+ name: 'customDetector',
+ lookup() {
+ return defaultLanguage
+ },
+ cacheUserLanguage(lng) {
+ setItem('language', lng)
+ },
+})
+
+i18next
+ .use(lngDetector)
+ .init({
+ detection: {
+ order: ['localStorage', 'customDetector'],
+ lookupLocalStorage: 'language',
+ },
+ interpolation: {
+ escapeValue: false,
+ },
+ whitelist,
+ resources: {
+ en: { common: en },
+ ru: { common: ru },
+ uk: { common: uk },
+ },
+ })
+
+export default i18next
diff --git a/src/index.js b/src/index.js
index 5ac108787..9b01d17b5 100644
--- a/src/index.js
+++ b/src/index.js
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom'
import { BrowserRouter } from 'react-router-dom'
import { store } from 'redux/store'
import { Provider } from 'react-redux'
+import { I18nextProvider } from 'react-i18next'
import { transitions, positions, Provider as AlertProvider } from 'react-alert'
import * as Swetrix from 'swetrix'
import * as Sentry from '@sentry/react'
@@ -12,13 +13,12 @@ import 'prismjs/themes/prism-tomorrow.css'
import AlertTemplate from 'ui/Alert'
import App from './App'
+import i18next from './i18next'
import './index.css'
console.log('%cWelcome, hacker, glad you opened your console, you seem serious about your craft and will go a long way!\nP.S. All the bugs, feature requests can be sent to [email protected]', 'color: #818cf8;background: #1f2937;font-size: 20px;text-shadow: 2px 2px black')
-Swetrix.init('STEzHcB1rALV', {
- debug: true,
-})
+Swetrix.init('STEzHcB1rALV')
Swetrix.trackViews()
@@ -41,15 +41,17 @@ if (process.env.NODE_ENV !== 'production') {
ReactDOM.render(
<React.StrictMode>
- <AlertProvider template={AlertTemplate} {...options}>
- <Provider store={store}>
- <BrowserRouter>
- <Sentry.ErrorBoundary fallback={<p>The app crashed.. :(<br/>Please, tell us about it at [email protected]</p>}>
- <App />
- </Sentry.ErrorBoundary>
- </BrowserRouter>
- </Provider>
- </AlertProvider>
+ <Sentry.ErrorBoundary fallback={<p>The app crashed.. :(<br />Please, tell us about it at [email protected]</p>}>
+ <AlertProvider template={AlertTemplate} {...options}>
+ <Provider store={store}>
+ <BrowserRouter>
+ <I18nextProvider i18n={i18next}>
+ <App />
+ </I18nextProvider>
+ </BrowserRouter>
+ </Provider>
+ </AlertProvider>
+ </Sentry.ErrorBoundary>
</React.StrictMode>,
document.getElementById('root')
)
diff --git a/src/pages/MainPage/index.jsx b/src/pages/MainPage/index.jsx
index d71cfd6d2..7599fd370 100644
--- a/src/pages/MainPage/index.jsx
+++ b/src/pages/MainPage/index.jsx
@@ -1,5 +1,7 @@
import React from 'react'
import { Link } from 'react-router-dom'
+import { useTranslation, Trans } from 'react-i18next'
+import _map from 'lodash/map'
import routes from 'routes'
import { notAuthenticated } from '../../hoc/protected'
@@ -7,58 +9,6 @@ import Title from 'components/Title'
import SignUp from '../Auth/Signup/BasicSignup'
import Pricing from './Pricing'
-const features = [
- {
- id: 1,
- name: 'Simple yet powerful',
- description: 'View all your analytics in a straightforward way. Say no more to confusing reports, metrics and notifications.',
- },
- {
- id: 2,
- name: 'Open source',
- description: 'Our tracking script is open sourced and available for everybody to explore. We only track data that we declare.',
- },
- {
- id: 3,
- name: 'Full event tracking',
- description: 'With us, you can not only track your traffic but also custom events such as button clicks or registrations.',
- },
- {
- id: 4,
- name: 'No cookie banners needed',
- description: 'We are not doing do targeted advertising or profiling and we do not rely on tracking cookies at all. Our business model is to sell software, not data.',
- },
- {
- id: 5,
- name: 'We are fast',
- description: 'We use the fastest and most advanced technology in our applications and our analytics script loads times faster than the competitors.',
- },
- {
- id: 6,
- name: 'Compare, explore and enjoy the data',
- description: 'You can view data by selected categories and also correlate statistics, such as separating unique users from regular page views.',
- },
-]
-
-const faqs = [
- {
- question: 'Does Swetrix tracking require cookies?',
- answer: 'No, it does not. Our analytics script is fully cookieless. You can use our service without the need to use a cookie notification on your website.\nWe are compliant with such regulations as GDPR, PECR, CCPA, ePrivacy and COPPA.',
- },
- {
- question: 'Do you use/share/sell the end users\' data?',
- answer: 'No, we do not. Also, all of the data we collect is anonymised. We do not store any data that would allow us to identify a specific user. We try to be as transparent and respectful of privacy as possible.',
- },
- {
- question: 'Do I have to pay for your service?',
- answer: 'We provide free accounts as well as paid accounts. Most of the features of the paid account are included in the free account, as well as more events per month. You can upgrade or downgrade your account subscription at any time.',
- },
- {
- question: 'Is my data secure?',
- answer: 'We adhere to all standards regarding the security of data storage and processing. All data is securely stored, cannot be accessed by third parties and all communication is always through encrypted channels (HTTPS).',
- },
-]
-
const SquareDots = ({ className }) => (
<div className='hidden lg:block lg:absolute lg:inset-0 pointer-events-none' aria-hidden='true'>
<svg
@@ -85,28 +35,32 @@ const SquareDots = ({ className }) => (
</div>
)
-const FAQs = () => (
+const FAQs = ({ t }) => (
<div id='faqs' className='bg-gray-50'>
<div className='w-11/12 mx-auto py-16 px-4 sm:px-6 lg:py-20 lg:px-8'>
<div className='lg:grid lg:grid-cols-3 lg:gap-8'>
<div>
- <h2 className='text-3xl font-extrabold text-gray-900'>Get some questions answered</h2>
+ <h2 className='text-3xl font-extrabold text-gray-900'>
+ {t('main.faq.title')}
+ </h2>
<p className='mt-4 text-lg text-gray-500'>
- Could not find the answer you’re looking for? Reach out to our{' '}
- <a href='mailto:[email protected]' className='font-medium text-indigo-600 hover:text-indigo-500'>
- customer support
- </a>{' '}
- team.
+ <Trans
+ t={t}
+ i18nKey='main.custSupport'
+ components={{
+ mail: <a href='mailto:[email protected]' className='font-medium text-indigo-600 hover:text-indigo-500' />,
+ }}
+ />
</p>
</div>
<div className='mt-12 lg:mt-0 lg:col-span-2'>
<dl className='space-y-12'>
- {faqs.map((faq) => (
- <div key={faq.question}>
- <dt className='text-lg leading-6 font-medium text-gray-900'>{faq.question}</dt>
- <dd className='mt-2 text-base text-gray-500 whitespace-pre-line'>{faq.answer}</dd>
- </div>
- ))}
+ {_map(t('main.faq.list', { returnObjects: true }), (faq) => (
+ <div key={faq.question}>
+ <dt className='text-lg leading-6 font-medium text-gray-900'>{faq.question}</dt>
+ <dd className='mt-2 text-base text-gray-500 whitespace-pre-line'>{faq.answer}</dd>
+ </div>
+ ))}
</dl>
</div>
</div>
@@ -114,16 +68,18 @@ const FAQs = () => (
</div>
)
-const Features = () => (
+const Features = ({ t }) => (
<div className='bg-white'>
<div className='w-11/12 mx-auto py-16 px-4 sm:py-24 sm:px-6 lg:px-8'>
- <h2 className='text-3xl font-extrabold text-gray-900 text-center'>Why us</h2>
+ <h2 className='text-3xl font-extrabold text-gray-900 text-center'>
+ {t('main.whyUs')}
+ </h2>
<div className='mt-12'>
<dl className='space-y-10 md:space-y-0 md:grid md:grid-cols-2 md:grid-rows-2 md:gap-x-8 md:gap-y-12 lg:grid-cols-3'>
- {features.map((faq) => (
- <div key={faq.id}>
- <dt className='text-lg leading-6 font-semibold text-gray-900'>{faq.name}</dt>
- <dd className='mt-2 text-base text-gray-500'>{faq.description}</dd>
+ {_map(t('main.features', { returnObjects: true }), (feature) => (
+ <div key={feature.name}>
+ <dt className='text-lg leading-6 font-semibold text-gray-900'>{feature.name}</dt>
+ <dd className='mt-2 text-base text-gray-500'>{feature.description}</dd>
</div>
))}
</dl>
@@ -132,121 +88,134 @@ const Features = () => (
</div>
)
-const Main = () => (
- <Title title='Privacy Respecting Web Analytics Platform'>
- <div className='relative bg-gray-800'>
- <SquareDots className='absolute bottom-0 left-0 transform translate-x-0 mb-0 text-gray-700 lg:top-0 xl:transform-none lg:mt-72' />
- <SquareDots className='absolute bottom-0 right-0 transform translate-x-0 mb-48 text-gray-700 lg:top-0 lg:mb-0 xl:transform-none lg:mt-16' />
- <div className='relative pt-6 pb-16 sm:pb-24'>
- <main className='mt-16 sm:mt-24'>
- <div className='mx-auto w-11/12'>
- <div className='lg:grid lg:grid-cols-12 lg:gap-8'>
- <div className='px-4 sm:px-6 sm:text-center md:max-w-2xl md:mx-auto lg:col-span-6 lg:text-left lg:flex lg:items-center'>
- <div>
- <h1 className='mt-4 text-4xl tracking-tight font-extrabold text-white sm:mt-5 sm:leading-none lg:mt-6 lg:text-5xl xl:text-6xl'>
- A{' '}
- <span className='text-indigo-400'>powerful</span>{' '}
- <span>analytics platform that respects</span>{' '}
- <span className='text-indigo-400'>user privacy</span>
- </h1>
- <p className='mt-3 text-base text-gray-300 sm:mt-5 sm:text-xl lg:text-lg xl:text-xl'>
- Swetrix brings an advanced and customisable analytics service for your web applications.<br />
- Track every metric you need without invading your users' privacy.
- </p>
+const Main = () => {
+ const { t } = useTranslation('common')
+
+ return (
+ <Title title='Privacy Respecting Web Analytics Platform'>
+ <div className='relative bg-gray-800'>
+ <SquareDots className='absolute bottom-0 left-0 transform translate-x-0 mb-0 text-gray-700 lg:top-0 xl:transform-none lg:mt-72' />
+ <SquareDots className='absolute bottom-0 right-0 transform translate-x-0 mb-48 text-gray-700 lg:top-0 lg:mb-0 xl:transform-none lg:mt-16' />
+ <div className='relative pt-6 pb-16 sm:pb-24'>
+ <main className='mt-16 sm:mt-24'>
+ <div className='mx-auto w-11/12'>
+ <div className='lg:grid lg:grid-cols-12 lg:gap-8'>
+ <div className='px-4 sm:px-6 sm:text-center md:max-w-2xl md:mx-auto lg:col-span-6 lg:text-left lg:flex lg:items-center'>
+ <div>
+ <h1 className='mt-4 text-4xl tracking-tight font-extrabold text-white sm:mt-5 sm:leading-none lg:mt-6 lg:text-5xl xl:text-6xl'>
+ <Trans
+ t={t}
+ i18nKey='main.slogan'
+ components={{
+ span: <span className='text-indigo-400' />,
+ }}
+ />
+ </h1>
+ <p className='mt-3 text-base text-gray-300 sm:mt-5 sm:text-xl lg:text-lg xl:text-xl'>
+ {t('main.description')}
+ <br />
+ {t('main.trackEveryMetric')}
+ </p>
+ </div>
</div>
- </div>
- <div className='mt-16 sm:mt-24 lg:mt-0 lg:col-span-6'>
- <div className='bg-white sm:max-w-md sm:w-full sm:mx-auto sm:rounded-lg sm:overflow-hidden'>
- <div className='px-4 py-8 sm:px-10'>
- <p className='text-lg text-gray-900 text-center'>Sign up, it's free!</p>
- <div className='mt-6'>
- <SignUp />
+ <div className='mt-16 sm:mt-24 lg:mt-0 lg:col-span-6'>
+ <div className='bg-white sm:max-w-md sm:w-full sm:mx-auto sm:rounded-lg sm:overflow-hidden'>
+ <div className='px-4 py-8 sm:px-10'>
+ <p className='text-lg text-gray-900 text-center'>
+ {t('main.signup')}
+ </p>
+ <div className='mt-6'>
+ <SignUp />
+ </div>
+ </div>
+ <div className='px-4 py-6 bg-gray-50 border-t-2 border-gray-200 sm:px-10'>
+ <p className='text-xs leading-5 text-gray-500'>
+ <Trans
+ t={t}
+ i18nKey='main.signupTerms'
+ components={{
+ tos: <Link to={routes.terms} className='font-medium text-gray-900 hover:underline' />,
+ pp: <Link to={routes.privacy} className='font-medium text-gray-900 hover:underline' />,
+ }}
+ />
+ </p>
</div>
- </div>
- <div className='px-4 py-6 bg-gray-50 border-t-2 border-gray-200 sm:px-10'>
- <p className='text-xs leading-5 text-gray-500'>
- By signing up, you agree to our{' '}
- <Link to={routes.terms} className='font-medium text-gray-900 hover:underline'>
- Terms and Conditions
- </Link>
- {' '}and{' '}
- <Link to={routes.privacy} className='font-medium text-gray-900 hover:underline'>
- Privacy Policy
- </Link>
- .
- </p>
</div>
</div>
</div>
</div>
- </div>
- </main>
- </div>
-
- <div className='relative'>
- <div className='absolute inset-0 flex flex-col' aria-hidden='true'>
- <div className='flex-1' />
- <div className='flex-1 w-full bg-white' />
+ </main>
</div>
- <div className='w-11/12 mx-auto'>
- <img className='relative rounded-md md:rounded-lg shadow-lg' src='/assets/screenshot.png' alt='' />
+
+ <div className='relative'>
+ <div className='absolute inset-0 flex flex-col' aria-hidden='true'>
+ <div className='flex-1' />
+ <div className='flex-1 w-full bg-white' />
+ </div>
+ <div className='w-11/12 mx-auto'>
+ <img className='relative rounded-md md:rounded-lg shadow-lg' src='/assets/screenshot.png' alt='' />
+ </div>
</div>
- </div>
- <Features />
- <div className='bg-indigo-600'>
- <div className='w-11/12 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:px-8 lg:flex lg:items-center lg:justify-between'>
- <h2 className='text-3xl sm:text-4xl font-extrabold tracking-tight text-gray-900'>
- <span className='block text-white'>Want to know more technical details?</span>
- <span className='block text-gray-300'>
- Look at the documentation and features pages.
- </span>
- </h2>
- <div className='mt-6 space-y-4 sm:space-y-0 sm:flex sm:space-x-5'>
- <Link
- to={routes.features}
- className='flex items-center justify-center px-3 py-2 border border-transparent text-lg font-medium rounded-md shadow-sm text-indigo-800 bg-indigo-50 hover:bg-indigo-100'
- >
- Features
- </Link>
- <Link
- to={routes.docs}
- className='flex items-center justify-center px-3 py-2 border border-transparent text-lg font-medium rounded-md shadow-sm text-indigo-800 bg-indigo-50 hover:bg-indigo-100'
- >
- Docs
- </Link>
+ <Features t={t} />
+ <div className='bg-indigo-600'>
+ <div className='w-11/12 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:px-8 lg:flex lg:items-center lg:justify-between'>
+ <h2 className='text-3xl sm:text-4xl font-extrabold tracking-tight text-gray-900'>
+ <span className='block text-white'>
+ {t('main.description')}
+ </span>
+ <span className='block text-gray-300'>
+ {t('main.lookAtDocs')}
+ </span>
+ </h2>
+ <div className='mt-6 space-y-4 sm:space-y-0 sm:flex sm:space-x-5'>
+ <Link
+ to={routes.features}
+ className='flex items-center justify-center px-3 py-2 border border-transparent text-lg font-medium rounded-md shadow-sm text-indigo-800 bg-indigo-50 hover:bg-indigo-100'
+ >
+ {t('common.features')}
+ </Link>
+ <Link
+ to={routes.docs}
+ className='flex items-center justify-center px-3 py-2 border border-transparent text-lg font-medium rounded-md shadow-sm text-indigo-800 bg-indigo-50 hover:bg-indigo-100'
+ >
+ {t('common.docs')}
+ </Link>
+ </div>
</div>
</div>
- </div>
- <Pricing />
- <FAQs />
+ <Pricing />
+ <FAQs t={t} />
- <div className='bg-white'>
- <div className='w-11/12 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:w-11/12 lg:px-8 lg:flex lg:items-center lg:justify-between'>
- <h2 className='text-3xl sm:text-4xl font-extrabold tracking-tight text-gray-900'>
- <span className='block'>Ready to get started?</span>
- <span className='block bg-gradient-to-r from-purple-600 to-indigo-600 bg-clip-text text-transparent'>
- Explore our service or create an account.
- </span>
- </h2>
- <div className='mt-6 space-y-4 sm:space-y-0 sm:flex sm:space-x-5'>
- <Link
- to={routes.features}
- className='flex items-center justify-center bg-gradient-to-r from-purple-600 to-indigo-600 bg-origin-border px-4 py-3 border border-transparent text-base font-medium rounded-md shadow-sm text-white hover:from-purple-700 hover:to-indigo-700'
- >
- Features
- </Link>
- <Link
- to={routes.signup}
- className='flex items-center justify-center px-4 py-3 border border-transparent text-base font-medium rounded-md shadow-sm text-indigo-800 bg-indigo-50 hover:bg-indigo-100'
- >
- Get started
- </Link>
+ <div className='bg-white'>
+ <div className='w-11/12 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:w-11/12 lg:px-8 lg:flex lg:items-center lg:justify-between'>
+ <h2 className='text-3xl sm:text-4xl font-extrabold tracking-tight text-gray-900'>
+ <span className='block'>
+ {t('main.readyToStart')}
+ </span>
+ <span className='block bg-gradient-to-r from-purple-600 to-indigo-600 bg-clip-text text-transparent'>
+ {t('main.exploreService')}
+ </span>
+ </h2>
+ <div className='mt-6 space-y-4 sm:space-y-0 sm:flex sm:space-x-5'>
+ <Link
+ to={routes.features}
+ className='flex items-center justify-center bg-gradient-to-r from-purple-600 to-indigo-600 bg-origin-border px-4 py-3 border border-transparent text-base font-medium rounded-md shadow-sm text-white hover:from-purple-700 hover:to-indigo-700'
+ >
+ {t('common.features')}
+ </Link>
+ <Link
+ to={routes.signup}
+ className='flex items-center justify-center px-4 py-3 border border-transparent text-base font-medium rounded-md shadow-sm text-indigo-800 bg-indigo-50 hover:bg-indigo-100'
+ >
+ {t('common.getStarted')}
+ </Link>
+ </div>
</div>
</div>
</div>
- </div>
- </Title>
-)
+ </Title>
+ )
+}
export default notAuthenticated(Main)
diff --git a/src/redux/constants/index.js b/src/redux/constants/index.js
index 1f6cacc06..22a9260c2 100644
--- a/src/redux/constants/index.js
+++ b/src/redux/constants/index.js
@@ -51,3 +51,17 @@ export const getProjectCacheKey = (period, timeBucket) => `${period}${timeBucket
// Cookies
export const GDPR_REQUEST = 'gdpr_request'
export const CONFIRMATION_TIMEOUT = 'confirmation_timeout'
+
+// List of languages with translations available
+export const whitelist = ['en', 'ru', 'uk']
+export const defaultLanguage = 'en'
+export const languages = {
+ en: 'English',
+ ru: 'Русский',
+ uk: 'Українська',
+}
+export const languageFlag = {
+ en: 'GB',
+ uk: 'UA',
+ ru: 'RU',
+}
diff --git a/src/ui/Dropdown.jsx b/src/ui/Dropdown.jsx
index 36bcd123f..5e51bcc10 100644
--- a/src/ui/Dropdown.jsx
+++ b/src/ui/Dropdown.jsx
@@ -7,7 +7,7 @@ import _isEmpty from 'lodash/isEmpty'
import PropTypes from 'prop-types'
const Dropdown = ({
- title, desc, className, items, labelExtractor, keyExtractor, onSelect, aside,
+ title, desc, className, items, labelExtractor, keyExtractor, onSelect, aside, buttonClassName, selectItemClassName,
}) => (
<Menu as='div' className={cx('relative inline-block text-left', className)}>
{({ open }) => (
@@ -16,7 +16,7 @@ const Dropdown = ({
<p className='mb-2 text-sm text-gray-900'>{desc}</p>
)}
<div>
- <Menu.Button className={cx('inline-flex w-full rounded-md border border-gray-300 shadow-sm px-3 md:px-4 py-2 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-indigo-500', {
+ <Menu.Button className={cx(buttonClassName ? buttonClassName : 'inline-flex w-full rounded-md border border-gray-300 shadow-sm px-3 md:px-4 py-2 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-indigo-500', {
'justify-between': aside,
'justify-center': !aside,
})}>
@@ -40,7 +40,7 @@ const Dropdown = ({
{_map(items, item => (
<Menu.Item key={keyExtractor ? keyExtractor(item) : item}>
<span
- className='text-gray-700 block px-4 py-2 text-sm cursor-pointer hover:bg-gray-200'
+ className={selectItemClassName ? selectItemClassName : 'text-gray-700 block px-4 py-2 text-sm cursor-pointer hover:bg-gray-200'}
role='menuitem'
tabIndex='-1'
id='menu-item-0'
@@ -65,6 +65,8 @@ Dropdown.propTypes = {
PropTypes.string, PropTypes.object,
])),
className: PropTypes.string,
+ buttonClassName: PropTypes.string,
+ selectItemClassName: PropTypes.string,
labelExtractor: PropTypes.func,
keyExtractor: PropTypes.func,
aside: PropTypes.bool,
@@ -73,6 +75,8 @@ Dropdown.propTypes = {
Dropdown.defaultProps = {
className: '',
+ buttonClassName: '',
+ selectItemClassName: '',
labelExtractor: null,
keyExtractor: null,
aside: false,