Giter VIP home page Giter VIP logo

nextjs-i18n-static-page-starter's Introduction

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ
I released a better solution: next-i18next-static-site
This package brings you react-i18next and i18next to your static sites build with the next export future from Next.js.

  • ๐Ÿ—ฒ Translation is already rendered (SSG), client will receive the final translated site.
  • ๐Ÿ”ฅ Hot reload works also when you update your locale (translation) files.
  • ๐Ÿš€ Automatic browser language detection can be realized.
  • ๐Ÿช Cookie stores the client language.

It's highly recommend to use next-i18next-static-site instead of this starter if you want to use all functions from react-i18next.

Next.js i18n Starter for Static Pages

This starter allows you to use the next export future from Next.js in combination with i18n to create a complete static site.

Clients will directly redirected from / to /[lang] based on the detected language.

Packages included:

Installation

Clone the repository and run npm ci (recommend) or npm install.

Configuration

  • Set the supported languages, default language, namespaces and default namespace in /src/i18n/config.js
  • Locales are located in /src/locales/
    • To prevent mess, you can split the .json translation file(s) into multiple namespaces

Development

Run npm run dev to start the development server on http://localhost:3000.
Visit http://localhost:3000 to view this starter.

Link Usage

There is a custom wrapper for <Link> that will handle the i18n linking, just replace next/link with src/components/link.

Set locale to force a specific language for a given href:

<Link href="/somesite" locale="en">
  <a>Somesite (EN)</a>
</Link>

To change the language of the current site you only need locale, href will be grabbed automatically:

<Link locale="de">
  <a>Current site (DE)</a>
</Link>

Build and Export Static Pages

npm run export

Tipp: You could deploy static sites totally for free on Cloudflare Pages.

Test/Serve the Site Locally

npm run serve

Example

nextjs-i18n-static-page-starter's People

Contributors

tambaqui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nextjs-i18n-static-page-starter's Issues

Text formatting

First off, thank you for creating this starter. Was using next-translate until the last moment when I discovered Next 10's lack of support for export.
Is there any way one could also do text formatting, without resorting to css styling. There's the Trans component for React i18next. Couldn't find anything for pure i18next.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.