How to use next-translate - 9 common examples

To help you get started, we’ve selected a few next-translate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vinissimus / next-translate / examples / static-site / pages_ / more-examples / index.js View on Github external
export default function MoreExamples() {
  const { t, lang } = useTranslation()
  const exampleWithVariable = t('more-examples:example-with-variable', {
    count: 42,
  })

  return (
    <>
      <header>
      <h2>{exampleWithVariable}</h2>
      
      , <b>]}
      /&gt;
      
      <br>
      {t`more-examples:nested-example.very-nested.nested`}</b></header>
github vinissimus / next-translate / examples / static-site / components / plural-example.js View on Github external
export default function PluralExample() {
  const [count, setCount] = useState(0)
  const { t } = useTranslation()

  useEffect(() =&gt; {
    const interval = setInterval(() =&gt; {
      setCount(v =&gt; (v === 5 ? 0 : v + 1))
    }, 1000)

    return () =&gt; clearInterval(interval)
  }, [])

  return <p>{t('more-examples:plural-example', { count })}</p>
}
github vinissimus / next-translate / examples / static-site / pages_ / index.js View on Github external
export default function Home() {
  const { t, lang } = useTranslation()
  const description = t('home:description')
  const linkName = t('home:more-examples')

  return (
    &lt;&gt;
      <header>
      <p>{description}</p>
      
        <a>{linkName}</a>
      
    
  )
}
</header>
github vinissimus / next-translate / examples / with-server / components / plural-example.js View on Github external
export default function PluralExample() {
  const [count, setCount] = useState(0)
  const { t } = useTranslation()

  useEffect(() =&gt; {
    const interval = setInterval(() =&gt; {
      setCount(v =&gt; (v === 5 ? 0 : v + 1))
    }, 1000)

    return () =&gt; clearInterval(interval)
  }, [])

  return <p>{t('more-examples:plural-example', { count })}</p>
}
github vinissimus / next-translate / examples / static-site / components / header.js View on Github external
export default function Header() {
  const { t, lang } = useTranslation()
  const title = t('common:title')

  return (
    &lt;&gt;
      
        <title>
          {title} | ({lang.toUpperCase()})
        </title>
        
      
      <header>
        <h1>{title}</h1>
        {lang !== 'es' &amp;&amp; (
          
            <a>Español</a>
          </header>
github vinissimus / next-translate / examples / with-server / pages / more-examples / index.js View on Github external
export default function MoreExamples() {
  const { t, lang } = useTranslation()
  const exampleWithVariable = t('more-examples:example-with-variable', {
    count: 42,
  })

  return (
    &lt;&gt;
      <h2>{exampleWithVariable}</h2>
      
      , <b>]}
      /&gt;
      
      <br>
      {t`more-examples:nested-example.very-nested.nested`}
      <br></b>
github vinissimus / next-translate / examples / with-server / components / header.js View on Github external
export default function Header() {
  const { t, lang } = useTranslation()
  const title = t('common:title')

  return (
    &lt;&gt;
      
        <title>
          {title} | ({lang.toUpperCase()})
        </title>
        
      
      <header>
        <h1>{title}</h1>
        {lang !== 'es' &amp;&amp; (
          
            <a>Español</a>
          </header>
github vinissimus / next-translate / examples / with-server / pages / index.js View on Github external
export default function Home() {
  const { t, lang } = useTranslation()
  const description = t('home:description')
  const linkName = t('home:more-examples')

  return (
    &lt;&gt;
      <header>
      <p>{description}</p>
      
        <a>{linkName}</a>
      
    
  )
}
</header>
github vinissimus / next-translate / examples / with-server / pages / _app.js View on Github external
import appWithI18n from 'next-translate/appWithI18n'
import i18nConfig from '../i18n'

function MyApp({ Component, pageProps }) {
  return 
}

export default appWithI18n(MyApp, i18nConfig)

next-translate

Tiny and powerful i18n tools (Next plugin + API) to translate your Next.js pages.

MIT
Latest version published 6 months ago

Package Health Score

82 / 100
Full package analysis