📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Integrated translations into Docs page
Blue Mouse928fc25b1fe9
diff --git a/src/i18n/en.json b/src/i18n/en.jsonindex 1c8cd828d..f2024ddc1 100644--- a/src/i18n/en.json+++ b/src/i18n/en.json@@ -173,6 +173,39 @@"inc": "Increased by","dec": "Descreased by"},+ "docs": {+ "titles": {+ "start": "Getting Started",+ "umd": "UMD Build",+ "npm": "NPM Package",+ "how": "How to..",+ "pv": "Track pageviews",+ "ce": "Track custom events",+ "api": "API"+ },+ "install": "You can also install the tracking script with NPM or Yarn",+ "import": "Next you should import module into your project's root, for example",+ "track": "After you can track anything you want.\nRead the detailed documentation on tracking params below.",+ "pv": "Swetrix.js tracking script provides a way to collect a page view event once the page has loaded.\nThis can be accomplished via calling the <link>trackViews()</link> function:",+ "ce": "In addition to tracking pageviews we provide an ability to track custom events.\nFor example, if you want to track an event like 'Sign up' or 'Newsletter subscription', this feature would be very useful.\nUnder the screen, the principle of this function is similar to trackViews.",+ "init": "This fuction is used to initialise the analytics.\nBasically you're letting the script know which project do you want to use it with, as well as specifying your custom parameters if needed.",+ "tr": "With this function you are able to track any custom events you want.\nYou should never send any identifiable data (like User ID, email, session cookie, etc.) as an event name.\nThe total number of track calls and their conversion rate will be saved.",+ "tv": {+ "call": "Calling trackViews will result in sending the data about the user to our servers.\nSuch data will include the next params if available:\n",+ "gather": "On the server side we also gather users IP Address and User Agent.\nThis data is used to detect whether the page view is unique or not.\n<b>We DO NOT store neither IP Address nor User Agent as a raw strings</b>, such data is stored as a salted hash for no longer than 30 minutes or 12:00 AM UTC, whatever happens first.\nAfter this timeframe the identifiable data is forever deleted from our servers.",+ "params": {+ "pid": "the unique Project ID request is related to.",+ "lc": "users locale (e.g. en_US or uk_UA).",+ "tz": "users timezone (e.g. Europe/Helsinki).",+ "ref": "the URL of the previous webpage from which a page was opened.",+ "so": "the page source ('ref' | 'source' | 'utm_source' GET param).",+ "me": "UTM medium ('utm_medium' GET param).",+ "ca": "UTM campaign ('utm_campaign' GET param).",+ "pg": "the page user currently views (e.g. /hello)."+ }+ },+ "contents": "Contents"+ },"titles": {"recovery": "Account recovery","signin": "Sign in",@@ -180,7 +213,8 @@"verification": "Email verification","profileSettings": "Profile settings","features": "Features",- "dashboard": "Dashboard"+ "dashboard": "Dashboard",+ "docs": "Documentation"},"footer": {"slogan": "The best apps need the best services.",diff --git a/src/pages/Docs/Docs.jsx b/src/pages/Docs/Docs.jsxindex 4f5c4d4ab..c55c7f4ad 100644--- a/src/pages/Docs/Docs.jsx+++ b/src/pages/Docs/Docs.jsx@@ -1,6 +1,7 @@import React, { memo, Fragment, useEffect } from 'react'import _map from 'lodash/map'import Prism from 'prismjs'+import { useTranslation, Trans } from 'react-i18next'import Title from 'components/Title'import Code from 'ui/Code'@@ -8,28 +9,28 @@ import {umdBuildExample, trackPageView, trackPVAPI, init, track, trackExample, npmInstall, esExample, npmImport,} from './examples'-const contents = [{- name: 'Getting Started',+const contents = (t) => [{+ name: t('docs.titles.start'),id: 'docs-gs',content: [{- name: 'UMD Build',+ name: t('docs.titles.umd'),id: 'docs-umd',}, {- name: 'NPM Package',+ name: t('docs.titles.npm'),id: 'docs-npm',}]}, {- name: 'How to..',+ name: t('docs.titles.how'),id: 'docs-ht',content: [{- name: 'Track pageviews',+ name: t('docs.titles.pv'),id: 'docs-pv',}, {- name: 'Track custom events',+ name: t('docs.titles.ce'),id: 'docs-ce',}]}, {- name: 'API',+ name: t('docs.titles.api'),id: 'docs-api',content: [{name: 'init',@@ -43,27 +44,34 @@ const contents = [{}]}]-const Contents = () => (- <div className='lg:flex flex-1 items-start justify-center lg:order-2'>- <h2 className='block lg:hidden text-3xl font-bold text-gray-900 tracking-tight'>Contents:</h2>- <ol className='mb-10 lg:mb-0 lg:sticky lg:top-10'>- {_map(contents, ({ name, id, content }) => (- <Fragment key={id}>- <li className='mt-3'>- <a className='hover:underline text-2xl text-blue-600 font-bold' href={`#${id}`}>{name}</a>- </li>- <ol>- {_map(content, ({ name: cname, id: cid }) => (- <li key={cid}>- <a className='hover:underline text-lg text-blue-500 px-4' href={`#${cid}`}>{cname}</a>- </li>- ))}- </ol>- </Fragment>- ))}- </ol>- </div>-)+const Contents = ({ t }) => {+ const tContents = contents(t)++ return (+ <div className='lg:flex flex-1 items-start justify-center lg:order-2'>+ <h2 className='block lg:hidden text-3xl font-bold text-gray-900 tracking-tight'>+ {t('docs.contents')}+ :+ </h2>+ <ol className='mb-10 lg:mb-0 lg:sticky lg:top-10'>+ {_map(tContents, ({ name, id, content }) => (+ <Fragment key={id}>+ <li className='mt-3'>+ <a className='hover:underline text-2xl text-blue-600 font-bold' href={`#${id}`}>{name}</a>+ </li>+ <ol>+ {_map(content, ({ name: cname, id: cid }) => (+ <li key={cid}>+ <a className='hover:underline text-lg text-blue-500 px-4' href={`#${cid}`}>{cname}</a>+ </li>+ ))}+ </ol>+ </Fragment>+ ))}+ </ol>+ </div>+ )+}const CHeader = ({ id, name, addHr = true }) => (<>@@ -79,90 +87,91 @@ const CSection = ({ id, name }) => ()const Docs = () => {+ const { t } = useTranslation('common')+useEffect(() => {Prism.highlightAll()}, [])return (- <Title title='Docs'>+ <Title title={t('titles.docs')}><div className='bg-gray-50'><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'>- <Contents />+ <Contents t={t} /><div className='flex-1 lg:order-1'>- <h1 className='text-4xl font-extrabold text-gray-900 tracking-tight'>Documentation</h1>+ <h1 className='text-4xl font-extrabold text-gray-900 tracking-tight'>+ {t('titles.docs')}+ </h1>- <CHeader id='docs-gs' name='Getting Started' addHr={false} />- <CSection id='docs-umd' name='UMD Build' />+ <CHeader id='docs-gs' name={t('docs.titles.start')} addHr={false} />+ <CSection id='docs-umd' name={t('docs.titles.umd')} /><Code text={umdBuildExample} language='html' />- <CSection id='docs-npm' name='NPM Package' />+ <CSection id='docs-npm' name={t('docs.titles.npm')} /><p className='text-lg text-gray-900 tracking-tight'>- You can also install the tracking script with NPM or Yarn:+ {t('docs.install')}+ :</p><Code text={npmInstall} language='bash' /><p className='text-lg text-gray-900 tracking-tight'>- Next you should import module into your project's root, for example:+ {t('docs.import')}+ :</p><Code text={npmImport} language='javascript' /><p className='text-lg text-gray-900 tracking-tight'>- After you can track anything you want.<br />- Read the detailed documentation on tracking params below.+ {t('docs.track')}</p><Code text={esExample} language='javascript' />- <CHeader id='docs-ht' name='How to..' />- <CSection id='docs-pv' name='Track pageviews' />+ <CHeader id='docs-ht' name={t('docs.titles.how')} />+ <CSection id='docs-pv' name={t('docs.titles.pv')} /><p className='text-lg text-gray-900 tracking-tight'>- Swetrix.js tracking script provides a way to collect a page view event once the page has loaded.<br />- This can be accomplished via calling the <span className='font-bold'>trackViews()</span> function:<br />+ <Trans+ t={t}+ i18nKey='docs.pv'+ components={{+ link: <a href='#docs-tv' className='font-bold hover:underline' />,+ }}+ /></p><Code text={trackPageView} language='javascript' />- <CSection id='docs-ce' name='Track custom events' />+ <CSection id='docs-ce' name={t('docs.titles.ce')} /><p className='text-lg text-gray-900 tracking-tight'>- In addition to tracking pageviews we provide an ability to track custom events. <br />- For example, if you want to track an event like 'Sign up' or 'Newsletter subscription', this feature would be very useful.<br />- Under the screen, the principle of this function is similar to trackViews.+ {t('docs.ce')}</p><Code text={trackExample} language='javascript' />- <CHeader id='docs-api' name='API' />+ <CHeader id='docs-api' name={t('docs.titles.api')} /><CSection id='docs-init' name='init' /><p className='text-lg text-gray-900 tracking-tight'>- This fuction is used to initialise the analytics.<br />- Basically you're letting the script know which project do you want to use it with, as well as specifying your custom parameters if needed.+ {t('docs.init')}</p><Code text={init} language='javascript' /><CSection id='docs-tr' name='track' /><p className='text-lg text-gray-900 tracking-tight'>- With this function you are able to track any custom events you want.<br />- You should never send any identifiable data (like User ID, email, session cookie, etc.) as an event name.<br />- The total number of track calls and their conversion rate will be saved.+ {t('docs.tr')}</p><Code text={track} language='javascript' /><CSection id='docs-tv' name='trackViews' /><p className='text-lg text-gray-900 tracking-tight'>- Calling trackViews will result in sending the data about the user to our servers.<br />- Such data will include the next params if available:<br />+ {t('docs.tv.call')}<div className='mb-5'><ul className='ml-10'>- <li><b>pid</b> - the unique Project ID request is related to.</li>- <li><b>lc</b> - users locale (e.g. en_US or uk_UA).</li>- <li><b>tz</b> - users timezone (e.g. Europe/Helsinki).</li>- <li><b>ref</b> - the URL of the previous webpage from which a page was opened.</li>- <li><b>so</b> - the page source ('ref' | 'source' | 'utm_source' GET param).</li>- <li><b>me</b> - UTM medium ('utm_medium' GET param).</li>- <li><b>ca</b> - UTM campaign ('utm_campaign' GET param).</li>- <li><b>pg</b> - the page user currently views (e.g. /hello)</li>+ <li><b>pid</b> - {t('docs.tv.params.pid')}</li>+ <li><b>lc</b> - {t('docs.tv.params.lc')}</li>+ <li><b>tz</b> - {t('docs.tv.params.tz')}</li>+ <li><b>ref</b> - {t('docs.tv.params.ref')}</li>+ <li><b>so</b> - {t('docs.tv.params.so')}</li>+ <li><b>me</b> - {t('docs.tv.params.me')}</li>+ <li><b>ca</b> - {t('docs.tv.params.ca')}</li>+ <li><b>pg</b> - {t('docs.tv.params.pg')}</li></ul></div>- On the server side we also gather users IP Address and User Agent.<br />- This data is used to detect whether the page view is unique or not.<br />- <b>We DO NOT store neither IP Address nor User Agent as a raw strings</b>, such data is stored as a salted hash for no longer than 30 minutes or 12:00 AM UTC, whatever happens first.<br />- After this timeframe the identifiable data is forever deleted from our servers.+ {t('docs.tv.gather')}</p><Code text={trackPVAPI} language='javascript' />